Last updated: 2020-03-19
Checks: 7 0
Knit directory: misc/
This reproducible R Markdown analysis was created with workflowr (version 1.6.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20191122)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Untracked files:
Untracked: analysis/contrainedclustering.Rmd
Untracked: analysis/gsea.Rmd
Untracked: analysis/ideas.Rmd
Untracked: analysis/methylation.Rmd
Untracked: analysis/susie.Rmd
Untracked: code/sccytokines.R
Untracked: code/scdeCalibration.R
Untracked: data/bart/
Untracked: data/cytokine/DE_controls_output_filter10.RData
Untracked: data/cytokine/DE_controls_output_filter10_addlimma.RData
Untracked: data/cytokine/README
Untracked: data/cytokine/test.RData
Untracked: data/cytokine_normalized.RData
Untracked: data/deconv/
Untracked: data/scde/
Unstaged changes:
Modified: analysis/deconvolution.Rmd
Modified: analysis/index.Rmd
Deleted: data/mout_high.RData
Deleted: data/scCDT.RData
Deleted: data/sva_sva_high.RData
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view them.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | a7a0098 | DongyueXie | 2020-03-19 | wflow_publish(“analysis/scdeCheckAlpha.Rmd”) |
Compare the loglikelihood from sva-limma-ash, setting \(\alpha=0\) and \(\alpha=1\), on real data.
library(vicar)
library(sva)
Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-25. For overview type 'help("mgcv-package")'.
Loading required package: genefilter
Loading required package: BiocParallel
library(cate)
library(seqgendiff)
load('data/scde/scCD4.RData')
load('data/scde/scCD8.RData')
load('data/scde/scCD14.RData')
load('data/scde/scMB.RData')
CD4, CD8, CD14 and B cells. Look at number of genes and cells.
dim(CD4)
[1] 13713 709
dim(CD8)
[1] 13713 313
dim(CD14)
[1] 13713 432
dim(MB)
[1] 13713 342
Y = as.matrix(cbind(CD4,MB))
group_idx = c(rep(1,dim(CD4)[2]),rep(0,dim(MB)[2]))
# remove genes appearing in less than 10 cells
Y = Y[-which(rowSums(Y!=0)<10),]
X = model.matrix(~group_idx)
sva_sva = sva((Y),mod=X,mod0=X[,1],n.sv = 3)
Number of significant surrogate variables is: 3
Iteration (out of 5 ):1 2 3 4 5
X.sva <- cbind(X, sva_sva$sv)
lmout <- limma::lmFit(object = (Y), design = X.sva)
eout <- limma::eBayes(lmout)
svaout <- list()
svaout$betahat <- lmout$coefficients[, 2]
svaout$sebetahat <- lmout$stdev.unscaled[, 2] * sqrt(eout$s2.post)
svaout$pvalues <- eout$p.value[, 2]
# sva-limma-ash-alpha 0
sva_limma_ash0 = ashr::ash(svaout$betahat,svaout$sebetahat,alpha=0)
sva_limma_ash0$loglik
[1] 16134.95
# sva-limma-ash-alpha 1
sva_limma_ash1 = ashr::ash(svaout$betahat,svaout$sebetahat,alpha=1)
sva_limma_ash1$loglik
[1] 17052.65
Take log of Y
Y = log(Y+0.5)
sva_sva = sva((Y),mod=X,mod0=X[,1],n.sv = 3)
Number of significant surrogate variables is: 3
Iteration (out of 5 ):1 2 3 4 5
X.sva <- cbind(X, sva_sva$sv)
lmout <- limma::lmFit(object = (Y), design = X.sva)
eout <- limma::eBayes(lmout)
svaout <- list()
svaout$betahat <- lmout$coefficients[, 2]
svaout$sebetahat <- lmout$stdev.unscaled[, 2] * sqrt(eout$s2.post)
svaout$pvalues <- eout$p.value[, 2]
# sva-limma-ash-alpha 0
sva_limma_ash0 = ashr::ash(svaout$betahat,svaout$sebetahat,alpha=0)
sva_limma_ash0$loglik
[1] 16932.72
# sva-limma-ash-alpha 1
sva_limma_ash1 = ashr::ash(svaout$betahat,svaout$sebetahat,alpha=1)
sva_limma_ash1$loglik
[1] 17553.91
Y = as.matrix(cbind(CD8,CD14))
group_idx = c(rep(1,dim(CD8)[2]),rep(0,dim(CD14)[2]))
# remove genes appearing in less than 10 cells
Y = Y[-which(rowSums(Y!=0)<10),]
X = model.matrix(~group_idx)
sva_sva = sva((Y),mod=X,mod0=X[,1],n.sv = 3)
Number of significant surrogate variables is: 3
Iteration (out of 5 ):1 2 3 4 5
X.sva <- cbind(X, sva_sva$sv)
lmout <- limma::lmFit(object = (Y), design = X.sva)
eout <- limma::eBayes(lmout)
svaout <- list()
svaout$betahat <- lmout$coefficients[, 2]
svaout$sebetahat <- lmout$stdev.unscaled[, 2] * sqrt(eout$s2.post)
svaout$pvalues <- eout$p.value[, 2]
# sva-limma-ash-alpha 0
sva_limma_ash0 = ashr::ash(svaout$betahat,svaout$sebetahat,alpha=0)
sva_limma_ash0$loglik
[1] 14146.63
# sva-limma-ash-alpha 1
sva_limma_ash1 = ashr::ash(svaout$betahat,svaout$sebetahat,alpha=1)
sva_limma_ash1$loglik
[1] 15013.91
Take log of Y
Y = log(Y+0.5)
sva_sva = sva((Y),mod=X,mod0=X[,1],n.sv = 3)
Number of significant surrogate variables is: 3
Iteration (out of 5 ):1 2 3 4 5
X.sva <- cbind(X, sva_sva$sv)
lmout <- limma::lmFit(object = (Y), design = X.sva)
eout <- limma::eBayes(lmout)
svaout <- list()
svaout$betahat <- lmout$coefficients[, 2]
svaout$sebetahat <- lmout$stdev.unscaled[, 2] * sqrt(eout$s2.post)
svaout$pvalues <- eout$p.value[, 2]
# sva-limma-ash-alpha 0
sva_limma_ash0 = ashr::ash(svaout$betahat,svaout$sebetahat,alpha=0)
sva_limma_ash0$loglik
[1] 16077.39
# sva-limma-ash-alpha 1
sva_limma_ash1 = ashr::ash(svaout$betahat,svaout$sebetahat,alpha=1)
sva_limma_ash1$loglik
[1] 16362.59
Simulate the easiest case…
library(ashr)
set.seed(12345)
beta = c(rep(0,100),rnorm(100))
sebetahat = abs(rnorm(200,0,1))
betahat = rnorm(200,beta,sebetahat)
beta.ash0 = ash(betahat, sebetahat,alpha=0)
beta.ash0$loglik
[1] -281.6105
beta.ash1 = ash(betahat, sebetahat,alpha=1)
beta.ash1$loglik
[1] -324.1801
sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Scientific Linux 7.4 (Nitrogen)
Matrix products: default
BLAS/LAPACK: /software/openblas-0.2.19-el7-x86_64/lib/libopenblas_haswellp-r0.2.19.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ashr_2.2-39 seqgendiff_1.2.1 cate_1.0.4
[4] sva_3.30.0 BiocParallel_1.16.0 genefilter_1.64.0
[7] mgcv_1.8-25 nlme_3.1-137 vicar_0.1-10
loaded via a namespace (and not attached):
[1] Biobase_2.42.0 svd_0.4.1 foreach_1.4.4
[4] bit64_0.9-7 splines_3.5.1 assertthat_0.2.0
[7] mixsqp_0.2-2 stats4_3.5.1 blob_1.1.1
[10] yaml_2.2.0 pillar_1.3.1 RSQLite_2.1.1
[13] backports_1.1.2 lattice_0.20-38 glue_1.3.0
[16] limma_3.38.2 digest_0.6.18 promises_1.0.1
[19] colorspace_1.3-2 htmltools_0.3.6 httpuv_1.4.5
[22] Matrix_1.2-15 plyr_1.8.4 XML_3.98-1.16
[25] pkgconfig_2.0.2 esaBcv_1.2.1 purrr_0.3.2
[28] xtable_1.8-3 corpcor_1.6.9 scales_1.0.0
[31] whisker_0.3-2 later_0.7.5 git2r_0.26.1
[34] tibble_2.1.1 annotate_1.60.0 IRanges_2.16.0
[37] ggplot2_3.1.1 BiocGenerics_0.28.0 lazyeval_0.2.1
[40] survival_2.43-1 magrittr_1.5 crayon_1.3.4
[43] memoise_1.1.0 evaluate_0.12 fs_1.3.1
[46] doParallel_1.0.14 MASS_7.3-51.1 truncnorm_1.0-8
[49] tools_3.5.1 matrixStats_0.54.0 stringr_1.3.1
[52] S4Vectors_0.20.1 munsell_0.5.0 AnnotationDbi_1.44.0
[55] compiler_3.5.1 rlang_0.4.0 grid_3.5.1
[58] leapp_1.2 RCurl_1.95-4.11 iterators_1.0.10
[61] bitops_1.0-6 rmarkdown_1.10 codetools_0.2-15
[64] gtable_0.2.0 DBI_1.0.0 ruv_0.9.7
[67] R6_2.3.0 gridExtra_2.3 knitr_1.20
[70] dplyr_0.8.0.1 bit_1.1-14 workflowr_1.6.0
[73] rprojroot_1.3-2 pscl_1.5.2 stringi_1.2.4
[76] SQUAREM_2017.10-1 parallel_3.5.1 Rcpp_1.0.2
[79] tidyselect_0.2.5