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
82 lines (69 sloc) 4.63 KB
```{r parameters-and-defaults, include = FALSE}
module <- "scRNAseq"
section <- "marker_genes"
```
```{r parameter-merge, include = FALSE}
local_params <- module %>%
options() %>%
magrittr::extract2(module) %>%
magrittr::extract2(section) %>%
ReporteR.base::validate_params(parameters_and_defaults)
```
```{r scRNAseq-marker-A-individual-check, include = FALSE, echo = FALSE}
assertive.sets::is_subset(local_params$features, rownames(object_filtered))
if (!is.null(local_params$translate)) {
assertive.sets::is_subset(local_params$translate, colnames(SummarizedExperiment::rowData(object_filtered)))
}
```
### Individual genes
Figure \@ref(fig:scRNAseq-marker-A-individual-figure) shows selected marker genes **individually**, meaning that the color scale represents the gene expression of a single gene.
```{r scRNAseq-marker-A-individual-figure-params, include = FALSE, echo = FALSE}
theme_marker_individual <- 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 = 4),
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")
palette_marker_individual <- c("#D3D3D3", "#FF856D", "#D05C48", "#A13325", "#730000")
if (!length(local_params$translate) == 0) {
m <- match(local_params$features, rownames(object_filtered))
assertive.base::assert_any_are_not_na(m)
feature_names <- SummarizedExperiment::rowData(object_filtered)[m, local_params$translate]
} else {
feature_names <- local_params$features
}
fig_height <- ReporteR.base::estimate_figure_height(
height_in_panels = min(ceiling(length(local_params$features)/3), max(4, ceiling(length(local_params$features)/3))),
panel_height_in_in = params$formatting_defaults$figures$panel_height_in,
axis_space_in_in = params$formatting_defaults$figures$axis_space_in,
mpf_row_space = as.numeric(grid::convertUnit(grid::unit(5, 'mm'), 'in')),
max_height_in_in = params$formatting_defaults$figures$max_height_in)
feature_names_caption <- ReporteR.base::itemize(paste0("(", LETTERS[1:min(12, length(feature_names))], ") ", feature_names[1:min(12, length(feature_names))]))
caption <- glue::glue("Marker gene expression. Samples shown in the 2-dimensional space of *{local_params$dimred}*, color-coded by the expression of {feature_names_caption}.")
```
```{r scRNAseq-marker-A-individual-figure, echo = FALSE, message=FALSE, warning=FALSE, fig.height = fig_height$global, fig.cap = caption}
figure_marker_individual <- multipanelfigure::multi_panel_figure(height = fig_height$sub, columns = min(3, length(local_params$features)), rows = min(ceiling(length(local_params$features)/3), max(4, ceiling(length(local_params$features)/3))), unit = "in")
for(i in 1:min(12, length(local_params$features))) {
tmp_plot <- object_filtered %>%
scater::plotReducedDim(use_dimred = local_params$dimred, colour_by = local_params$features[i], add_ticks = FALSE, alpha = 0.9, by_exprs_values = local_params$assay) +
#ggplot2::guides(colour = FALSE) +
ggplot2::scale_fill_gradientn(colors = palette_marker_individual, name = feature_names[i]) +
#ggplot2::scale_color_gradientn(colors = palette_marker_individual) +
theme_marker_individual
figure_marker_individual <- multipanelfigure::fill_panel(figure_marker_individual, tmp_plot)
}
figure_marker_individual
```