Last updated: 2020-02-21
Checks: 6 1
Knit directory: SMF/
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(20190719)
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.
Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.
absolute | relative |
---|---|
~/SMF/data/lowgene/ | data/lowgene |
~/SMF/data/lowgene/Counts_20:57603732-57607422.txt.gz_NMF_mkl_scd_K3_base10.RData | data/lowgene/Counts_20:57603732-57607422.txt.gz_NMF_mkl_scd_K3_base10.RData |
~/SMF/data/lowgene/Counts_20:57603732-57607422.txt.gz_stm_nugget_K3_base10.RData | data/lowgene/Counts_20:57603732-57607422.txt.gz_stm_nugget_K3_base10.RData |
~/SMF/data/lowgene/Counts_10:73576054-73611082.txt.gz_NMF_mkl_scd_K3_base10.RData | data/lowgene/Counts_10:73576054-73611082.txt.gz_NMF_mkl_scd_K3_base10.RData |
~/SMF/data/lowgene/Counts_10:73576054-73611082.txt.gz_stm_nugget_K3_base10.RData | data/lowgene/Counts_10:73576054-73611082.txt.gz_stm_nugget_K3_base10.RData |
~/SMF/data/lowgene/Counts_3:101399933-101405563.txt.gz_NMF_mkl_scd_K3_base10.RData | data/lowgene/Counts_3:101399933-101405563.txt.gz_NMF_mkl_scd_K3_base10.RData |
~/SMF/data/lowgene/Counts_3:101399933-101405563.txt.gz_stm_nugget_K3_base10.RData | data/lowgene/Counts_3:101399933-101405563.txt.gz_stm_nugget_K3_base10.RData |
~/SMF/data/lowgene/Counts_6:44214694-44221625.txt.gz_NMF_mkl_scd_K3_base10.RData | data/lowgene/Counts_6:44214694-44221625.txt.gz_NMF_mkl_scd_K3_base10.RData |
~/SMF/data/lowgene/Counts_6:44214694-44221625.txt.gz_stm_nugget_K3_base10.RData | data/lowgene/Counts_6:44214694-44221625.txt.gz_stm_nugget_K3_base10.RData |
~/SMF/data/lowgene/Counts_19:2269519-2273487.txt.gz_NMF_mkl_scd_K3_base10.RData | data/lowgene/Counts_19:2269519-2273487.txt.gz_NMF_mkl_scd_K3_base10.RData |
~/SMF/data/lowgene/Counts_19:2269519-2273487.txt.gz_stm_nugget_K3_base10.RData | data/lowgene/Counts_19:2269519-2273487.txt.gz_stm_nugget_K3_base10.RData |
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: code/lowgene.R
Untracked: data/lowgene/
Untracked: data/stmGTEx/
Unstaged changes:
Modified: analysis/stmGTEx.Rmd
Deleted: data/GPX3_NMF_mkl_scd_K3.RData
Deleted: data/GPX3_NMF_mkl_scd_K3_base10.RData
Deleted: data/GPX3_NMF_mkl_scd_K3_base5.RData
Deleted: data/GPX3_hals_runmed_K3.RData
Deleted: data/GPX3_hals_runmed_K3_base10.RData
Deleted: data/GPX3_hals_runmed_K3_base5.RData
Deleted: data/GPX3_hals_wavelet_K3.RData
Deleted: data/GPX3_hals_wavelet_K3_base10.RData
Deleted: data/GPX3_hals_wavelet_K3_base5.RData
Deleted: data/GPX3_stm_bmsm_K3.RData
Deleted: data/GPX3_stm_bmsm_K3_base10.RData
Deleted: data/GPX3_stm_bmsm_K3_base5.RData
Deleted: data/GPX3_stm_nugget_K3.RData
Deleted: data/GPX3_stm_nugget_K3_base10.RData
Deleted: data/GPX3_stm_nugget_K3_base5.RData
Deleted: data/GPX3_stm_nugget_robust_K3.RData
Deleted: data/GPX3_stm_nugget_robust_K3_base10.RData
Deleted: data/GPX3_stm_nugget_robust_K3_base5.RData
Deleted: data/PSAP_NMF_mkl_scd_K3.RData
Deleted: data/PSAP_NMF_mkl_scd_K3_base10.RData
Deleted: data/PSAP_NMF_mkl_scd_K3_base5.RData
Deleted: data/PSAP_hals_runmed_K3.RData
Deleted: data/PSAP_hals_runmed_K3_base10.RData
Deleted: data/PSAP_hals_runmed_K3_base5.RData
Deleted: data/PSAP_hals_wavelet_K3.RData
Deleted: data/PSAP_hals_wavelet_K3_base10.RData
Deleted: data/PSAP_hals_wavelet_K3_base5.RData
Deleted: data/PSAP_stm_bmsm_K3.RData
Deleted: data/PSAP_stm_bmsm_K3_base10.RData
Deleted: data/PSAP_stm_bmsm_K3_base5.RData
Deleted: data/PSAP_stm_nugget_K3.RData
Deleted: data/PSAP_stm_nugget_K3_base10.RData
Deleted: data/PSAP_stm_nugget_K3_base5.RData
Deleted: data/PSAP_stm_nugget_robust_K3.RData
Deleted: data/PSAP_stm_nugget_robust_K3_base10.RData
Deleted: data/PSAP_stm_nugget_robust_K3_base5.RData
Deleted: data/RPS13_NMF_mkl_scd_K3.RData
Deleted: data/RPS13_NMF_mkl_scd_K3_base10.RData
Deleted: data/RPS13_NMF_mkl_scd_K3_base5.RData
Deleted: data/RPS13_hals_runmed_K3.RData
Deleted: data/RPS13_hals_runmed_K3_base10.RData
Deleted: data/RPS13_hals_runmed_K3_base5.RData
Deleted: data/RPS13_hals_wavelet_K3.RData
Deleted: data/RPS13_hals_wavelet_K3_base10.RData
Deleted: data/RPS13_hals_wavelet_K3_base5.RData
Deleted: data/RPS13_stm_bmsm_K3.RData
Deleted: data/RPS13_stm_bmsm_K3_base10.RData
Deleted: data/RPS13_stm_bmsm_K3_base5.RData
Deleted: data/RPS13_stm_nugget_K3.RData
Deleted: data/RPS13_stm_nugget_K3_base10.RData
Deleted: data/RPS13_stm_nugget_K3_base5.RData
Deleted: data/RPS13_stm_nugget_robust_K3.RData
Deleted: data/RPS13_stm_nugget_robust_K3_base10.RData
Deleted: data/RPS13_stm_nugget_robust_K3_base5.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 | fff278e | DongyueXie | 2020-02-21 | wflow_publish(“analysis/lowgene.Rmd”) |
library(stm)
library(NNLM)
sum_base = function(x,base){
x = x[1:(floor(length(x)/base)*base)]
colSums(matrix(x,nrow=base))
}
#compare methods like nmf, stm-bmsm, stm-smashgen, stm-smashgen robust, HALS-wavelet, HALS-runmed
gene_splicing_study = function(X,name,K,nreps = 6,seed=12345,base=1,path){
set.seed(seed)
if(base>1){
X = t(apply(X, 1, sum_base,base=base))
}
nmf_loss = Inf
stm_loss = Inf
stm_nugget_loss = Inf
stm_nugget_robust_loss = Inf
hals_wavelet_loss = Inf
hals_runmed_loss = Inf
for (reps in 1:nreps) {
print(reps)
fit_NMF = nnmf(X,k=K,method = 'scd',loss='mkl',verbose = F)
if(min(fit_NMF$mkl)<nmf_loss){
nmf_loss = min(fit_NMF$mkl)
save(fit_NMF,file = paste(path,name,'_NMF_mkl_scd_K',K,'_base',base,'.RData',sep = ''))
}
fit_stm = stm(X,K,init = list(L_init=fit_NMF$W,F_init = fit_NMF$H),
return_all = FALSE,tol=1e-3,maxiter=50,printevery = 1e5)
if(fit_stm$KL[length(fit_stm$KL)]<stm_loss){
stm_loss=fit_stm$KL[length(fit_stm$KL)]
save(fit_stm,file=paste(path,name,'_stm_bmsm_K',K,'_base',base,'.RData',sep = ''))
}
fit_stm_nugget_robust = stm(X,K,init = list(L_init=fit_NMF$W,F_init = fit_NMF$H),
return_all = FALSE,tol=1e-2,nugget = TRUE,maxiter=50,printevery = 1e5)
if(fit_stm_nugget_robust$KL[length(fit_stm_nugget_robust$KL)]<stm_nugget_robust_loss){
stm_nugget_robust_loss=fit_stm_nugget_robust$KL[length(fit_stm_nugget_robust$KL)]
save(fit_stm_nugget_robust,file=paste(path,name,'_stm_nugget_robust_K',K,'_base',base,'.RData',sep = ''))
}
fit_stm_nugget = stm(X,K,init = list(L_init=fit_NMF$W,F_init = fit_NMF$H),
return_all = FALSE,tol=1e-2,nugget = TRUE,maxiter=50,printevery = 1e5,
nug_control_f = list(robust=F))
if(fit_stm_nugget$KL[length(fit_stm_nugget$KL)]<stm_nugget_loss){
stm_nugget_loss=fit_stm_nugget$KL[length(fit_stm_nugget$KL)]
save(fit_stm_nugget,file=paste(path,name,'_stm_nugget_K',K,'_base',base,'.RData',sep = ''))
}
fit_hals_wavelet = NMF_HALS(X,K,smooth_method = 'wavelet',printevery = 1e5)
if(fit_hals_wavelet$loss[length(fit_hals_wavelet$loss)]<hals_wavelet_loss){
hals_wavelet_loss = fit_hals_wavelet$loss[length(fit_hals_wavelet$loss)]
save(fit_hals_wavelet,file=paste(path,name,'_hals_wavelet_K',K,'_base',base,'.RData',sep = ''))
}
fit_hals_runmed = NMF_HALS(X,K,smooth_method = 'runmed',printevery = 1e5)
if(fit_hals_runmed$loss[length(fit_hals_runmed$loss)]<hals_runmed_loss){
hals_runmed_loss = fit_hals_runmed$loss[length(fit_hals_runmed$loss)]
save(fit_hals_runmed,file=paste(path,name,'_hals_runmed_K',K,'_base',base,'.RData',sep = ''))
}
}
}
plot_factors3 = function(X,method){
plot(X[,1],col=2,ylim=range(lf$FF),type='l',xlab = '',ylab='Intensity',main=paste('Factors - ',method,sep=''))
lines(X[,2],col=3)
lines(X[,3],col=4)
}
find genes with small 95% quantile of expression
path = '/home/dyxie/NMF/YangLi/readcount'
count.files = list.files(path=path)
data.list = lapply(count.files,function(x){
datax = read.table(paste(path,'/',x,sep='',collapse = ''),header = T)
quantile(rowSums(datax[,-c(1:3)])/457,0.99)
#mean(rowSums(datax[,-c(1:3)])/457)
})
gene.order = order(unlist(data.list),decreasing = F)
run models for top 5 genes with smallest expression.
library(CountClust)
Loading required package: ggplot2
# K=3
# base=10
# path.save = '~/SMF/data/lowgene/'
# for(gene in gene.order[1:5]){
# X = read.table(paste(path,'/',count.files[gene],sep='',collapse = ''),header = T)
# X = t(X[,-c(1:3)])
# gene_splicing_study(X,count.files[gene],K,base=base,path=path.save)
# }
#plot results, factors and structure plot.
#compare nmf, smashgen_nmf, hals_runmed
load("~/SMF/data/lowgene/Counts_20:57603732-57607422.txt.gz_NMF_mkl_scd_K3_base10.RData")
load("~/SMF/data/lowgene/Counts_20:57603732-57607422.txt.gz_stm_nugget_K3_base10.RData")
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
plot_factors3(lf$FF,'NMF')
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
plot_factors3(lf$FF,'smoothed')
library(gridExtra)
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
annotation = data.frame(sample_id=1:length(fit_NMF$label),tissue_label=fit_NMF$label)
a=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'NMF',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
b=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'smoothed',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
grid.arrange(a, b, ncol=2)
load("~/SMF/data/lowgene/Counts_10:73576054-73611082.txt.gz_NMF_mkl_scd_K3_base10.RData")
load("~/SMF/data/lowgene/Counts_10:73576054-73611082.txt.gz_stm_nugget_K3_base10.RData")
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
plot_factors3(lf$FF,'NMF')
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
plot_factors3(lf$FF,'smoothed')
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
annotation = data.frame(sample_id=1:length(fit_NMF$label),tissue_label=fit_NMF$label)
a=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'NMF',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
b=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'smoothed',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
grid.arrange(a, b, ncol=2)
load("~/SMF/data/lowgene/Counts_3:101399933-101405563.txt.gz_NMF_mkl_scd_K3_base10.RData")
load("~/SMF/data/lowgene/Counts_3:101399933-101405563.txt.gz_stm_nugget_K3_base10.RData")
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
plot_factors3(lf$FF,'NMF')
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
plot_factors3(lf$FF,'smoothed')
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
annotation = data.frame(sample_id=1:457,tissue_label=c(rep('Adipose',226),rep('Skin',231)))
a=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'NMF',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
b=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'smoothed',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
grid.arrange(a, b, ncol=2)
load("~/SMF/data/lowgene/Counts_6:44214694-44221625.txt.gz_NMF_mkl_scd_K3_base10.RData")
load("~/SMF/data/lowgene/Counts_6:44214694-44221625.txt.gz_stm_nugget_K3_base10.RData")
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
plot_factors3(lf$FF,'NMF')
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
plot_factors3(lf$FF,'smoothed')
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
annotation = data.frame(sample_id=1:457,tissue_label=c(rep('Adipose',226),rep('Skin',231)))
a=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'NMF',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
b=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'smoothed',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
grid.arrange(a, b, ncol=2)
load("~/SMF/data/lowgene/Counts_19:2269519-2273487.txt.gz_NMF_mkl_scd_K3_base10.RData")
load("~/SMF/data/lowgene/Counts_19:2269519-2273487.txt.gz_stm_nugget_K3_base10.RData")
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
plot_factors3(lf$FF,'NMF')
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
plot_factors3(lf$FF,'smoothed')
lf = poisson2multinom(t(fit_NMF$H),fit_NMF$W)
annotation = data.frame(sample_id=1:length(fit_NMF$label),tissue_label=fit_NMF$label)
a=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'NMF',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
lf = poisson2multinom(t(fit_stm_nugget$qf),fit_stm_nugget$ql)
b=StructureGGplot(lf$L,annotation,palette = c(2,3,4),order_sample = TRUE,figure_title = 'smoothed',
axis_tick = list(axis_ticks_length = .1,
axis_ticks_lwd_y = .1,
axis_ticks_lwd_x = .1,
axis_label_size = 7,
axis_label_face = "bold"))
grid.arrange(a, b, ncol=2)
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] gridExtra_2.3 CountClust_1.6.2 ggplot2_3.1.1 NNLM_0.4.2
[5] stm_1.0.0
loaded via a namespace (and not attached):
[1] genlasso_1.4 foreach_1.4.4 gtools_3.8.1
[4] assertthat_0.2.0 mixsqp_0.2-2 highr_0.7
[7] stats4_3.5.1 yaml_2.2.0 slam_0.1-43
[10] pillar_1.3.1 backports_1.1.2 lattice_0.20-38
[13] glue_1.3.0 limma_3.38.2 digest_0.6.18
[16] promises_1.0.1 colorspace_1.3-2 picante_1.7
[19] cowplot_0.9.4 htmltools_0.3.6 httpuv_1.4.5
[22] Matrix_1.2-15 plyr_1.8.4 pkgconfig_2.0.2
[25] purrr_0.3.2 scales_1.0.0 whisker_0.3-2
[28] later_0.7.5 Rtsne_0.15 git2r_0.26.1
[31] tibble_2.1.1 mgcv_1.8-25 withr_2.1.2
[34] ashr_2.2-39 nnet_7.3-12 lazyeval_0.2.1
[37] magrittr_1.5 crayon_1.3.4 evaluate_0.12
[40] ebpm_0.0.0.9004 fs_1.3.1 wavethresh_4.6.8
[43] doParallel_1.0.14 nlme_3.1-137 MASS_7.3-51.1
[46] truncnorm_1.0-8 vegan_2.5-3 tools_3.5.1
[49] data.table_1.12.0 stringr_1.3.1 munsell_0.5.0
[52] cluster_2.0.7-1 compiler_3.5.1 caTools_1.17.1.1
[55] mapplots_1.5.1 rlang_0.4.0 grid_3.5.1
[58] iterators_1.0.10 igraph_1.2.2 bitops_1.0-6
[61] rmarkdown_1.10 boot_1.3-20 gtable_0.2.0
[64] codetools_0.2-15 flexmix_2.3-14 reshape2_1.4.3
[67] R6_2.3.0 knitr_1.20 dplyr_0.8.0.1
[70] workflowr_1.6.0 rprojroot_1.3-2 smashr_1.2-7
[73] maptpx_1.9-7 permute_0.9-4 ape_5.2
[76] modeltools_0.2-22 stringi_1.2.4 pscl_1.5.2
[79] parallel_3.5.1 SQUAREM_2017.10-1 Rcpp_1.0.2
[82] tidyselect_0.2.5