This function computes the enrichment scores for the cells using AddModuleScore and then aggregates the scores by the metadata variables provided by the user and displays it as a heatmap, computed by Heatmap.
do_EnrichmentHeatmap(
sample,
input_gene_list,
features.order = NULL,
groups.order = NULL,
cluster = TRUE,
scale_scores = FALSE,
assay = NULL,
slot = NULL,
reduction = NULL,
group.by = NULL,
values.show = FALSE,
values.threshold = NULL,
values.size = 3,
values.round = 1,
verbose = FALSE,
na.value = "grey75",
legend.position = "bottom",
use_viridis = FALSE,
viridis.palette = "G",
viridis.direction = 1,
legend.framewidth = 0.5,
legend.tickwidth = 0.5,
legend.length = 20,
legend.width = 1,
legend.framecolor = "grey50",
legend.tickcolor = "white",
legend.type = "colorbar",
font.size = 14,
font.type = "sans",
axis.text.x.angle = 45,
enforce_symmetry = FALSE,
nbin = 24,
ctrl = 100,
flavor = "Seurat",
legend.title = NULL,
ncores = 1,
storeRanks = TRUE,
min.cutoff = NA,
max.cutoff = NA,
pt.size = 1,
plot_cell_borders = TRUE,
border.size = 2,
return_object = FALSE,
number.breaks = 5,
sequential.palette = "YlGnBu",
diverging.palette = "RdBu",
diverging.direction = -1,
sequential.direction = 1,
flip = FALSE,
grid.color = "white",
border.color = "black",
plot.title.face = "bold",
plot.subtitle.face = "plain",
plot.caption.face = "italic",
axis.title.face = "bold",
axis.text.face = "plain",
legend.title.face = "bold",
legend.text.face = "plain"
)A ggplot2 object.
Seurat | A Seurat object, generated by CreateSeuratObject.
named_list | Named list of lists of genes to be used as input.
character | Should the gene sets be ordered in a specific way? Provide it as a vector of characters with the same names as the names of the gene sets.
named_list | Should the groups in theheatmaps be ordered in a specific way? Provide it as a named list (as many lists as values in group.by) with the order for each of the elements in the groups.
logical | Whether to perform clustering of rows and columns.
logical | Whether to transform the scores to a range of 0-1 for plotting.
character | Assay to use. Defaults to the current assay.
character | Data slot to use. Only one of: counts, data, scale.data. Defaults to "data".
character | Reduction to use. Can be the canonical ones such as "umap", "pca", or any custom ones, such as "diffusion". If you are unsure about which reductions you have, use Seurat::Reductions(sample). Defaults to "umap" if present or to the last computed reduction if the argument is not provided.
character | Metadata variable to group the output by. Has to be a character of factor column.
logical | Whether to add values as text in the heatmap.
numeric | Value from which the text color turns from black to white. If mode = "hvg", this is applied to both ends of the color scale.
numeric | Size of the text labels.
numeric | Decimal to which round the values to.
logical | Whether to show extra comments, warnings,etc.
character | Color value for NA.
character | Position of the legend in the plot. One of:
top: Top of the figure.
bottom: Bottom of the figure.
left: Left of the figure.
right: Right of the figure.
none: No legend is displayed.
logical | Whether to use viridis color scales.
character | A capital letter from A to H or the scale name as in scale_fill_viridis.
numeric | Either 1 or -1. Controls how the gradient of viridis scale is formed.
numeric | Width of the lines of the box in the legend.
numeric | Length and width of the legend. Will adjust automatically depending on legend side.
character | Color of the lines of the box in the legend.
character | Color of the ticks of the box in the legend.
character | Type of legend to display. One of:
normal: Default legend displayed by ggplot2.
colorbar: Redefined colorbar legend, using guide_colorbar.
numeric | Overall font size of the plot. All plot elements will have a size relationship with this font size.
character | Base font family for the plot. One of:
mono: Mono spaced font.
serif: Serif font family.
sans: Default font family.
numeric | Degree to rotate the X labels. One of: 0, 45, 90.
logical | Whether the geyser and feature plot has a symmetrical color scale.
numeric | Number of bins to use in AddModuleScore.
numeric | Number of genes in the control set to use in AddModuleScore.
character | One of: Seurat, UCell. Compute the enrichment scores using AddModuleScore or AddModuleScore_UCell.
character | Title for the legend.
numeric | Number of cores used to run UCell scoring.
logical | Whether to store the ranks for faster UCell scoring computations. Might require large amounts of RAM.
numeric | Set the min/max ends of the color scale. Any cell/group with a value lower than min.cutoff will turn into min.cutoff and any cell with a value higher than max.cutoff will turn into max.cutoff. In FeaturePlots, provide as many values as features. Use NAs to skip a feature.
numeric | Size of the dots.
logical | Whether to plot border around cells.
numeric | Width of the border of the cells.
logical | Return the Seurat object with the enrichment scores stored.
numeric | Controls the number of breaks in continuous color scales of ggplot2-based plots.
character | Type of sequential color palette to use. Out of the sequential palettes defined in brewer.pal.
character | Type of symmetrical color palette to use. Out of the diverging palettes defined in brewer.pal.
numeric | Either 1 or -1. Direction of the divering palette. This basically flips the two ends.
numeric | Direction of the sequential color scale. Either 1 or -1.
logical | Whether to invert the axis of the displayed plot.
character | Color of the grid in the plot. In heatmaps, color of the border of the cells.
character | Color for the border of the heatmap body.
character | Controls the style of the font for the corresponding theme element. One of:
plain: For normal text.
italic: For text in itallic.
bold: For text in bold.
bold.italic: For text both in itallic and bold.
# \donttest{
# Check Suggests.
value <- SCpubr:::check_suggests(function_name = "do_EnrichmentHeatmap", passive = TRUE)
if (isTRUE(value)){
# Consult the full documentation in https://enblacar.github.io/SCpubr-book/
# Define your Seurat object.
sample <- readRDS(system.file("extdata/seurat_dataset_example.rds", package = "SCpubr"))
# Genes have to be unique.
genes <- list("A" = rownames(sample)[1:5],
"B" = rownames(sample)[6:10],
"C" = rownames(sample)[11:15])
# Default parameters.
p <- SCpubr::do_EnrichmentHeatmap(sample = sample,
input_gene_list = genes,
nbin = 1,
ctrl = 10)
p
} else if (base::isFALSE(value)){
message("This function can not be used without its suggested packages.")
message("Check out which ones are needed using `SCpubr::state_dependencies()`.")
}
# }
Run the code above in your browser using DataLab