Last updated: 2020-06-08
Checks: 7 0
Knit directory: neural_scRNAseq/
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(20200522) 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 f3c8307. 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: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: ._.DS_Store
Ignored: .__workflowr.yml
Ignored: ._neural_scRNAseq.Rproj
Ignored: analysis/.DS_Store
Ignored: analysis/.Rhistory
Ignored: analysis/._.DS_Store
Ignored: analysis/._01-preprocessing.Rmd
Ignored: analysis/._01-preprocessing.html
Ignored: analysis/._02.1-SampleQC.Rmd
Ignored: analysis/._04-clustering.Rmd
Ignored: analysis/._04-clustering.knit.md
Ignored: analysis/.__site.yml
Ignored: analysis/01-preprocessing_cache/
Ignored: analysis/02-1-SampleQC_cache/
Ignored: analysis/02-quality_control_cache/
Ignored: analysis/02.1-SampleQC_cache/
Ignored: analysis/04-clustering_cache/
Ignored: analysis/05-annotation_cache/
Ignored: analysis/sample5_QC_cache/
Ignored: data/.DS_Store
Ignored: data/._.DS_Store
Ignored: data/._metadata.csv
Ignored: data/._metadata.xlsx
Ignored: data/.smbdeleteAAA17ed8b4b
Ignored: data/data_sushi/
Ignored: data/filtered_feature_matrices/
Ignored: data/metadata.csv
Ignored: data/metadata.xlsx
Ignored: output/.DS_Store
Ignored: output/._.DS_Store
Ignored: output/figures/
Ignored: output/sce_01_preprocessing.rds
Ignored: output/sce_02_quality_control.rds
Ignored: output/sce_03_filtering.rds
Ignored: output/sce_preprocessing.rds
Ignored: output/so_04_clustering.rds
Untracked files:
Untracked: analysis/sample5_QC.Rmd
Untracked: scripts/
Unstaged changes:
Modified: analysis/04-clustering.Rmd
Modified: analysis/_site.yml
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/03-filtering.Rmd) and HTML (docs/03-filtering.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 | 6d822af | khembach | 2020-05-28 | Build site. |
| Rmd | a7ced59 | khembach | 2020-05-28 | cell and gene filtering |
library(scater)
library(LSD)
sce <- readRDS(file.path("output", "sce_02_quality_control.rds"))
Based on the QC metrics, we now identify outlier cells:
cols <- c("sum", "detected", "subsets_Mt_percent")
log <- c(TRUE, TRUE, FALSE)
type <- c("both", "both", "higher")
drop_cols <- paste0(cols, "_drop")
for (i in seq_along(cols))
colData(sce)[[drop_cols[i]]] <- isOutlier(sce[[cols[i]]],
nmads = 3, type = type[i], log = log[i], batch = sce$sample_id)
# Overlap of outlier cells from two metrics
sapply(drop_cols, function(i)
sapply(drop_cols, function(j)
sum(sce[[i]] & sce[[j]])))
sum_drop detected_drop subsets_Mt_percent_drop
sum_drop 2499 2289 614
detected_drop 2289 2740 809
subsets_Mt_percent_drop 614 809 2611
colData(sce)$discard <- rowSums(data.frame(colData(sce)[,drop_cols])) > 0
table(colData(sce)$discard)
FALSE TRUE
43846 4735
## Plot the metrics and highlight the discarded cells
plotColData(sce, x = "sample_id", y = "sum", colour_by = "discard") +
scale_y_log10()

| Version | Author | Date |
|---|---|---|
| 6d822af | khembach | 2020-05-28 |
plotColData(sce, x = "sample_id", y = "detected", colour_by = "discard") +
scale_y_log10()

| Version | Author | Date |
|---|---|---|
| 6d822af | khembach | 2020-05-28 |
plotColData(sce, x = "sample_id", y = "subsets_Mt_percent",
colour_by = "discard")

| Version | Author | Date |
|---|---|---|
| 6d822af | khembach | 2020-05-28 |
Plot the library size against the number of detected genes before and after filtering.
cd <- colData(sce)
layout(matrix(1:12, nrow = 3, byrow = TRUE))
for (i in levels(sce$sample_id)) {
tmp <- cd[cd$sample_id == i,]
heatscatter(tmp$sum, tmp$detected, log = "xy",
main = paste0(i, "-unfiltered"), xlab = "total counts",
ylab = "detected genes")
heatscatter(tmp$sum[!tmp$discard], tmp$detected[!tmp$discard],
log = "xy", main = paste0(i, "-filtered"), xlab = "total counts",
ylab = "detected genes")
}

| Version | Author | Date |
|---|---|---|
| 6d822af | khembach | 2020-05-28 |
We remove the outlier cells and filter the genes:
## summary of the kept cells
nr <- table(cd$sample_id)
nr_fil <- table(cd$sample_id[!cd$discard])
print(rbind(
unfiltered = nr, filtered = nr_fil,
"%" = round(nr_fil / nr * 100, digits = 0)))
1NSC 2NSC 3NC52 4NC52 5NC96 6NC96
unfiltered 8893 8854 9109 8865 6571 6289
filtered 8331 8408 8687 7438 6189 4793
% 94 95 95 84 94 76
## discard the outlier cells
dim(sce)
[1] 19375 48581
sce <- sce[,!cd$discard]
dim(sce)
[1] 19375 43846
## we filter genes and require > 1 count in at least 20 cells
sce <- sce[rowSums(counts(sce) > 1) >= 20, ]
dim(sce)
[1] 13264 43846
saveRDS(sce, file.path("output", "sce_03_filtering.rds"))
sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS
Matrix products: default
BLAS: /usr/local/R/R-4.0.0/lib/libRblas.so
LAPACK: /usr/local/R/R-4.0.0/lib/libRlapack.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=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] parallel stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] HDF5Array_1.16.0 rhdf5_2.32.0
[3] LSD_4.0-0 scater_1.16.0
[5] ggplot2_3.3.0 SingleCellExperiment_1.10.1
[7] SummarizedExperiment_1.18.1 DelayedArray_0.14.0
[9] matrixStats_0.56.0 Biobase_2.48.0
[11] GenomicRanges_1.40.0 GenomeInfoDb_1.24.0
[13] IRanges_2.22.2 S4Vectors_0.26.1
[15] BiocGenerics_0.34.0 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] viridis_0.5.1 BiocSingular_1.4.0
[3] viridisLite_0.3.0 DelayedMatrixStats_1.10.0
[5] assertthat_0.2.1 GenomeInfoDbData_1.2.3
[7] vipor_0.4.5 yaml_2.2.1
[9] pillar_1.4.4 backports_1.1.7
[11] lattice_0.20-41 glue_1.4.1
[13] digest_0.6.25 promises_1.1.0
[15] XVector_0.28.0 colorspace_1.4-1
[17] cowplot_1.0.0 htmltools_0.4.0
[19] httpuv_1.5.2 Matrix_1.2-18
[21] pkgconfig_2.0.3 zlibbioc_1.34.0
[23] purrr_0.3.4 scales_1.1.1
[25] whisker_0.4 later_1.0.0
[27] BiocParallel_1.22.0 git2r_0.27.1
[29] tibble_3.0.1 farver_2.0.3
[31] ellipsis_0.3.1 withr_2.2.0
[33] magrittr_1.5 crayon_1.3.4
[35] evaluate_0.14 fs_1.4.1
[37] beeswarm_0.2.3 tools_4.0.0
[39] lifecycle_0.2.0 stringr_1.4.0
[41] Rhdf5lib_1.10.0 munsell_0.5.0
[43] irlba_2.3.3 compiler_4.0.0
[45] rsvd_1.0.3 rlang_0.4.6
[47] grid_4.0.0 RCurl_1.98-1.2
[49] BiocNeighbors_1.6.0 bitops_1.0-6
[51] labeling_0.3 rmarkdown_2.1
[53] gtable_0.3.0 codetools_0.2-16
[55] R6_2.4.1 gridExtra_2.3
[57] knitr_1.28 dplyr_0.8.5
[59] rprojroot_1.3-2 stringi_1.4.6
[61] ggbeeswarm_0.6.0 Rcpp_1.0.4.6
[63] vctrs_0.3.0 tidyselect_1.1.0
[65] xfun_0.14