celltype.heatmap: Plot a averaged expression heatmap from a Seurat object

View source: R/main.R

celltype.heatmapR Documentation

Plot a averaged expression heatmap from a Seurat object

Description

This function allows to calculate and plot pseudo-bulk gene expression by cell type and custom grouping variables. Data can be split in principle by any metadata present in the starting Seurat object (e.g. patient, tissue, study, etc.). This can be useful to evaluate consistency of expression profiles for different cell types across samples, studies or other grouping variables.

Usage

celltype.heatmap(
  data,
  assay = "RNA",
  slot = "data",
  genes,
  ref = NULL,
  scale = "row",
  method = c("ward.D2", "ward.D", "average"),
  brewer.palette = "RdBu",
  palette_reverse = F,
  palette = NULL,
  cluster.col = "functional.cluster",
  group.by = NULL,
  flip = FALSE,
  cluster_genes = FALSE,
  cluster_samples = FALSE,
  min.cells = 10,
  show_samplenames = FALSE,
  remove.NA.meta = TRUE,
  breaks = seq(-2, 2, by = 0.1),
  return.matrix = FALSE,
  ...
)

Arguments

data

A Seurat object to be used for the heatmap

assay

A string indicating the assay type, default is "RNA"

genes

A vector of genes to be used in the heatmap

ref

A ProjecTILs reference Seurat object to define the order of functional.cluster

scale

A string indicating the scale of the heatmap, default is "row"

method

A string or vector of strings indicating the clustering method to be used, default is "ward.D2"

brewer.palette

A string indicating the color palette to be used, default is "RdBu"

palette_reverse

A boolean indicating if color palette should be reversed, default is FALSE

palette

A named list containing colors vectors compatible with pheatmap. The list is named by the metadata names, default is taking these palettes to plot metadata: "Paired","Set2","Accent","Dark2","Set1","Set3".

cluster.col

The metadata column name containing the cell type labels

group.by

The metadata column names used as grouping variables

flip

A boolean indicating if the heatmap should be flipped, default is FALSE

cluster_genes

A boolean indicating if genes should be clustered, default is FALSE

cluster_samples

A boolean indicating if samples should be clustered, default is FALSE

min.cells

A value defining the minimum number of cells a sample should have to be kept, default is 10

show_samplenames

A boolean indicating whether the heatmap should display the sample names or not, default is FALSE

remove.NA.meta

A boolean indicating if missing samples with missing metadata should be plotted, default is TRUE

return.matrix

If true, return the pseudo-bulk data matrix instead of graphical output

Value

A pheatmap plot, displaying averaged expression values across genes for each selected genes and samples.

Examples

library(Seurat)
ref <- load.reference.map(ref = "https://figshare.com/ndownloader/files/38921366")
celltype.heatmap(ref, assay = "RNA", genes = c("LEF1","SELL","GZMK","FGFBP2"),
    ref = ref, cluster.col = "functional.cluster", metadata = c("orig.ident", "Tissue"))

carmonalab/ProjecTILs documentation built on April 13, 2025, 10:04 p.m.