Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/plotMarkerHeat.R
Plot a heatmap of expression values for a select set of genes across all cells. Optionally also cluster those genes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | plotMarkerHeat(
exp,
classes,
markers,
colors = colorRampPalette(rev(c("orangered4", "orangered", "gray90", "dodgerblue",
"dodgerblue4")))(n = 100),
newOrder = 1:length(unique(classes)),
clusterGenes = FALSE,
clusterGenesK = length(unique(classes)),
averageCells = 0,
outs = FALSE,
plotheat = TRUE,
gaps = TRUE,
seed = 10
)
|
exp |
A matrix of expression values. Typically the one supplied to
|
classes |
A vector or factor of cell classes, whose length is equal to
|
markers |
A character vector of gene names to plot in the heatmap. |
colors |
Color palette used for the heatmap. |
newOrder |
Reorder the clusters in the heatmap? See Examples. |
clusterGenes |
Cluster genes before plotting? |
clusterGenesK |
How many clusters should genes by clustered into? See Details. |
averageCells |
Plot averages of cells instead of individual cells. You can use this when you have a large number of cells. See Details. |
outs |
Should gene cluster output and pheatmap object be returned? FALSE by default. |
plotheat |
Should the heatmap be drawn? TRUE by default. |
gaps |
Should the heatmap have gaps between cell types and gene clusters? TRUE by default. |
seed |
Randomization seed used for gene clustering initialization. |
clusterGenesK
parameter controls the number of gene clusters when
clusterGenes
is TRUE
. By default, it is equal to the number of
cell types/clusters. This is usually a good initial guess, the optimal
number of clusters (what does that even mean?) is typically somewhere around
this value in my subjective experience, unless there are many cell clusters.
By default, the heatmap plots every single cell in one column, this might
take forever if you have a lot of cells (would say >10k) or it can crash when
you do not have enough RAM. If so, it might be good to set averageCells
to n
where n
is the number of cells you
want to average. For example, if averageCells = 10
, every 10 cells will
be averaged (without averaging across cell clusters) before plotting the heatmap.
if averageCells =< 1
, no averaging happens. Hints: (1) If you want one column
per cell cluster, set averageCells
to a very high number (larger than the
number of cells in the largest cluster). (2) Gene clustering occurs after cell
averaging, so averaging might be useful if the gene clusters you get do not make much sense
without averaging (averaging will smooth out zeros).
If outs
is TRUE, plotMarkerHeat
returns a list
containing:
p |
The pheatmap object corresponding to the plot. |
gene_class_info |
Gene cluster assignments if gene clustering was requested. See Details. |
new_class_info |
The new order of cell clusters. See Examples. |
Mahmoud M Ibrahim <mmibrahim@pm.me>
plotTopMarkerHeat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | data(kidneyTabulaMuris)
gs = sortGenes(kidneyTabulaMuris$exp, kidneyTabulaMuris$cellType)
mm = getMarkers(gs, quant = 0.999)
#this plots a heatmap without reordering genes
plotMarkerHeat(gs$inputMat, gs$inputClass, mm$markers)
#so now cluster genes and return the clustering: a better looking plot
pp = plotMarkerHeat(gs$inputMat, gs$inputClass, mm$markers, clusterGenes=TRUE, outs=TRUE)
pp$gene_class_info #cell clusters
#reorder cell clusters in the heatmap
plotMarkerHeat(gs$inputMat, gs$inputClass, mm$markers, clusterGenes=TRUE, newOrder = c(3,1,2))
#average every 4 cells to make a less intense heatmap
plotMarkerHeat(gs$inputMat, gs$inputClass, mm$markers, clusterGenes=TRUE, newOrder = c(3,1,2),
averageCells = 4)
#only cluster genes, do not make plots
pp = plotMarkerHeat(gs$inputMat, gs$inputClass, mm$markers, clusterGenes=TRUE,
outs=TRUE, plotheat=FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.