Last updated: 2021-03-21

Checks: 7 0

Knit directory: fastTopics-experiments/analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(1) 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 results in this page were generated with repository version 833235b. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

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:    data/GSE103354_Trachea_droplet_UMIcounts.txt.gz
    Ignored:    data/droplet.RData
    Ignored:    data/pbmc_68k
    Ignored:    data/pbmc_68k.RData
    Ignored:    output/newsgroups/fits-newsgroups.RData
    Ignored:    output/newsgroups/rds/
    Ignored:    output/nips/fits-nips.RData
    Ignored:    output/nips/rds/

Unstaged changes:
    Modified:   analysis/scd_vs_ccd.R
    Modified:   matlab/dat100x200.mat

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 repository in which changes were made to the R Markdown (analysis/scd_vs_ccd.Rmd) and HTML (docs/scd_vs_ccd.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 833235b Peter Carbonetto 2021-03-21 workflowr::wflow_publish(“scd_vs_ccd.Rmd”, view = FALSE)
Rmd ff4bd15 Peter Carbonetto 2021-03-21 Added link to overview page.

Add text here.

Load the packages used in the analysis below.

library(R.matlab)
library(NNLM)
library(fastTopics)

Set the seed so that the results can be reproduced.

set.seed(1)

Simulate a 100 x 200 counts matrix.

X <- simulate_count_data(100,200,3)$X

Add text here.

fit0 <- fit_poisson_nmf(X,k = 3,numiter = 20,method = "mu",
                        control = list(numiter = 1))
# Using 56 RcppParallel threads.
# Using 56 RcppParallel threads.
writeMat("../matlab/dat100x200.mat",X = X,L0 = fit0$L,F0 = fit0$F)
# Initializing factors using Topic SCORE algorithm.
# Initializing loadings by running 10 SCD updates.
# Fitting rank-3 Poisson NMF to 100 x 200 dense matrix.
# Running 20 multiplicative updates, without extrapolation (fastTopics 0.5-24).

Run 40 multiplicative (EM) updates as implemented in the NNLM package.

fit1 <- suppressWarnings(nnmf(X,k = 3,init = list(W = fit0$L,H = t(fit0$F)),
                              method = "lee",loss = "mkl",max.iter = 40,
                              trace = 1,rel.tol = 0,inner.max.iter = 1,
                              inner.rel.tol = 0,n.threads = 1))

Run 40 SCD updates as implemented in the NNLM package.

fit2 <- suppressWarnings(nnmf(X,k = 3,init = list(W = fit0$L,H = t(fit0$F)),
                              method = "scd",loss = "mkl",max.iter = 40,
                              trace = 1,rel.tol = 0,inner.max.iter = 1,
                              n.threads = 1))

Load the output of running 40 updates of the CCD algorithm in MATLAB.

fit3 <- readMat("../matlab/ccd100x200.mat")
fit3$obj <- drop(fit3$obj)

The CCD and SCD parameter estimates are nearly the same:

print(range(fit2$W - fit3$W))
print(range(fit2$H - fit3$H))
# [1] -1.116106e-09  1.565456e-09
# [1] -9.941866e-10  1.446030e-09

Finally, I compare these results against SCD with extrapolation implemented in the fastTopics package.

fit4 <- fit_poisson_nmf(X,fit0 = fit0,numiter = 40,method = "scd",
                        control = list(extrapolate = TRUE,numiter = 1))
# Using 56 RcppParallel threads.
# Fitting rank-3 Poisson NMF to 100 x 200 dense matrix.
# Running 40 SCD updates, with extrapolation (fastTopics 0.5-24).

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] fastTopics_0.5-24 NNLM_0.4.4        R.matlab_3.6.2   
# 
# loaded via a namespace (and not attached):
#  [1] ggrepel_0.9.1      Rcpp_1.0.4.6       invgamma_1.1      
#  [4] lattice_0.20-38    tidyr_0.8.3        prettyunits_1.0.2 
#  [7] assertthat_0.2.0   rprojroot_1.3-2    digest_0.6.18     
# [10] utf8_1.1.4         truncnorm_1.0-8    R6_2.3.0          
# [13] backports_1.1.2    MatrixModels_0.4-1 evaluate_0.12     
# [16] coda_0.19-2        httr_1.4.2         ggplot2_3.3.3     
# [19] pillar_1.5.0       progress_1.2.0     rlang_0.4.10      
# [22] lazyeval_0.2.1     data.table_1.12.0  irlba_2.3.3       
# [25] SparseM_1.77       whisker_0.3-2      R.utils_2.7.0     
# [28] R.oo_1.22.0        Matrix_1.2-15      rmarkdown_1.10    
# [31] Rtsne_0.15         stringr_1.3.1      htmlwidgets_1.5.3 
# [34] munsell_0.5.0      mixsqp_0.3-46      compiler_3.5.1    
# [37] httpuv_1.4.5       pkgconfig_2.0.2    SQUAREM_2017.10-1 
# [40] mcmc_0.9-7         htmltools_0.3.6    tidyselect_1.1.0  
# [43] tibble_3.1.0       workflowr_1.6.2    quadprog_1.5-5    
# [46] viridisLite_0.3.0  fansi_0.4.0        crayon_1.3.4      
# [49] dplyr_1.0.5        later_0.7.5        MASS_7.3-51.1     
# [52] R.methodsS3_1.7.1  grid_3.5.1         jsonlite_1.6      
# [55] gtable_0.2.0       lifecycle_1.0.0    DBI_1.0.0         
# [58] git2r_0.26.1       magrittr_1.5       scales_1.0.0      
# [61] RcppParallel_5.0.1 stringi_1.2.4      fs_1.3.1          
# [64] promises_1.0.1     ellipsis_0.2.0.1   vctrs_0.3.6       
# [67] generics_0.0.2     cowplot_1.1.1      tools_3.5.1       
# [70] glue_1.4.2         purrr_0.3.2        hms_0.4.2         
# [73] yaml_2.2.0         colorspace_1.3-2   ashr_2.2-51       
# [76] plotly_4.9.3       knitr_1.20         quantreg_5.36     
# [79] MCMCpack_1.4-4