Last updated: 2022-12-07

Checks: 7 0

Knit directory: gsmash/

This reproducible R Markdown analysis was created with workflowr (version 1.7.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(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.

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 3a2ef34. 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/
    Ignored:    analysis/figure/
    Ignored:    data/poisson_mean_simulation/

Untracked files:
    Untracked:  Rplot.png
    Untracked:  data/real_data_singlecell/
    Untracked:  figure/
    Untracked:  output/poisson_MF_simulation/
    Untracked:  output/poisson_mean_simulation/
    Untracked:  output/poisson_smooth_simulation/

Unstaged changes:
    Modified:   analysis/run_PMF_on_pbmc.Rmd
    Modified:   code/poisson_STM/real_PMF.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/run_PMF_on_droplet.Rmd) and HTML (docs/run_PMF_on_droplet.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 3a2ef34 DongyueXie 2022-12-07 wflow_publish("analysis/run_PMF_on_droplet.Rmd")

Introduction

The droplet dataset is from Peter and stored on RCC. I ran splitting PMF on the dataset.

The dataset initially has 7193 cells and 18388 genes. I tried to run PMF on the dataset with 32GB memory but got an error saying out of memory. I don’t know why but likely due to the vga step that I’m using a vector of size 7193*18388?

So I filtered out genes that has no expressio in more than \(3%\) of the total cells. The resulting dataset has 7193 cells and 8701 genes. I set the scaling factors as \(s_{ij} = \frac{y_{i+}y_{+j}}{y_{++}}\). For comparison, I also fit flash on transformed count data, as \(\tilde{y}_{ij} = \log(1+\frac{y_{ij}}{s_{ij}}\frac{a_j}{0.5})\) where \(a_j = median(s_{\cdot j})\). This transformation is derived from \(\tilde{y}_{ij} = \log(\frac{y_{ij}}{s_{ij}}+\frac{0.5}{a_j})\).

fit = readRDS('output/poisson_MF_simulation/droplet.rds')
fit_flashier = readRDS('output/poisson_MF_simulation/fit_flashier_droplet_filter_gene.rds')
fit$run_time
Time difference of 3.446107 hours
length(fit$eblo_trace)
[1] 91
fit$fit_flash$n.factors
[1] 26
plot(fit$K_trace)

plot(fit$sigma2,ylab = 'sigma2',xlab='gene',col='grey50')

fit$fit_flash$pve
 [1] 0.1568789125 0.0341639389 0.1349336658 0.0267323517 0.0215516881
 [6] 0.0088459773 0.0096850569 0.0043514745 0.0183677735 0.0032679003
[11] 0.0061264726 0.0020586084 0.0012677020 0.0019521592 0.0017855445
[16] 0.0013343647 0.0007932285 0.0004428087 0.0012478659 0.0005800477
[21] 0.0008824267 0.0114974202 0.0006673994 0.0007898059 0.0037400368
[26] 0.0003999684
library(Matrix)
load('data/real_data_singlecell/droplet.RData')
genes = (colSums(counts>0) > (dim(counts)[1]*0.03))
counts = counts[,genes]

Use Jason’s method for visualizing loadings:

source('code/poisson_STM/plot_factors.R')
cell_names = as.character(samples$tissue)
plot.factors(fit$fit_flash,cell_names,title='splitting PMF')

plot.factors(fit_flashier,cell_names,title='flashier')


sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

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

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

other attached packages:
[1] ggplot2_3.3.6   Matrix_1.5-1    workflowr_1.7.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9        horseshoe_0.2.0   invgamma_1.1      lattice_0.20-45  
 [5] getPass_0.2-2     ps_1.7.1          assertthat_0.2.1  rprojroot_2.0.3  
 [9] digest_0.6.29     utf8_1.2.2        truncnorm_1.0-8   plyr_1.8.7       
[13] R6_2.5.1          evaluate_0.17     highr_0.9         httr_1.4.4       
[17] pillar_1.8.1      rlang_1.0.6       rstudioapi_0.14   ebnm_1.0-9       
[21] irlba_2.3.5.1     whisker_0.4       callr_3.7.2       jquerylib_0.1.4  
[25] rmarkdown_2.17    labeling_0.4.2    splines_4.2.1     stringr_1.4.1    
[29] munsell_0.5.0     mixsqp_0.3-48     compiler_4.2.1    httpuv_1.6.6     
[33] xfun_0.33         pkgconfig_2.0.3   SQUAREM_2021.1    htmltools_0.5.3  
[37] tidyselect_1.2.0  tibble_3.1.8      fansi_1.0.3       withr_2.5.0      
[41] dplyr_1.0.10      later_1.3.0       grid_4.2.1        jsonlite_1.8.2   
[45] gtable_0.3.1      lifecycle_1.0.3   DBI_1.1.3         git2r_0.30.1     
[49] magrittr_2.0.3    scales_1.2.1      cli_3.4.1         stringi_1.7.8    
[53] cachem_1.0.6      farver_2.1.1      reshape2_1.4.4    fs_1.5.2         
[57] promises_1.2.0.1  flashier_0.2.34   bslib_0.4.0       generics_0.1.3   
[61] vctrs_0.4.2       trust_0.1-8       tools_4.2.1       softImpute_1.4-1 
[65] glue_1.6.2        parallel_4.2.1    processx_3.7.0    fastmap_1.1.0    
[69] yaml_2.3.5        colorspace_2.0-3  ashr_2.2-54       deconvolveR_1.2-1
[73] knitr_1.40        sass_0.4.2