Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
64fce7794e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
173 lines (157 sloc) 7.22 KB
```{r, parameters-and-defaults, include = FALSE}
module <- "scRNAseq"
section <- "quality_control"
parameters_and_defaults <- list(
assay = structure(
"counts",
type = "character",
choices = NA,
several.ok = FALSE
),
control_feature_yml = structure(
c(),
type = "character",
choices = NA,
several.ok = FALSE
),
control_samples_yml = structure(
c(),
type = "character",
choices = NA,
several.ok = FALSE
),
features = structure(
c("percent_mapped"),
type = "character",
choices = NA,
several.ok = TRUE
),
qc_tsne = structure(
TRUE,
type = "logical",
choices = NA,
several.ok = FALSE
),
qc_pca = structure(
c("irlba"),
type = "character",
choices = c("none", "irlba", "prcomp"),
several.ok = FALSE
),
cell_filter_yml = structure(
"none",
type = "character",
choices = NA,
several.ok = FALSE
),
cell_filter_allow_n_failed = structure(
1L,
type = "integer",
choices = NA,
several.ok = FALSE
),
tabulate_samples = structure(
c(),
type = "character",
choices = NA,
several.ok = FALSE
),
gene_filter_yml = structure(
"none",
type = "character",
choices = NA,
several.ok = FALSE
),
tabulate_features = structure(
c(),
type = "character",
choices = NA,
several.ok = FALSE
),
summarize_features = structure(
c(),
type = "character",
choices = NA,
several.ok = TRUE
),
summarize_samples = structure(
c(),
type = "character",
choices = NA,
several.ok = TRUE
),
plot_saturation = structure(
TRUE,
type = "logical",
choices = NA,
several.ok = TRUE
)
)
```
```{r parameter-merge, include = FALSE}
local_params <- module %>%
options() %>%
magrittr::extract2(module) %>%
magrittr::extract2(section) %>%
ReporteR.base::validate_params(parameters_and_defaults)
```
## Quality control
* **sequencing depth**: Low quality cells typically have low numbers of reads sequenced.
* **detected features**: Low quality cells typically have low numbers of detected genes.
* **dropout rates**: Low quality cells typically have high dropout-rates.
* **duplicated reads**: Low quality cells typically have high percentage of read duplication.
* **mitochondrial gene expression**: Low quality cells are typically dominated by mitochondrial genes.
* **alignment to genes**: Low number of alignments to genes might be a sign of low quality cells.
* **housekeeping gene expression**: High quality cells express housekeeping genes.
```{r scRNAseq-quality-control-A-params, echo = FALSE, include = FALSE, R.options = params}
theme_qc_pca <- ggplot2::theme(plot.background = ggplot2::element_blank(),
panel.grid.major = ggplot2::element_line(size=.2, colour = "grey"),
panel.grid.minor = ggplot2::element_line(size=.1, colour = "grey"),
panel.border = ggplot2::element_blank(),
panel.background = ggplot2::element_blank(),
axis.line.x = ggplot2::element_line(size=.3),
axis.line.y = ggplot2::element_line(size=.3),
axis.text = ggplot2::element_text(size = 4),
axis.title.y = ggplot2::element_text(size = 5, margin = ggplot2::margin(0, -2, 0, 0)),
axis.title.x = ggplot2::element_text(size = 5, margin = ggplot2::margin(-2, 0, 0, 0)),
legend.text = ggplot2::element_text(size = 5),
legend.title = ggplot2::element_text(size = 5),
plot.title = ggplot2::element_text(face="bold", color="black", size=5),
legend.key.size = grid::unit(2, "mm"),
legend.margin = ggplot2::margin(b = 2),#grid::unit(-50, "mm"),
legend.position = c(0,1),
legend.justification = c(0,0),
legend.background = ggplot2::element_rect(fill = "white"),
legend.direction = "horizontal")
```
```{r scRNAseq-quality-control-A-setup, echo = FALSE, child = system.file(file.path('content', '02-quality-control-A-setup.Rmd'), package = 'ReporteR.scRNAseq', mustWork = TRUE), R.options = params, eval = TRUE}
```
```{r scRNAseq-quality-control-B-pca, echo = FALSE, child = system.file(file.path('content', '02-quality-control-B-pca.Rmd'), package = 'ReporteR.scRNAseq', mustWork = TRUE), R.options = params, eval = ifelse(exists('local_params'), local_params$qc_pca != "none", FALSE)}
```
```{r scRNAseq-quality-control-C-tsne, echo = FALSE, child = system.file(file.path('content', '02-quality-control-C-tsne.Rmd'), package = 'ReporteR.scRNAseq', mustWork = TRUE), R.options = params, eval = ifelse(exists('local_params'), local_params$qc_tsne, FALSE)}
```
```{r scRNAseq-quality-control-D-cellfiltering, echo = FALSE, child = system.file(file.path('content', '02-quality-control-D-cellfiltering.Rmd'), package = 'ReporteR.scRNAseq', mustWork = TRUE), R.options = params, eval = ifelse(exists('local_params'), local_params$cell_filter_yml != "none", FALSE)}
```
```{r scRNAseq-quality-control-E-genefiltering, echo = FALSE, child = system.file(file.path('content', '02-quality-control-E-genefiltering.Rmd'), package = 'ReporteR.scRNAseq', mustWork = TRUE), R.options = params, eval = ifelse(exists('local_params'), local_params$gene_filter_yml != "none", FALSE)}
```
```{r scRNAseq-quality-control-F-createobject, include=FALSE, echo=FALSE}
# Check presence of control cells and remove them
SummarizedExperiment::colData(object)$qc_status[SummarizedExperiment::colData(object)$is_cell_control] <- "fail"
object[SummarizedExperiment::rowData(object)$qc_status == "pass", SummarizedExperiment::colData(object)$qc_status == "pass"] %>%
scater::calculateQCMetrics(percent_top = c(50, 100, 500), exprs_values = local_params$assay) %>%
scater::mutate(percent_dropout = 1 - apply(SummarizedExperiment::assay(., local_params$assay), 2, function(x) mean(x > 0))) -> object_filtered
```
```{r scRNAseq-quality-control-G-saturation, echo = FALSE, child = system.file(file.path('content', '02-quality-control-G-saturation.Rmd'), package = 'ReporteR.scRNAseq', mustWork = TRUE), R.options = params, eval = ifelse(exists('local_params'), local_params$plot_saturation, FALSE)}
```
```{r scRNAseq-quality-control-Y-summary, echo = FALSE, child = system.file(file.path('content', '02-quality-control-Y-summary.Rmd'), package = 'ReporteR.scRNAseq', mustWork = TRUE), R.options = params, eval = TRUE}
```
```{r scRNAseq-quality-control-Z-appendix, echo = FALSE, include = FALSE, R.options=params}
rmd_path <- system.file(file.path('content', '02-quality-control-Z-appendix.Rmd'), package = 'ReporteR.scRNAseq', mustWork = TRUE)
md_path = ReporteR.base::make_md_path(rmd_path)
knitr::knit_child(rmd_path, output = md_path)
```
```{r scRNAseq-quality-control-terminal-cleanup, include = FALSE}
saveRDS(object = object, file = managed_objects$paths$object$path)
saveRDS(object = object_filtered, file = managed_objects$paths$object_filtered$path)
ReporteR.base::purge_nonpersistent()
```