Last updated: 2022-10-18

Checks: 7 0

Knit directory: synovialscrnaseq/

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(20210105) 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 816d5c9. 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:    '/
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    .empty/
    Ignored:    analysis/.Rhistory
    Ignored:    analysis/iSEE_interactive_document.html
    Ignored:    code/test_files/
    Ignored:    data/Culemann/
    Ignored:    data/E-MTAB-8322/
    Ignored:    data/Synovial scRNA-seq samples - Sheet1.csv
    Ignored:    data/Zhang_top20_singlecell_cluster_markers_fromGithub.csv
    Ignored:    data/findMarkers_results.rds
    Ignored:    data/findMarkers_results_v2.rds
    Ignored:    data/info/
    Ignored:    data/syn_sce_tidy_filtered.rds
    Ignored:    data/syn_sce_tidy_hvg.rds
    Ignored:    data/syn_sce_tidy_hvg_cms.rds
    Ignored:    docs/
    Ignored:    output/Figures_Paper/
    Ignored:    output/Sample_summaries_RA_comparisons.rds
    Ignored:    output/Sample_summaries_direct_dissociation.rds
    Ignored:    output/Sample_summaries_exvivo_treatment.rds
    Ignored:    output/Suppl_Figure_4d.rds
    Ignored:    output/barcodes.txt
    Ignored:    output/count_matrix_unfiltered.mtx
    Ignored:    output/emptyDrops_result_v4_tmp.rds
    Ignored:    output/emptyDrops_result_v4tmptmp.rds
    Ignored:    output/entropies_fstat_v5_ec.rds
    Ignored:    output/entropies_fstat_v5_main.rds
    Ignored:    output/entropies_fstat_v5_mp.rds
    Ignored:    output/entropies_fstat_v5_sf.rds
    Ignored:    output/entropies_fstat_v5_tc.rds
    Ignored:    output/findMarkers_results_v5_ec.rds
    Ignored:    output/findMarkers_results_v5_main.rds
    Ignored:    output/findMarkers_results_v5_mp.rds
    Ignored:    output/findMarkers_results_v5_sf.rds
    Ignored:    output/findMarkers_results_v5_tc.rds
    Ignored:    output/findMarkers_results_v6.rds
    Ignored:    output/findMarkers_results_v6_ec.rds
    Ignored:    output/findMarkers_results_v6_main.rds
    Ignored:    output/findMarkers_results_v6_mp.rds
    Ignored:    output/findMarkers_results_v6_sf.rds
    Ignored:    output/findMarkers_results_v6_tc.rds
    Ignored:    output/genes.txt
    Ignored:    output/goana_results_v6_ec.rds
    Ignored:    output/goana_results_v6_mp.rds
    Ignored:    output/syn_v4_swappedDrops_24300_after.rds
    Ignored:    output/syn_v4_swappedDrops_24300_before.rds
    Ignored:    output/syn_v4_swappedDrops_24793_after.rds
    Ignored:    output/syn_v4_swappedDrops_24793_before.rds
    Ignored:    output/syn_v5_annot_df_manual.rds
    Ignored:    output/syn_v5_cluster_cellid_match_invivo.rds
    Ignored:    output/syn_v5_clustering_lookup_invivo.rds
    Ignored:    output/syn_v5_clustering_lookup_multiple_invivo.rds
    Ignored:    output/syn_v5_res_da_Accute_inflammation_invivo.rds
    Ignored:    output/syn_v5_res_da_Diagnosis_invivo.rds
    Ignored:    output/syn_v5_res_da_Diagnosis_main_invivo.rds
    Ignored:    output/syn_v5_res_da_Lymphoid_folicles_invivo.rds
    Ignored:    output/syn_v5_res_da_Pathotype_invivo.rds
    Ignored:    output/syn_v5_res_da_Therapy_invivo.rds
    Ignored:    output/syn_v5_res_da_Vascularisation_bin_invivo.rds
    Ignored:    output/syn_v5_res_ds_Accute_inflammation_invivo.rds
    Ignored:    output/syn_v5_res_ds_Diagnosis_invivo.rds
    Ignored:    output/syn_v5_res_ds_Diagnosis_main_invivo.rds
    Ignored:    output/syn_v5_res_ds_Lymphoid_folicles_invivo.rds
    Ignored:    output/syn_v5_res_ds_Pathotype_invivo.rds
    Ignored:    output/syn_v5_res_ds_Therapy_invivo.rds
    Ignored:    output/syn_v5_res_ds_Vascularisation_bin_invivo.rds
    Ignored:    output/syn_v5_sce.rds
    Ignored:    output/syn_v5_sce_ec_invivo.rds
    Ignored:    output/syn_v5_sce_filtered_invivo.rds
    Ignored:    output/syn_v5_sce_hvg_cms_doublet_annot_manual_invivo.rds
    Ignored:    output/syn_v5_sce_hvg_cms_doublet_cmstest_invivo.rds
    Ignored:    output/syn_v5_sce_hvg_cms_doublet_invivo.rds
    Ignored:    output/syn_v5_sce_hvg_cms_doublet_subcluster_invivo.rds
    Ignored:    output/syn_v5_sce_hvg_invivo.rds
    Ignored:    output/syn_v5_sce_mp_invivo.rds
    Ignored:    output/syn_v5_sce_sf_invivo.rds
    Ignored:    output/syn_v5_sce_tc_invivo.rds
    Ignored:    output/syn_v5_vst_out_invivo.rds
    Ignored:    output/syn_v6_cluster_cellid_match_invivo.rds
    Ignored:    output/syn_v6_clustering_lookup_invivo.rds
    Ignored:    output/syn_v6_clustering_lookup_multiple_invivo.rds
    Ignored:    output/syn_v6_sce.rds
    Ignored:    output/syn_v6_sce_Figure8.rds
    Ignored:    output/syn_v6_sce_Figure8_dic_ls.rds
    Ignored:    output/syn_v6_sce_ec_invivo.rds
    Ignored:    output/syn_v6_sce_filtered_invivo.rds
    Ignored:    output/syn_v6_sce_hdf5/
    Ignored:    output/syn_v6_sce_hvg_cms_doublet_invivo.rds
    Ignored:    output/syn_v6_sce_hvg_cms_doublet_subcluster_invivo.rds
    Ignored:    output/syn_v6_sce_hvg_invivo.rds
    Ignored:    output/syn_v6_sce_hvg_marker_genes.rds
    Ignored:    output/syn_v6_sce_mp_invivo.rds
    Ignored:    output/syn_v6_sce_sf_invivo.rds
    Ignored:    output/syn_v6_sce_tc_invivo.rds
    Ignored:    output/syn_v6_sfig1.rds
    Ignored:    output/syn_v6_vst_out_invivo.rds

Untracked files:
    Untracked:  analysis/22
    Untracked:  analysis/scRNAseq_complete_01_preprocessing_comparison.Rmd
    Untracked:  analysis/test.Rmd
    Untracked:  code/rebuild_ezRun.R
    Untracked:  nonhosted_public/
    Untracked:  singRstudio.sh.bak

Unstaged changes:
    Modified:   analysis/scRNAseq_complete_00_ambient_RNA.Rmd
    Modified:   analysis/scRNAseq_complete_Figures.Rmd
    Modified:   analysis/write_tsv.Rmd

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/scRNAseq_complete_00-1_swappedDrops.Rmd) and HTML (public/scRNAseq_complete_00-1_swappedDrops.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 3443cc6 Reto Gerber 2022-04-25 Update
html f2e34e1 Reto Gerber 2021-07-29 Update navbar
html 222b0d1 Reto Gerber 2021-07-29 Update analysis to v5
Rmd e88c23e Reto Gerber 2021-07-12 add ambient RNA analysis
html e88c23e Reto Gerber 2021-07-12 add ambient RNA analysis
Rmd 3072789 Reto Gerber 2021-06-09 Update annotation scripts
html 3072789 Reto Gerber 2021-06-09 Update annotation scripts

Set up

suppressPackageStartupMessages({
  library(dplyr)
  library(ggplot2)
  library(purrr)
  library(stringr)
  library(scater)
  library(scran)
  library(scuttle)
  library(tidySingleCellExperiment)
  library(DropletUtils)
})
n_workers <- 20
RhpcBLASctl::blas_set_num_threads(n_workers)
# bp_param <- BiocParallel::MulticoreParam(workers=20)

here::here()
[1] "/home/retger/Synovial/synovialscrnaseq"
raw_data_dir <- here::here("..","data_server")
raw_data_dir_blaz <- here::here("..","data_blaz")
remove_low_quality_samples <- TRUE

set.seed(100)

metadata_df <- readRDS(here::here("output","Sample_summaries_direct_dissociation.rds"))

swappedDrops

24300

order_id <- "24300"
# for order 24300
samples <- here::here(raw_data_dir,list.files(raw_data_dir),"molecule_info.h5")
names(samples) <- purrr::map_chr(strsplit(samples, "/") , ~ .x[length(.x)-1])
samples <- samples[names(samples) %in% metadata_df$`FGCZ_Sample Name`[metadata_df$Order_FGCZ == order_id]]

samples_blaz_names <- c("o24300_1_08-akg1_BB","o24300_1_09-control2_MFB","o24300_1_10-akg2_MFB","o24300_1_13-control1_BB")
samples_blaz <- here::here(raw_data_dir_blaz, samples_blaz_names,"molecule_info.h5")
names(samples_blaz) <- samples_blaz_names

samples <- c(samples, samples_blaz)
# subset for testing
# samples <- samples[c(3,10)]
before.stats <- BiocParallel::bplapply(BPPARAM = BiocParallel::MulticoreParam(workers=n_workers, RNGseed = 123),
                                       samples, get10xMolInfoStats)
saveRDS(before.stats, here::here("output",paste0("syn_v4_swappedDrops_",order_id,"_before.rds")))

max.umi <- vapply(before.stats, function(x) max(x$num.umis), 0)
ylim <- c(1, max(max.umi))
max.ncells <- vapply(before.stats, nrow, 0L)
xlim <- c(1, max(max.ncells))

plot(0,0,type="n", xlab="Rank", ylab="Number of UMIs", 
    log="xy", xlim=xlim, ylim=ylim)
Warning in xy.coords(x, y, xlabel, ylabel, log): 1 x value <= 0 omitted from
logarithmic plot
Warning in xy.coords(x, y, xlabel, ylabel, log): 1 y value <= 0 omitted from
logarithmic plot
for (i in seq_along(before.stats)) {
    u <- sort(before.stats[[i]]$num.umis, decreasing=TRUE)
    lines(seq_along(u), u, col=i, lwd=5)
}
legend("topright", col=seq_along(before.stats), 
    lwd=5, legend=stringr::str_split(names(before.stats),"-",simplify = TRUE)[,2])

Version Author Date
3072789 Reto Gerber 2021-06-09
after.mat <- swappedDrops(samples,get.swapped=TRUE,get.diagnostics=TRUE)
saveRDS(after.mat, here::here("output",paste0("syn_v4_swappedDrops_",order_id,"_after.rds")))
cleaned.sum <- vapply(after.mat$cleaned, sum, 0)
swapped.sum <- vapply(after.mat$swapped, sum, 0)
swapped.sum / (swapped.sum + cleaned.sum)
          o24300_1_01-79           o24300_1_02-86           o24300_1_03-83 
              0.02998419               0.02336929               0.03091428 
          o24300_1_04-84           o24300_1_05-78           o24300_1_06-81 
              0.03072419               0.08318399               0.03363505 
          o24300_1_07-87           o24300_1_11-80           o24300_1_12-89 
              0.05538205               0.04705487               0.07608163 
     o24300_1_08-akg1_BB o24300_1_09-control2_MFB     o24300_1_10-akg2_MFB 
              0.03899989               0.03400100               0.03435084 
 o24300_1_13-control1_BB 
              0.09283039 
plot(0,0,type="n", xlab="Rank", ylab="Number of UMIs", 
    log="xy", xlim=xlim, ylim=ylim)
Warning in xy.coords(x, y, xlabel, ylabel, log): 1 x value <= 0 omitted from
logarithmic plot

Warning in xy.coords(x, y, xlabel, ylabel, log): 1 y value <= 0 omitted from
logarithmic plot
for (i in seq_along(after.mat$cleaned)) {
    cur.stats <- barcodeRanks(after.mat$cleaned[[i]])
    u <- sort(cur.stats$total, decreasing=TRUE)
    lines(seq_along(u), u, col=i, lwd=5)
}
Warning in smooth.spline(x[new.keep], y[new.keep], df = df, ...): not using
invalid df; must have 1 < df <= n := #{unique x} = 17
legend("topright", col=seq_along(after.mat$cleaned), 
    lwd=5, legend=stringr::str_split(names(after.mat$cleaned),"-",simplify = TRUE)[,2])

Version Author Date
3072789 Reto Gerber 2021-06-09

24793

order_id <- "24793"
# for order 24793
samples <- here::here(raw_data_dir,list.files(raw_data_dir),"molecule_info.h5")
names(samples) <- purrr::map_chr(strsplit(samples, "/") , ~ .x[length(.x)-1])
samples <- samples[names(samples) %in% metadata_df$`FGCZ_Sample Name`[metadata_df$Order_FGCZ == order_id]]

samples_blaz_names <- c("o24793_1_09-BB_skin_control","o24793_1_10-BB_skin_akg","o24793_1_11-BB","o24793_1_12-BB")
samples_blaz <- here::here(raw_data_dir_blaz, samples_blaz_names,"molecule_info.h5")
names(samples_blaz) <- samples_blaz_names

samples <- c(samples, samples_blaz)
# subset for testing
samples <- samples[c(1:10)]
before.stats <- BiocParallel::bplapply(BPPARAM = BiocParallel::MulticoreParam(workers=n_workers, RNGseed = 123),
                                       samples, get10xMolInfoStats)
saveRDS(before.stats, here::here("output",paste0("syn_v4_swappedDrops_",order_id,"_before.rds")))

max.umi <- vapply(before.stats, function(x) max(x$num.umis), 0)
ylim <- c(1, max(max.umi))
max.ncells <- vapply(before.stats, nrow, 0L)
xlim <- c(1, max(max.ncells))

plot(0,0,type="n", xlab="Rank", ylab="Number of UMIs", 
    log="xy", xlim=xlim, ylim=ylim)
Warning in xy.coords(x, y, xlabel, ylabel, log): 1 x value <= 0 omitted from
logarithmic plot
Warning in xy.coords(x, y, xlabel, ylabel, log): 1 y value <= 0 omitted from
logarithmic plot
for (i in seq_along(before.stats)) {
    u <- sort(before.stats[[i]]$num.umis, decreasing=TRUE)
    lines(seq_along(u), u, col=i, lwd=5)
}
legend("topright", col=seq_along(before.stats), 
    lwd=5, legend=stringr::str_split(names(before.stats),"-",simplify = TRUE)[,2])

Version Author Date
e88c23e Reto Gerber 2021-07-12
after.mat <- swappedDrops(samples,get.swapped=TRUE,get.diagnostics=TRUE)
saveRDS(after.mat, here::here("output",paste0("syn_v4_swappedDrops_",order_id,"_after.rds")))
cleaned.sum <- vapply(after.mat$cleaned, sum, 0)
swapped.sum <- vapply(after.mat$swapped, sum, 0)
swapped.sum / (swapped.sum + cleaned.sum)
             o24793_1_01-91              o24793_1_02-92 
                0.011251514                 0.009949212 
             o24793_1_03-93              o24793_1_04-95 
                0.012013213                 0.017716810 
             o24793_1_05-96             o24793_1_06-98a 
                0.011379293                 0.012042140 
            o24793_1_07-98b              o24793_1_08-99 
                0.014001739                 0.010291177 
o24793_1_09-BB_skin_control     o24793_1_10-BB_skin_akg 
                0.013301817                 0.052566037 
plot(0,0,type="n", xlab="Rank", ylab="Number of UMIs", 
    log="xy", xlim=xlim, ylim=ylim)
Warning in xy.coords(x, y, xlabel, ylabel, log): 1 x value <= 0 omitted from
logarithmic plot

Warning in xy.coords(x, y, xlabel, ylabel, log): 1 y value <= 0 omitted from
logarithmic plot
for (i in seq_along(after.mat$cleaned)) {
    cur.stats <- barcodeRanks(after.mat$cleaned[[i]])
    u <- sort(cur.stats$total, decreasing=TRUE)
    lines(seq_along(u), u, col=i, lwd=5)
}

legend("topright", col=seq_along(after.mat$cleaned), 
    lwd=5, legend=stringr::str_split(names(after.mat$cleaned),"-",simplify = TRUE)[,2])

Version Author Date
e88c23e Reto Gerber 2021-07-12

sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.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=C             
 [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] parallel  stats4    stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] gdtools_0.2.3                  DropletUtils_1.10.3           
 [3] tidySingleCellExperiment_1.0.0 scuttle_1.0.4                 
 [5] scran_1.18.7                   scater_1.18.6                 
 [7] SingleCellExperiment_1.12.0    SummarizedExperiment_1.20.0   
 [9] Biobase_2.50.0                 GenomicRanges_1.42.0          
[11] GenomeInfoDb_1.26.7            IRanges_2.24.1                
[13] S4Vectors_0.28.1               BiocGenerics_0.36.1           
[15] MatrixGenerics_1.2.1           matrixStats_0.58.0            
[17] stringr_1.4.0                  purrr_0.3.4                   
[19] ggplot2_3.3.3                  dplyr_1.0.4                   
[21] workflowr_1.6.2               

loaded via a namespace (and not attached):
 [1] bitops_1.0-6              fs_1.5.0                 
 [3] httr_1.4.2                rprojroot_2.0.2          
 [5] tools_4.0.3               R6_2.5.0                 
 [7] irlba_2.3.3               HDF5Array_1.18.1         
 [9] vipor_0.4.5               lazyeval_0.2.2           
[11] DBI_1.1.1                 colorspace_2.0-0         
[13] rhdf5filters_1.2.1        withr_2.4.1              
[15] tidyselect_1.1.0          gridExtra_2.3            
[17] compiler_4.0.3            git2r_0.28.0             
[19] cli_2.3.0                 BiocNeighbors_1.8.2      
[21] DelayedArray_0.16.3       plotly_4.9.3             
[23] scales_1.1.1              systemfonts_1.0.1        
[25] digest_0.6.27             svglite_1.2.3.2          
[27] R.utils_2.10.1            rmarkdown_2.6            
[29] RhpcBLASctl_0.20-137      XVector_0.30.0           
[31] pkgconfig_2.0.3           htmltools_0.5.1.1        
[33] sparseMatrixStats_1.2.1   highr_0.8                
[35] limma_3.46.0              htmlwidgets_1.5.3        
[37] rlang_0.4.10              DelayedMatrixStats_1.12.3
[39] generics_0.1.0            jsonlite_1.7.2           
[41] BiocParallel_1.24.1       R.oo_1.24.0              
[43] RCurl_1.98-1.2            magrittr_2.0.1           
[45] BiocSingular_1.6.0        GenomeInfoDbData_1.2.4   
[47] Matrix_1.3-2              Rhdf5lib_1.12.1          
[49] Rcpp_1.0.6                ggbeeswarm_0.6.0         
[51] munsell_0.5.0             fansi_0.4.2              
[53] viridis_0.5.1             R.methodsS3_1.8.1        
[55] lifecycle_1.0.0           stringi_1.5.3            
[57] whisker_0.4               yaml_2.2.1               
[59] edgeR_3.32.1              zlibbioc_1.36.0          
[61] rhdf5_2.34.0              grid_4.0.3               
[63] promises_1.2.0.1          dqrng_0.2.1              
[65] crayon_1.4.1              lattice_0.20-41          
[67] beachmat_2.6.4            locfit_1.5-9.4           
[69] knitr_1.31                pillar_1.4.7             
[71] igraph_1.2.6              glue_1.4.2               
[73] evaluate_0.14             data.table_1.13.6        
[75] vctrs_0.3.6               httpuv_1.5.5             
[77] tidyr_1.1.2               gtable_0.3.0             
[79] assertthat_0.2.1          xfun_0.21                
[81] rsvd_1.0.3                later_1.1.0.1            
[83] viridisLite_0.3.0         tibble_3.0.6             
[85] beeswarm_0.2.3            bluster_1.0.0            
[87] statmod_1.4.35            ellipsis_0.3.1           
[89] here_1.0.1