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/03C_Ding-Cortex.Rmd) and HTML (docs/03C_Ding-Cortex.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
html d736ec8 Saket Choudhary 2021-07-07 Build site.
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)

suppressPackageStartupMessages({
  library(Seurat)
  library(ggplot2)
  library(patchwork)
  library(stringr)
  library(httr)
  library(XML)
})
set.seed(42)
theme_set(theme_classic())

FetchGEOFiles <- function(geo, download.dir = getwd(), download.files = FALSE, ...) {
  geo <- trimws(toupper(geo))
  geo_type <- substr(geo, 1, 3)
  url.prefix <- "https://ftp.ncbi.nlm.nih.gov/geo/"
  if (geo_type == "GSE") {
    url.prefix <- paste0(url.prefix, "series/")
  } else if (geo_type == "GSM") {
    url.prefix <- paste0(url.prefix, "samples/")
  } else if (geotype == "GPL") {
    url.prefix <- paste0(url.prefix, "platform/")
  }
  geo_prefix <- paste0(substr(x = geo, start = 1, stop = nchar(geo) - 3), "nnn")
  url <- paste0(url.prefix, geo_prefix, "/", geo, "/", "suppl", "/")
  response <- GET(url = url)
  html_parsed <- htmlParse(file = response)
  links <- xpathSApply(doc = html_parsed, path = "//a/@href")
  suppl_files <- as.character(grep(pattern = "^G", x = links, value = TRUE))
  if (length(suppl_files) == 0) {
    return(NULL)
  }
  file.url <- paste0(url, suppl_files)
  file_list <- data.frame(filename = suppl_files, url = file.url)
  if (download.files) {
    names(file.url) <- suppl_files
    download_file <- function(url, filename, ...) {
      message(paste0("Downloading ", filename, " to ", download.dir))
      download.file(url = url, destfile = file.path(download.dir, filename), mode = "wb", ...)
      message("Done!")
    }
    lapply(seq_along(file.url), function(y, n, i) {
      download_file(y[[i]], n[[i]], ...)
    },
    y = file.url, n = names(file.url)
    )
  }
  return(file_list)
}
download_dir <- here::here("data/raw_data/Ding")
dir.create(download_dir, showWarnings = F, recursive = T)
dir.create(here::here("data/rds_raw"), showWarnings = F, recursive = T)

geo_files <- FetchGEOFiles("GSE132044", download_dir, download.files = T)
geo_files
                                          filename
1            GSE132044_HEK293_PBMC_TPM_bulk.tsv.gz
2          GSE132044_NIH3T3_cortex_TPM_bulk.tsv.gz
3                GSE132044_cortex_mm10_cell.tsv.gz
4        GSE132044_cortex_mm10_count_matrix.mtx.gz
5                GSE132044_cortex_mm10_gene.tsv.gz
6          GSE132044_mixture_hg19_mm10_cell.tsv.gz
7  GSE132044_mixture_hg19_mm10_count_matrix.mtx.gz
8          GSE132044_mixture_hg19_mm10_gene.tsv.gz
9                  GSE132044_pbmc_hg38_cell.tsv.gz
10         GSE132044_pbmc_hg38_count_matrix.mtx.gz
11                 GSE132044_pbmc_hg38_gene.tsv.gz
                                                                                                                 url
1            https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_HEK293_PBMC_TPM_bulk.tsv.gz
2          https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_NIH3T3_cortex_TPM_bulk.tsv.gz
3                https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_cortex_mm10_cell.tsv.gz
4        https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_cortex_mm10_count_matrix.mtx.gz
5                https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_cortex_mm10_gene.tsv.gz
6          https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_mixture_hg19_mm10_cell.tsv.gz
7  https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_mixture_hg19_mm10_count_matrix.mtx.gz
8          https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_mixture_hg19_mm10_gene.tsv.gz
9                  https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_pbmc_hg38_cell.tsv.gz
10         https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_pbmc_hg38_count_matrix.mtx.gz
11                 https://ftp.ncbi.nlm.nih.gov/geo/series/GSE132nnn/GSE132044/suppl/GSE132044_pbmc_hg38_gene.tsv.gz

Cortex

cortex <- ReadMtx(
  mtx = "~/github/scRNA_NB_comparison/data/raw_data/Ding/GSE132044_cortex_mm10_count_matrix.mtx.gz",
  cells = "~/github/scRNA_NB_comparison/data/raw_data/Ding/GSE132044_cortex_mm10_cell.tsv.gz",
  features = "~/github/scRNA_NB_comparison/data/raw_data/Ding/GSE132044_cortex_mm10_gene.tsv.gz", feature.column = 1
)
cortex[1:5, 1:5]
5 x 5 sparse Matrix of class "dgCMatrix"
                         Cortex1.Smart-seq2.p1_A1 Cortex1.Smart-seq2.p2_A12
ENSMUSG00000000001_Gnai3                        .                         .
ENSMUSG00000000003_Pbsn                         .                         .
ENSMUSG00000000028_Cdc45                        .                         .
ENSMUSG00000000031_H19                          .                         .
ENSMUSG00000000037_Scml2                        .                         .
                         Cortex1.Smart-seq2.p2_A2 Cortex1.Smart-seq2.p2_A4
ENSMUSG00000000001_Gnai3                        .                       80
ENSMUSG00000000003_Pbsn                         .                        .
ENSMUSG00000000028_Cdc45                        .                        .
ENSMUSG00000000031_H19                          .                        .
ENSMUSG00000000037_Scml2                        .                        .
                         Cortex1.Smart-seq2.p2_A5
ENSMUSG00000000001_Gnai3                        .
ENSMUSG00000000003_Pbsn                         .
ENSMUSG00000000028_Cdc45                        .
ENSMUSG00000000031_H19                          .
ENSMUSG00000000037_Scml2                        .
replicate <- str_split_fixed(colnames(cortex), pattern = "\\.", n = 3)[, 1]
technology <- str_split_fixed(colnames(cortex), pattern = "\\.", n = 3)[, 2]
metadata <- data.frame(technology = technology, replicate = replicate)
rownames(metadata) <- colnames(cortex)
head(metadata)
                          technology replicate
Cortex1.Smart-seq2.p1_A1  Smart-seq2   Cortex1
Cortex1.Smart-seq2.p2_A12 Smart-seq2   Cortex1
Cortex1.Smart-seq2.p2_A2  Smart-seq2   Cortex1
Cortex1.Smart-seq2.p2_A4  Smart-seq2   Cortex1
Cortex1.Smart-seq2.p2_A5  Smart-seq2   Cortex1
Cortex1.Smart-seq2.p2_A7  Smart-seq2   Cortex1
genes <- rownames(cortex)
gene_names <- make.unique(str_split_fixed(genes, pattern = "_", n = 2)[, 2])
rownames(cortex) <- gene_names
cortex <- CreateSeuratObject(counts = cortex, project = "Ding_scBenchmark_Cortex", meta.data = metadata, min.cells = 1, min.features = 1)
all_technologies <- sort(unique(metadata$technology))
all_technologies
[1] "10x-Chromium-v2" "DroNc-seq"       "sci-RNA-seq"     "Smart-seq2"     
umi_techs <- c("10x-Chromium-v2", "DroNc-seq", "sci-RNA-seq")
clean_named_techs <- c("ChromiumV2", "DroNc-seq", "sci-RNA-seq")
names(clean_named_techs) <- umi_techs
clean_named_techs
10x-Chromium-v2       DroNc-seq     sci-RNA-seq 
   "ChromiumV2"     "DroNc-seq"   "sci-RNA-seq" 
`%notin%` <- Negate(`%in%`)


split_cortex <- SplitObject(object = cortex, split.by = "technology")
names(split_cortex)
[1] "Smart-seq2"      "10x-Chromium-v2" "DroNc-seq"       "sci-RNA-seq"    
for (technology in names(split_cortex)) {
  if (technology %notin% umi_techs) next
  obj <- split_cortex[[technology]]
  obj_split <- SplitObject(object = obj, split.by = "replicate")

  clean_tech <- clean_named_techs[[technology]]


  for (sampletype in names(obj_split)) {
    seu <- obj_split[[sampletype]]
    seu[["percent.mt"]] <- PercentageFeatureSet(seu, pattern = "^mt-")
    saveRDS(
      seu,
      here::here("data/rds_raw/", paste0("Ding-", sampletype, "__", clean_tech, ".rds"))
    )
  }
}

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] XML_3.99-0.8       httr_1.4.2         stringr_1.4.0      patchwork_1.1.1   
[5] ggplot2_3.3.5      SeuratObject_4.0.4 Seurat_4.0.5       workflowr_1.6.2   

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