Last updated: 2021-12-17

Checks: 7 0

Knit directory: sct2_revision/

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(20210706) 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 8afc486. 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:    data/raw_data/
    Ignored:    data/rds_filtered/
    Ignored:    data/rds_raw/
    Ignored:    data/sampled_counts/
    Ignored:    output/snakemake_output/

Untracked files:
    Untracked:  code/02_run_seurat_noclip.R
    Untracked:  code/07AA_deseq2_muscat_simulate.R
    Untracked:  code/07A_muscat_simulate.R
    Untracked:  code/07A_simulate_muscat.R
    Untracked:  code/07BB_deseq2_muscat_process.R
    Untracked:  code/07B_muscat_process.R
    Untracked:  code/07B_process_muscat.R
    Untracked:  code/08_run_presto.R
    Untracked:  code/17A_HEK_SS3_dropseq.Rmd
    Untracked:  code/17A_HEK_SS3_dropseq_files/
    Untracked:  code/17C_HEK_Quartzeseq2_dropseq.Rmd
    Untracked:  code/17C_HEK_Quartzeseq2_dropseq_files/
    Untracked:  code/17_HEK_SS3_ChromiumV3.Rmd
    Untracked:  code/17_HEK_SS3_ChromiumV3.nb.html
    Untracked:  code/17_HEK_SS3_ChromiumV3_files/
    Untracked:  code/AA_process_muscat.R
    Untracked:  code/BB_process_muscat.R
    Untracked:  code/DD_simulate_muscat.R
    Untracked:  code/EE_simulate_muscat.R
    Untracked:  code/XX_process_muscat.R
    Untracked:  code/XX_simulate_muscat.R
    Untracked:  code/YY_simulate_muscat.R
    Untracked:  code/ZZ_simulate_muscat.R
    Untracked:  code/kang_muscat.R
    Untracked:  code/prep_sce.R
    Untracked:  code/prep_sce_ss3_dropseq.R
    Untracked:  data/azimuth_predictions/
    Untracked:  junk/
    Untracked:  mamba_update_changes.txt
    Untracked:  output/11C_VST/
    Untracked:  output/AAmuscat_simulated/
    Untracked:  output/BBmuscat_simulated/
    Untracked:  output/CCmuscat_simulated/
    Untracked:  output/CD4_NK_downsampling_DE.rds
    Untracked:  output/DDmuscat_simulated/
    Untracked:  output/EEmuscat_simulated/
    Untracked:  output/KANGmuscat_simulated/
    Untracked:  output/NK_downsampling/
    Untracked:  output/XXmuscat_simulated/
    Untracked:  output/YYmuscat_simulated/
    Untracked:  output/ZZmuscat_simulated/
    Untracked:  output/figures/
    Untracked:  output/kang_prepsce.rds
    Untracked:  output/muscat_simulated/
    Untracked:  output/muscat_simulation/
    Untracked:  output/seu_sct2_sim.rds
    Untracked:  output/simulation_HEK_QuartzSeq2_Dropseq_downsampling/
    Untracked:  output/simulation_HEK_SS3_ChromiumV3_downsampling/
    Untracked:  output/simulation_HEK_SS3_Dropseq_downsampling/
    Untracked:  output/simulation_HEK_downsampling/
    Untracked:  output/simulation_NK_downsampling/
    Untracked:  output/ss3_dropseq_prepsim.rds
    Untracked:  output/tables/
    Untracked:  output/vargenes/
    Untracked:  snakemake/.snakemake/
    Untracked:  snakemake/Snakefile_noclip.smk
    Untracked:  snakemake/Snakefile_presto.smk
    Untracked:  snakemake/cluster.yaml
    Untracked:  snakemake/install_glm.R
    Untracked:  snakemake/jobscript.sh
    Untracked:  snakemake/jobscript_ncells.sh
    Untracked:  snakemake/local_run_downsampling.sh
    Untracked:  snakemake/local_run_glm.sh
    Untracked:  snakemake/local_run_ncells.sh
    Untracked:  snakemake/local_run_noclip.sh
    Untracked:  snakemake/local_run_presto.sh
    Untracked:  snakemake/local_run_time.sh
    Untracked:  snakemake/run_glm.sh
    Untracked:  snakemake/run_ncells.sh
    Untracked:  snakemake/sct2_revision_env.yml
    Untracked:  temp_figures/

Unstaged changes:
    Deleted:    analysis/04_PBMC68k.Rmd
    Modified:   code/02_run_seurat.R
    Modified:   code/03_run_vst2_downsample.R
    Modified:   code/04_run_vst_ncells.R
    Modified:   code/06_run_sct.R
    Modified:   data/datasets.csv
    Modified:   snakemake/Snakefile_downsampling.smk
    Modified:   snakemake/Snakefile_glm_seurat.smk
    Modified:   snakemake/Snakefile_metacell.smk

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/11_Figure3.Rmd) and HTML (docs/11_Figure3.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 8afc486 Saket Choudhary 2021-12-17 workflowr::wflow_publish("analysis/*")
html d736ec8 Saket Choudhary 2021-07-07 Build site.
Rmd 052425f Saket Choudhary 2021-07-07 Update template
Rmd 400797a Saket Choudhary 2021-07-06 workflowr::wflow_git_commit(all = TRUE)
html 400797a Saket Choudhary 2021-07-06 workflowr::wflow_git_commit(all = TRUE)

Compare parameters

gene_attr <- list()
root_dir_sct <- here::here("output/snakemake_output/sct_v1_ncells_benchmarks/Fetal__sci-RNA-seq3")
root_dir_sct2 <- here::here("output/snakemake_output/sct_ncells_benchmarks/Fetal__sci-RNA-seq3")


for (ncell in list.dirs(root_dir_sct, full.names = F)) {
  if (ncell == "") {
    next
  }
  fp1 <- here::here(file.path(root_dir_sct, ncell), "gene_attr_sct.csv")
  fp2 <- here::here(file.path(root_dir_sct2, ncell), "gene_attr_sct2.csv")
  if (!file.exists(fp1)) next
  if (!file.exists(fp2)) next
  df1 <- read.csv(fp1)
  if (ncell == "Full") {
    # seu <- readRDS("data/rds/Fetal__sci-RNA-seq3.rds")
    # dim(seu)
    #  63561 377456
    ncell <- 377456
  }
  df1$ncells <- as.numeric(ncell)
  df1$type <- "Regularized parameters (v1)"

  df2 <- read.csv(fp2)
  df2$ncells <- as.numeric(ncell)
  df2$type <- "Regularized parameters (v2)"


  gene_attr[[ncell]] <- rbind(df1, df2)
}

gene_attr_df <- bind_rows(gene_attr)
gene_attr_df$ncells <- factor(gene_attr_df$ncells, levels = sort(unique(gene_attr_df$ncells)), labels = so_formatter(sort(unique(gene_attr_df$ncells))))

plot.theta <- ggplot(gene_attr_df, aes(x = log10(gmean), y = log10(theta), color = ncells)) +
  scale_color_manual(values = brewer.pal(11, "Paired"), name = "") +
  geom_scattermore(pointsize = 1, position = "jitter", alpha = 0.5) +
  facet_wrap(~type, ncol=2) +
  guides(colour = guide_legend(override.aes = list(size = 2))) +
  xlab(expression(paste(log[10], "(Gene mean)"))) +
  ylab(expression(paste(log[10], theta))) +
  theme(legend.position = "right", legend.direction = "vertical", 
        legend.background = element_blank()
) +
  guides(color=guide_legend(ncol=2)) +
  theme(legend.position = c(0.88,0.1)) + theme(legend.key.size = unit(.75, 'lines'))
plot.theta

Version Author Date
400797a Saket Choudhary 2021-07-06

Compare runtimes

times <- list()
root_dir <- here::here("output/snakemake_output/vst2_time_benchmarks/Fetal__sci-RNA-seq3")
for (ncell in list.dirs(root_dir, full.names = F)) {
  if (ncell == "") {
    next
  }
  for (seed in list.dirs(file.path(root_dir, ncell), full.names = F)) {
    if (seed == "") {
      next
    }
    fp <- here::here(file.path(root_dir, ncell, seed), "times.csv")
    if (!file.exists(fp)) next
    df <- read.csv(fp)
    df$ncell <- as.numeric(ncell)
    df$seed <- as.numeric(seed)
    times[[paste0(ncell, seed)]] <- df
  }
}
times <- bind_rows(times)
times_melt <- melt(times, id.vars = c("ncells", "seed"), measure.vars = c("time_sct", "time_sct2"), variable.name = "type", value.name = "time")
times_melt$ncells <- as.numeric(times_melt$ncells)


times_melt <- summarySE(times_melt, measurevar = "time", groupvars = c("ncells", "type"))

times_melt$ncells <- factor(times_melt$ncells, levels = sort(unique(times_melt$ncells)), labels = so_formatter(sort(unique(times_melt$ncells))))

times_melt <- times_melt %>% arrange(ncells)


plot.time <- ggplot(times_melt, aes(ncells, time, color = type, group = type)) +
  geom_errorbar(aes(ymin = time - se, ymax = time + se), width = .1) +
  geom_line() +
  geom_point() +
  geom_line(show.legend = F) +
  scale_color_manual(values = brewer.pal(3, "Dark2"), labels = c("all cells", "n_cells=2,000"), name = "") +
  theme(legend.position = c(0.3, 0.9), legend.background = element_blank()) +
  guides(col = guide_legend(ncol = 1)) +
  xlab("Number of cells") +
  ylab("Time (s)") +
  #scale_y_log10() +
  guides(x = guide_axis(angle = 40)) + theme(legend.key.size = unit(0.75, 'lines'))
plot.time

Version Author Date
400797a Saket Choudhary 2021-07-06

Correlations

gene_attr <- list()
common_genes <- NULL
ncells <- c()
root_dir <- here::here("output/snakemake_output/sct_ncells_benchmarks/Fetal__sci-RNA-seq3/")
for (ncell in list.dirs(root_dir, full.names = F)) {
  if (ncell == "") {
    next
  }
  fp1 <- here::here(file.path(root_dir, ncell), "gene_attr_sct2.csv")
  if (!file.exists(fp1)) next
  df1 <- read.csv(fp1, row.names = 1)
  if (is.null(common_genes)) {
    common_genes <- rownames(df1)
  } else {
    common_genes <- intersect(common_genes, rownames(df1))
  }

  df1 <- df1[common_genes, ]
  df1$ncells <- ncell




  gene_attr[[ncell]] <- df1

  ncell <- as.integer(ncell)
  if (!is.na(ncell)) ncells <- c(ncells, ncell)
}
ncells_level <- sort(ncells)
ncells <- c(sort(ncells), "Full")

mat <- sapply(gene_attr, function(x) x$residual_variance)
colnames(mat) <- names(gene_attr)
mat <- as.data.frame(mat)
rownames(mat) <- common_genes
mat <- mat[order(-mat$Full),]

matc <- mat
colnames(matc) <- paste0("C", colnames(matc))
#matc <- log1p(matc)#[1:3000, ]
plot.resvar <- ggplot(matc, aes_string("CFull", "C2000")) +
  geom_point(alpha=0.5) +#scattermore(pointsize = 3) +
  geom_abline(color = "red", linetype = "dashed") +
  xlab(expression(sigma["all cells"]^2)) +
  ylab(expression(sigma["n_cells=2,000"]^2)) 
plot.resvar

Version Author Date
d736ec8 Saket Choudhary 2021-07-07
400797a Saket Choudhary 2021-07-06
plot.thetax <- plot.theta +
  theme(legend.position = c(0.86,0.28))  
layout <- "
AABC
"

p <- plot.thetax |  plot.resvar | plot.time 
p + plot_layout(design = layout, tag_level = "new") & plot_annotation(tag_levels = "A") & theme(plot.tag = element_text(face = "bold"))

Version Author Date
d736ec8 Saket Choudhary 2021-07-07
400797a Saket Choudhary 2021-07-06
ggsave(here::here("output", "figures", "03_Figure3.pdf"), width = 9, height=3,  dpi = "print")
ggsave(here::here("output", "figures", "03_Figure3.png"),)
sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 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=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] plyr_1.8.6         SeuratObject_4.0.4 Seurat_4.0.5       reshape2_1.4.4    
 [5] RColorBrewer_1.1-2 purrr_0.3.4        patchwork_1.1.1    here_1.0.1        
 [9] scattermore_0.7    ggpubr_0.4.0       ggridges_0.5.3     ggplot2_3.3.5     
[13] forcats_0.5.1      dplyr_1.0.7        workflowr_1.6.2   

loaded via a namespace (and not attached):
  [1] Rtsne_0.15             colorspace_2.0-2       deldir_1.0-6          
  [4] ggsignif_0.6.3         ellipsis_0.3.2         rprojroot_2.0.2       
  [7] fs_1.5.2               spatstat.data_2.1-0    farver_2.1.0          
 [10] leiden_0.3.9           listenv_0.8.0          ggrepel_0.9.1         
 [13] fansi_0.5.0            codetools_0.2-18       splines_4.1.2         
 [16] knitr_1.36             polyclip_1.10-0        jsonlite_1.7.2        
 [19] broom_0.7.10           ica_1.0-2              cluster_2.1.2         
 [22] png_0.1-7              uwot_0.1.11            shiny_1.7.1           
 [25] sctransform_0.3.2.9008 spatstat.sparse_2.0-0  compiler_4.1.2        
 [28] httr_1.4.2             backports_1.4.1        assertthat_0.2.1      
 [31] Matrix_1.4-0           fastmap_1.1.0          lazyeval_0.2.2        
 [34] later_1.3.0            htmltools_0.5.2        tools_4.1.2           
 [37] igraph_1.2.9           gtable_0.3.0           glue_1.5.1            
 [40] RANN_2.6.1             Rcpp_1.0.7             carData_3.0-4         
 [43] jquerylib_0.1.4        vctrs_0.3.8            nlme_3.1-152          
 [46] lmtest_0.9-39          xfun_0.28              stringr_1.4.0         
 [49] globals_0.14.0         mime_0.12              miniUI_0.1.1.1        
 [52] lifecycle_1.0.1        irlba_2.3.5            goftest_1.2-3         
 [55] rstatix_0.7.0          future_1.23.0          MASS_7.3-54           
 [58] zoo_1.8-9              scales_1.1.1           spatstat.core_2.3-2   
 [61] promises_1.2.0.1       spatstat.utils_2.3-0   parallel_4.1.2        
 [64] yaml_2.2.1             reticulate_1.22        pbapply_1.5-0         
 [67] gridExtra_2.3          sass_0.4.0             rpart_4.1-15          
 [70] stringi_1.7.6          highr_0.9              rlang_0.4.12          
 [73] pkgconfig_2.0.3        matrixStats_0.61.0     evaluate_0.14         
 [76] lattice_0.20-45        ROCR_1.0-11            tensor_1.5            
 [79] labeling_0.4.2         htmlwidgets_1.5.4      cowplot_1.1.1         
 [82] tidyselect_1.1.1       parallelly_1.29.0      RcppAnnoy_0.0.19      
 [85] magrittr_2.0.1         R6_2.5.1               generics_0.1.1        
 [88] DBI_1.1.1              mgcv_1.8-38            pillar_1.6.4          
 [91] whisker_0.4            withr_2.4.3            fitdistrplus_1.1-6    
 [94] survival_3.2-13        abind_1.4-5            tibble_3.1.6          
 [97] future.apply_1.8.1     crayon_1.4.2           car_3.0-12            
[100] KernSmooth_2.23-20     utf8_1.2.2             spatstat.geom_2.3-1   
[103] plotly_4.10.0          rmarkdown_2.11         grid_4.1.2            
[106] data.table_1.14.2      git2r_0.29.0           digest_0.6.29         
[109] xtable_1.8-4           tidyr_1.1.4            httpuv_1.6.3          
[112] munsell_0.5.0          viridisLite_0.4.0      bslib_0.3.1           

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 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=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] plyr_1.8.6         SeuratObject_4.0.4 Seurat_4.0.5       reshape2_1.4.4    
 [5] RColorBrewer_1.1-2 purrr_0.3.4        patchwork_1.1.1    here_1.0.1        
 [9] scattermore_0.7    ggpubr_0.4.0       ggridges_0.5.3     ggplot2_3.3.5     
[13] forcats_0.5.1      dplyr_1.0.7        workflowr_1.6.2   

loaded via a namespace (and not attached):
  [1] Rtsne_0.15             colorspace_2.0-2       deldir_1.0-6          
  [4] ggsignif_0.6.3         ellipsis_0.3.2         rprojroot_2.0.2       
  [7] fs_1.5.2               spatstat.data_2.1-0    farver_2.1.0          
 [10] leiden_0.3.9           listenv_0.8.0          ggrepel_0.9.1         
 [13] fansi_0.5.0            codetools_0.2-18       splines_4.1.2         
 [16] knitr_1.36             polyclip_1.10-0        jsonlite_1.7.2        
 [19] broom_0.7.10           ica_1.0-2              cluster_2.1.2         
 [22] png_0.1-7              uwot_0.1.11            shiny_1.7.1           
 [25] sctransform_0.3.2.9008 spatstat.sparse_2.0-0  compiler_4.1.2        
 [28] httr_1.4.2             backports_1.4.1        assertthat_0.2.1      
 [31] Matrix_1.4-0           fastmap_1.1.0          lazyeval_0.2.2        
 [34] later_1.3.0            htmltools_0.5.2        tools_4.1.2           
 [37] igraph_1.2.9           gtable_0.3.0           glue_1.5.1            
 [40] RANN_2.6.1             Rcpp_1.0.7             carData_3.0-4         
 [43] jquerylib_0.1.4        vctrs_0.3.8            nlme_3.1-152          
 [46] lmtest_0.9-39          xfun_0.28              stringr_1.4.0         
 [49] globals_0.14.0         mime_0.12              miniUI_0.1.1.1        
 [52] lifecycle_1.0.1        irlba_2.3.5            goftest_1.2-3         
 [55] rstatix_0.7.0          future_1.23.0          MASS_7.3-54           
 [58] zoo_1.8-9              scales_1.1.1           spatstat.core_2.3-2   
 [61] promises_1.2.0.1       spatstat.utils_2.3-0   parallel_4.1.2        
 [64] yaml_2.2.1             reticulate_1.22        pbapply_1.5-0         
 [67] gridExtra_2.3          sass_0.4.0             rpart_4.1-15          
 [70] stringi_1.7.6          highr_0.9              rlang_0.4.12          
 [73] pkgconfig_2.0.3        matrixStats_0.61.0     evaluate_0.14         
 [76] lattice_0.20-45        ROCR_1.0-11            tensor_1.5            
 [79] labeling_0.4.2         htmlwidgets_1.5.4      cowplot_1.1.1         
 [82] tidyselect_1.1.1       parallelly_1.29.0      RcppAnnoy_0.0.19      
 [85] magrittr_2.0.1         R6_2.5.1               generics_0.1.1        
 [88] DBI_1.1.1              mgcv_1.8-38            pillar_1.6.4          
 [91] whisker_0.4            withr_2.4.3            fitdistrplus_1.1-6    
 [94] survival_3.2-13        abind_1.4-5            tibble_3.1.6          
 [97] future.apply_1.8.1     crayon_1.4.2           car_3.0-12            
[100] KernSmooth_2.23-20     utf8_1.2.2             spatstat.geom_2.3-1   
[103] plotly_4.10.0          rmarkdown_2.11         grid_4.1.2            
[106] data.table_1.14.2      git2r_0.29.0           digest_0.6.29         
[109] xtable_1.8-4           tidyr_1.1.4            httpuv_1.6.3          
[112] munsell_0.5.0          viridisLite_0.4.0      bslib_0.3.1