This repository has been archived by the owner. It is now read-only.
Permalink
Cannot retrieve contributors at this time
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?
ReporteR.scRNAseq/inst/content/04-feature-selection-Z-distance.Rmd
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
62 lines (53 sloc)
4.15 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```{r parameters-and-defaults, include = FALSE} | |
module <- "scRNAseq" | |
section <- "feature_selection" | |
``` | |
```{r parameter-merge, include = FALSE} | |
local_params <- module %>% | |
options() %>% | |
magrittr::extract2(module) %>% | |
magrittr::extract2(section) %>% | |
ReporteR.base::validate_params(parameters_and_defaults) | |
``` | |
```{r scRNAseq-feature-selection-Z-distance-checks} | |
assertive.sets::assert_is_subset(local_params$assay, SummarizedExperiment::assayNames(object_filtered)) | |
``` | |
### Transcriptional noise within known celltypes | |
In total, **`r sum(SummarizedExperiment::rowData(object_filtered)$is_het)` heterogeneous genes** have been detected using methods described above. Heterogeneous genes can be used to calculate and compare the overall *transcriptional noise* in groups of cells, e.g. cell types, cell clusters, etc. Cell-to-cell distance values (here calculated as 1 - `r local_params$wgcna_cor_method` correlation) serve as a good proxy for transcriptional noise within and between cell populations, as they characterize cells in a defined state (low noise, low distance) *vs.* cells that loose their characteristic pattern (high noise, high distance) [@mojtahedi_fate_2016]. Figure \@ref(fig:scRNAseq-feature-selection-Z-distance-figure) shows transcriptional noise within and between cells across the experimental factor `r local_params$celltype`. | |
```{r scRNAseq-feature-selection-Z-distance-processing, include = FALSE} | |
celltypes <- droplevels(factor(SummarizedExperiment::colData(object_filtered)[, local_params$celltype])) | |
data <- SummarizedExperiment::assay(object_filtered, local_params$assay)[SummarizedExperiment::rowData(object_filtered)$is_het,] | |
transcriptome_noise_list <- lapply(levels(celltypes), function(c) { | |
i <- which(celltypes == c) | |
cor <- WGCNA::cor(data[, i], method = local_params$wgcna_cor_method) | |
1 - cor[upper.tri(cor)] | |
}) | |
transcriptome_noise <- data.frame(celltype = rep(levels(celltypes), times = sapply(transcriptome_noise_list, length)), distance = unlist(transcriptome_noise_list)) | |
``` | |
```{r scRNAseq-feature-selection-Z-distance-figure, echo = FALSE, message=FALSE, warning=FALSE, fig.cap = "Cell-to-cell distance as a proxy of transcriptional noise. Low distance values hint to low transcriptional noise within a homogeneous cell population of a defined state. High distance values indicate cells that are loosing their characteristic state."} | |
theme_violins <- ggplot2::theme(plot.background = ggplot2::element_blank(), | |
panel.grid.major = ggplot2::element_blank(), | |
panel.grid.minor = ggplot2::element_blank(), | |
panel.border = ggplot2::element_blank(), | |
panel.background = ggplot2::element_blank(), | |
axis.line.y = ggplot2::element_line(size=.3), | |
axis.line.x = ggplot2::element_line(size=.3), | |
legend.text = ggplot2::element_text(size=6), | |
axis.title.y = ggplot2::element_text(color="black", size=10), | |
axis.title.x = ggplot2::element_blank(), | |
plot.title = ggplot2::element_text(face="bold", color="black", size=6), | |
legend.key.size = grid::unit(2, "mm"), | |
legend.margin = grid::unit(-25, "mm"), | |
strip.background = ggplot2::element_blank(), | |
strip.text = ggplot2::element_blank(), | |
axis.text = ggplot2::element_text(color="black", size=8), | |
axis.text.x = ggplot2::element_text(color="black", size=10)) | |
ggplot2::ggplot(data = transcriptome_noise, ggplot2::aes(x = celltype, y = distance, fill = celltype)) + | |
ggplot2::geom_violin(trim = F) + | |
ggplot2::geom_boxplot(width = 0.1, fill = "white") + | |
#scale_fill_manual(values = nkx_colors) + | |
ggplot2::scale_y_continuous(expand = c(0.05, 0)) + | |
ggplot2::guides(fill = FALSE, colour = FALSE) + | |
ggplot2::xlab("") + ggplot2::ylab("Cell to cell distance") + theme_violins + | |
ggplot2::theme(plot.margin = grid::unit(c(0, -5, 2.5, 0), "mm")) | |
``` |