Last updated: 2019-11-05
Checks: 7 0
Knit directory: SMF/
This reproducible R Markdown analysis was created with workflowr (version 1.5.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.
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: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Untracked files:
Untracked: analysis/SmoothPMF.Rmd
Untracked: code/BMSM.R
Untracked: code/ebbp_beta_mixture.R
Untracked: code/ebpm_exp_mixture.R
Untracked: code/update_f.R
Untracked: code/update_l.R
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 |
---|---|---|---|---|
html | 97d85f1 | Dongyue Xie | 2019-11-05 | Build site. |
Rmd | 2434973 | Dongyue Xie | 2019-11-05 | wflow_publish(“analysis/nmfsparse.Rmd”) |
html | 1aacddd | Dongyue Xie | 2019-11-05 | Build site. |
Rmd | cf54a3e | Dongyue Xie | 2019-11-05 | wflow_publish(“analysis/nmfsparse.Rmd”) |
L1 penalty in NNLM::nnmf either put no/littlle thresholding or thresholds all entries to zero.
nsNMF and snmf in NMF package give sparse estimate of loadings and factors.
set.seed(123)
n = 99
p = 300
k= 4
mfac = 2 # controls PVE of dense factor
L = matrix(0, nrow=n, ncol=k)
F = matrix(0, nrow=p, ncol=k)
L[1:(n/3),1] = 1
L[((n/3)+1):(2*n/3),2] = 1
L[((2*n/3)+1):n,3] = 1
L[,4] = 1+mfac*runif(n)
F[1:(p/3),1] = 1+10*runif(p/3)
F[((p/3)+1):(2*p/3),2] = 1+10*runif(p/3)
F[((2*p/3)+1):p,3] = 1+10*runif(p/3)
F[,4]= 1+mfac*runif(p)
lambda = L %*% t(F)
X = matrix(rpois(n=length(lambda),lambda),nrow=n)
image(X)
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
library(NNLM)
fit_scd_L1.1 = NNLM::nnmf(A = X, k = 4, loss = "mse", method = "scd", max.iter = 10000, alpha=c(0,0,1))
for(i in 1:k){
plot(fit_scd_L1.1$W[,i],main=paste0("L1 penalty = 1: estimated loadings ",i))
}
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
fit_scd_L1.10 = NNLM::nnmf(A = X, k = 4, loss = "mse", method = "scd", max.iter = 10000, alpha=c(0,0,10))
for(i in 1:k){
plot(fit_scd_L1.10$W[,i],main=paste0("L1 penalty = 10: estimated loadings ",i))
}
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
fit_scd_L1.11 = NNLM::nnmf(A = X, k = 4, loss = "mse", method = "scd", max.iter = 10000, alpha=c(0,0,11))
for(i in 1:k){
plot(fit_scd_L1.11$W[,i],main=paste0("L1 penalty = 11: estimated loadings ",i))
}
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
fit_scd_L1.100 = NNLM::nnmf(A = X, k = 4, loss = "mse", method = "scd", max.iter = 10000, alpha=c(0,0,100))
for(i in 1:k){
plot(fit_scd_L1.100$W[,i],main=paste0("L1 penalty = 100: estimated loadings ",i))
}
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Non-smooth NMF. Uses a modified version of Lee and Seung’s multiplicative updates for Kullback-Leibler divergence to fit a extension of the standard NMF model. It is meant to give sparser results.
Reference: Pascual-Montano2006
library(NMF)
Loading required package: pkgmaker
Loading required package: registry
Attaching package: 'pkgmaker'
The following object is masked from 'package:base':
isFALSE
Loading required package: rngtools
Loading required package: cluster
NMF - BioConductor layer [OK] | Shared memory capabilities [NO: bigmemory] | Cores 7/8
To enable shared memory capabilities, try: install.extras('
NMF
')
fit_nsNMF = nmf(X,4,method = 'nsNMF')
for(i in 1:k){
plot(fit_nsNMF@fit@W[,i],main=paste0("nsNMF: estimated loadings ",i))
}
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
for(i in 1:k){
plot(fit_nsNMF@fit@H[i,],main=paste0("nsNMF: estimated factors ",i))
}
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Alternating Least Square (ALS) approach. It is meant to be very fast com- pared to other approaches.
Reference: KimH2007
Sparse Loading:
fit_snmfl = nmf(X,4,method = 'snmf/l',beta=1)
Warning in nmf_snmf(beta = 1, A = y, x = x, version = "L", verbose
= FALSE): NMF::snmf - Too many restarts due to too big 'beta' value
[Computation stopped after the 9th restart]
for(i in 1:k){
plot(fit_snmfl@fit@W[,i],main=paste0("snmfl: estimated loadings ",i))
}
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Sparse Factors:
fit_snmfr = nmf(X,4,method = 'snmf/r',beta=1)
Warning in nmf_snmf(beta = 1, A = y, x = x, version = "R", verbose
= FALSE): NMF::snmf - Too many restarts due to too big 'beta' value
[Computation stopped after the 9th restart]
for(i in 1:k){
plot(fit_snmfr@fit@H[i,],main=paste0("snmfr: estimated factors ",i))
}
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
Version | Author | Date |
---|---|---|
1aacddd | Dongyue Xie | 2019-11-05 |
sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] NMF_0.21.0 Biobase_2.44.0 BiocGenerics_0.30.0
[4] cluster_2.1.0 rngtools_1.4 pkgmaker_0.27
[7] registry_0.5-1 NNLM_0.4.3
loaded via a namespace (and not attached):
[1] tidyselect_0.2.5 xfun_0.10 purrr_0.3.2
[4] reshape2_1.4.3 colorspace_1.4-1 htmltools_0.4.0
[7] yaml_2.2.0 rlang_0.4.0 later_1.0.0
[10] pillar_1.4.2 glue_1.3.1 withr_2.1.2
[13] RColorBrewer_1.1-2 foreach_1.4.7 plyr_1.8.4
[16] stringr_1.4.0 munsell_0.5.0 gtable_0.3.0
[19] workflowr_1.5.0 codetools_0.2-16 evaluate_0.14
[22] knitr_1.25 doParallel_1.0.15 httpuv_1.5.2
[25] Rcpp_1.0.2 xtable_1.8-4 promises_1.1.0
[28] backports_1.1.5 scales_1.0.0 fs_1.3.1
[31] ggplot2_3.2.1 digest_0.6.21 stringi_1.4.3
[34] dplyr_0.8.3 grid_3.6.1 rprojroot_1.3-2
[37] bibtex_0.4.2 tools_3.6.1 magrittr_1.5
[40] lazyeval_0.2.2 tibble_2.1.3 crayon_1.3.4
[43] whisker_0.4 pkgconfig_2.0.3 gridBase_0.4-7
[46] assertthat_0.2.1 rmarkdown_1.16 iterators_1.0.12
[49] R6_2.4.0 git2r_0.26.1 compiler_3.6.1