Last updated: 2023-03-05

Checks: 6 1

Knit directory: gsmash/

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(20220606) 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
~/Rpackages/gsmash/code/poisson_STM/structure_plot.R code/poisson_STM/structure_plot.R
~/Rpackages/gsmash/code/poisson_STM/plot_factors_general.R code/poisson_STM/plot_factors_general.R

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 40ac907. 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:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  analysis/compare_vga_iterations_pbmc_full.Rmd
    Untracked:  analysis/droplet_results_full.Rmd
    Untracked:  analysis/pbmc3k_10X_othermethods.Rmd
    Untracked:  code/ebpmf_simulation/add.R
    Untracked:  code/mutation/
    Untracked:  code/poisson_STM/for_probgen.R
    Untracked:  output/pbmc3k_k1.rds
    Untracked:  output/pbmc3k_k1_S1.rds

Unstaged changes:
    Modified:   analysis/overdispersed_splitting.Rmd
    Modified:   code/ebpmf_simulation/simu_func.R
    Modified:   code/poisson_STM/structure_plot.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 repository in which changes were made to the R Markdown (analysis/pbmc_infasttopics_othermethods.Rmd) and HTML (docs/pbmc_infasttopics_othermethods.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 40ac907 DongyueXie 2023-03-05 wflow_publish("analysis/pbmc_infasttopics_othermethods.Rmd")
html 1c5241e DongyueXie 2023-02-23 Build site.
Rmd fb561bd DongyueXie 2023-02-23 wflow_publish("analysis/pbmc_infasttopics_othermethods.Rmd")

I take the pbmc dataset from fasttopics package, and fit flash, glmpca, as well as topic model on the dataset.

library(fastTopics)
library(flashier)
Loading required package: magrittr
library(glmpca)
library(Matrix)
data("pbmc_facs")
counts = pbmc_facs$counts
counts = counts[,colSums(counts!=0)>10]
source("~/Rpackages/gsmash/code/poisson_STM/structure_plot.R")
source("~/Rpackages/gsmash/code/poisson_STM/plot_factors_general.R")

GLMPCA Poisson

I set K = 10

glmpca_fit_poi = readRDS('/project2/mstephens/dongyue/poisson_mf/pbmc_fasttopics/othermethods/glmpca_poi.rds')
plot.factors.general(glmpca_fit_poi$factors,cell.types = pbmc_facs$samples$subpop,title = 'glmpca poisson')

Version Author Date
1c5241e DongyueXie 2023-02-23
plot.factors.general(glmpca_fit_poi$factors,cell.types = pbmc_facs$samples$celltype,title = 'glmpca poisson')

Version Author Date
1c5241e DongyueXie 2023-02-23

GLMPCA NB

I set K = 10

glmpca_fit_poi = readRDS('/project2/mstephens/dongyue/poisson_mf/pbmc_fasttopics/othermethods/glmpca_nb.rds')
plot.factors.general(glmpca_fit_poi$factors,cell.types = pbmc_facs$samples$subpop,title = 'glmpca NB')

Version Author Date
1c5241e DongyueXie 2023-02-23
plot.factors.general(glmpca_fit_poi$factors,cell.types = pbmc_facs$samples$celltype,title = 'glmpca NB')

Version Author Date
1c5241e DongyueXie 2023-02-23

flash sparse

flash_sparse = readRDS('/project2/mstephens/dongyue/poisson_mf/pbmc_fasttopics/othermethods/flash_sparse.rds')
K_plot = 10
kset = order(flash_sparse$pve,decreasing = T)[1:K_plot]
plot.factors.general(flash_sparse$L.pm[,kset],cell.types = pbmc_facs$samples$subpop,title = 'flash sparse')

Version Author Date
1c5241e DongyueXie 2023-02-23
plot.factors.general(flash_sparse$L.pm[,kset],cell.types = pbmc_facs$samples$celltype,title = 'flash sparse')

Version Author Date
1c5241e DongyueXie 2023-02-23

flash nonneg Loadings

flash_nonnegL = readRDS('/project2/mstephens/dongyue/poisson_mf/pbmc_fasttopics/othermethods/flash_nonnegL.rds')
plot.factors.general(flash_nonnegL$L.pm,cell.types = pbmc_facs$samples$subpop,title = 'flash nonnegL',nonnegative = T)

Version Author Date
1c5241e DongyueXie 2023-02-23
plot.factors.general(flash_nonnegL$L.pm,cell.types = pbmc_facs$samples$celltype,title = 'flash nonnegL',nonnegative = T)

Version Author Date
1c5241e DongyueXie 2023-02-23
library(randomcoloR)
n <- 20
set.seed(12345)
palette <- distinctColorPalette(n)
#kset = order(flash_nonnegL$pve,decreasing = T)[1:K_plot]
structure_plot_general(flash_nonnegL$L.pm,
                       flash_nonnegL$F.pm,
                       grouping = pbmc_facs$samples$subpop, 
                       title='flash nonnegL',
                       colors = palette,
                       remove_l0f0 = FALSE,
                       print_plot = F,
                       LD=T)
Running tsne on 417 x 20 matrix.
Running tsne on 91 x 20 matrix.
Running tsne on 358 x 20 matrix.
Running tsne on 359 x 20 matrix.
Running tsne on 775 x 20 matrix.

Version Author Date
1c5241e DongyueXie 2023-02-23
# structure_plot_general(flash_nonnegL$L.pm,flash_nonnegL$F.pm,grouping = pbmc_facs$samples$celltype,
#                        title='flash nonnegL',remove_l0f0 = FALSE,LD=T)
kset = order(flash_nonnegL$pve,decreasing = T)[1:20]
structure_plot_general(flash_nonnegL$L.pm[,kset[-c(1,2)]],
                       flash_nonnegL$F.pm[,kset[-c(1,2)]],
                       grouping = pbmc_facs$samples$subpop,
                       title='flash nonnegL',
                       colors = palette,
                       remove_l0f0 = FALSE,
                       print_plot = F,
                       LD=T)
Running tsne on 417 x 18 matrix.
Running tsne on 91 x 18 matrix.
Running tsne on 358 x 18 matrix.
Running tsne on 359 x 18 matrix.
Running tsne on 775 x 18 matrix.

structure_plot_general(flash_nonnegL$L.pm[,kset[-c(1,2,3)]],
                       flash_nonnegL$F.pm[,kset[-c(1,2,3)]],
                       grouping = pbmc_facs$samples$subpop,
                       title='flash nonnegL',
                       colors = palette,
                       remove_l0f0 = FALSE,
                       LD=T,print_plot = F
                      )
Running tsne on 417 x 17 matrix.
Running tsne on 91 x 17 matrix.
Running tsne on 358 x 17 matrix.
Running tsne on 359 x 17 matrix.
Running tsne on 775 x 17 matrix.

Version Author Date
1c5241e DongyueXie 2023-02-23

flash nonneg Loadings and factors

flash_nonnegLF = readRDS('/project2/mstephens/dongyue/poisson_mf/pbmc_fasttopics/othermethods/flash_nonnegLF.rds')
plot.factors.general(flash_nonnegLF$L.pm,cell.types = pbmc_facs$samples$subpop,title = 'flash nonnegLF',nonnegative = T)

plot.factors.general(flash_nonnegLF$L.pm,cell.types = pbmc_facs$samples$celltype,title = 'flash nonnegLF',nonnegative = T)

structure_plot_general(flash_nonnegLF$L.pm,
                       flash_nonnegLF$F.pm,
                       grouping = pbmc_facs$samples$subpop,
                       title='flash nonnegLF',
                       colors = palette,
                       print_plot = F,
                       remove_l0f0 = FALSE,LD=T)
Running tsne on 417 x 20 matrix.
Running tsne on 91 x 20 matrix.
Running tsne on 358 x 20 matrix.
Running tsne on 359 x 20 matrix.
Running tsne on 775 x 20 matrix.

Version Author Date
1c5241e DongyueXie 2023-02-23
kset = order(flash_nonnegLF$pve,decreasing = T)[1:20]
structure_plot_general(flash_nonnegLF$L.pm[,kset[-1]],
                       flash_nonnegLF$F.pm[,kset[-1]],
                       grouping = pbmc_facs$samples$subpop,
                       title='flash nonnegLF',
                       colors = palette,
                       print_plot = F,
                       remove_l0f0 = FALSE,LD=T)
Running tsne on 417 x 19 matrix.
Running tsne on 91 x 19 matrix.
Running tsne on 358 x 19 matrix.
Running tsne on 359 x 19 matrix.
Running tsne on 775 x 19 matrix.

Version Author Date
1c5241e DongyueXie 2023-02-23
structure_plot_general(flash_nonnegLF$L.pm[,kset[-1]],
                       flash_nonnegLF$F.pm[,kset[-1]],
                       grouping = pbmc_facs$samples$celltype,
                       title='flash nonnegLF',
                       remove_l0f0 = FALSE,
                       print_plot = F,
                       colors = palette,
                       LD=T)
Running tsne on 417 x 19 matrix.
Running tsne on 91 x 19 matrix.
Running tsne on 358 x 19 matrix.
Running tsne on 134 x 19 matrix.
Running tsne on 359 x 19 matrix.
Running tsne on 196 x 19 matrix.
Running tsne on 117 x 19 matrix.
Running tsne on 124 x 19 matrix.
Running tsne on 91 x 19 matrix.
Running tsne on 113 x 19 matrix.

Topic model

tm = readRDS('/project2/mstephens/dongyue/poisson_mf/pbmc_fasttopics/othermethods/fasttopics_fit.rds')
tm = poisson2multinom(tm)
plot.factors.general(tm$L,cell.types = pbmc_facs$samples$subpop,title = 'topic model',nonnegative = T)

plot.factors.general(tm$L,cell.types = pbmc_facs$samples$celltype,title = 'topic model',nonnegative = T)

structure_plot_general(tm$L,tm$F,grouping = pbmc_facs$samples$subpop,
                       title='topic model',remove_l0f0 = FALSE,LD=F,topic_model = T)
Running tsne on 417 x 10 matrix.
Running tsne on 91 x 10 matrix.
Running tsne on 358 x 10 matrix.
Running tsne on 359 x 10 matrix.
Running tsne on 775 x 10 matrix.

structure_plot_general(tm$L,tm$F,grouping = pbmc_facs$samples$celltype,
                       title='topic model',remove_l0f0 = FALSE,LD=F,topic_model = T)
Running tsne on 417 x 10 matrix.
Running tsne on 91 x 10 matrix.
Running tsne on 358 x 10 matrix.
Running tsne on 134 x 10 matrix.
Running tsne on 359 x 10 matrix.
Running tsne on 196 x 10 matrix.
Running tsne on 117 x 10 matrix.
Running tsne on 124 x 10 matrix.
Running tsne on 91 x 10 matrix.
Running tsne on 113 x 10 matrix.


sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS:   /software/R-4.1.0-no-openblas-el7-x86_64/lib64/R/lib/libRblas.so
LAPACK: /software/R-4.1.0-no-openblas-el7-x86_64/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C           
 [4] LC_COLLATE=C         LC_MONETARY=C        LC_MESSAGES=C       
 [7] LC_PAPER=C           LC_NAME=C            LC_ADDRESS=C        
[10] LC_TELEPHONE=C       LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] randomcoloR_1.1.0.1 gridExtra_2.3       ggplot2_3.4.1      
[4] Matrix_1.5-3        glmpca_0.2.0        flashier_0.2.34    
[7] magrittr_2.0.3      fastTopics_0.6-142  workflowr_1.6.2    

loaded via a namespace (and not attached):
 [1] mcmc_0.9-7         fs_1.5.0           progress_1.2.2     httr_1.4.5        
 [5] rprojroot_2.0.2    tools_4.1.0        bslib_0.2.5.1      utf8_1.2.3        
 [9] R6_2.5.1           irlba_2.3.5.1      uwot_0.1.14        lazyeval_0.2.2    
[13] colorspace_2.1-0   withr_2.5.0        tidyselect_1.2.0   prettyunits_1.1.1 
[17] curl_5.0.0         compiler_4.1.0     git2r_0.28.0       cli_3.6.0         
[21] quantreg_5.94      SparseM_1.81       plotly_4.10.1      labeling_0.4.2    
[25] horseshoe_0.2.0    sass_0.4.0         scales_1.2.1       SQUAREM_2021.1    
[29] quadprog_1.5-8     pbapply_1.7-0      mixsqp_0.3-48      stringr_1.5.0     
[33] digest_0.6.31      rmarkdown_2.9      MCMCpack_1.6-3     deconvolveR_1.2-1 
[37] pkgconfig_2.0.3    htmltools_0.5.4    fastmap_1.1.0      invgamma_1.1      
[41] highr_0.9          htmlwidgets_1.6.1  rlang_1.0.6        rstudioapi_0.13   
[45] farver_2.1.1       jquerylib_0.1.4    generics_0.1.3     jsonlite_1.8.4    
[49] dplyr_1.1.0        Rcpp_1.0.10        munsell_0.5.0      fansi_1.0.4       
[53] lifecycle_1.0.3    stringi_1.6.2      whisker_0.4        yaml_2.3.7        
[57] MASS_7.3-54        plyr_1.8.6         Rtsne_0.16         grid_4.1.0        
[61] parallel_4.1.0     promises_1.2.0.1   ggrepel_0.9.3      crayon_1.5.2      
[65] lattice_0.20-44    cowplot_1.1.1      splines_4.1.0      hms_1.1.2         
[69] knitr_1.33         pillar_1.8.1       softImpute_1.4-1   reshape2_1.4.4    
[73] glue_1.6.2         evaluate_0.14      trust_0.1-8        V8_4.2.2          
[77] data.table_1.14.8  RcppParallel_5.1.7 vctrs_0.5.2        httpuv_1.6.1      
[81] MatrixModels_0.5-1 gtable_0.3.1       purrr_1.0.1        ebnm_1.0-11       
[85] tidyr_1.3.0        ashr_2.2-54        xfun_0.24          coda_0.19-4       
[89] later_1.3.0        survival_3.2-11    viridisLite_0.4.1  truncnorm_1.0-8   
[93] tibble_3.1.8       cluster_2.1.2      ellipsis_0.3.2