plotMarkerHeatmap: Plot a heatmap of the markers for a label

View source: R/plotMarkerHeatmap.R

plotMarkerHeatmapR Documentation

Plot a heatmap of the markers for a label

Description

Create a heatmap of the log-normalized expression for the most interesting markers of a particular label.

Usage

plotMarkerHeatmap(
  results,
  test,
  label,
  other.labels = NULL,
  assay.type = "logcounts",
  display.row.names = NULL,
  use.pruned = FALSE,
  order.by.effect = "cohens.d",
  order.by.summary = "min.rank",
  top = 20,
  num.threads = bpnworkers(BPPARAM),
  BPPARAM = SerialParam(),
  ...
)

configureMarkerHeatmap(
  results,
  test,
  label,
  other.labels = NULL,
  assay.type = "logcounts",
  use.pruned = FALSE,
  order.by.effect = "cohens.d",
  order.by.summary = "min.rank",
  num.threads = 1
)

Arguments

results

A DataFrame containing the output from SingleR, classifySingleR, or combineRecomputedResults.

test

A numeric matrix of log-normalized expression values where rows are genes and columns are cells. Each row should be named with the same gene name that was used to compute results.

Alternatively, a SummarizedExperiment object containing such a matrix.

label

String specifying the label of interest.

other.labels

Character vector specifying the other labels to be compared to label when finding interesting markers. Defaults to all available labels.

assay.type

Integer scalar or string specifying the matrix of expression values to use if test is a SummarizedExperiment.

display.row.names

Character vector of length equal to the number of rows of test, containing the names of the features to show on the heatmap (e.g., to replace IDs with symbols). If NULL, the existing row names of test are used.

use.pruned

Logical scalar indicating whether the pruned labels should be used instead.

order.by.effect

String specifying the effect size from scoreMarkers with which to sort for interesting markers.

order.by.summary

String specifying the summary statistic from scoreMarkers with which to sort for interesting markers.

top

Integer scalar indicating the top most interesting markers to show in the heatmap.

num.threads

Integer scalar specifying the number to threads to use.

BPPARAM

Deprecated, use num.threads instead.

...

Additional parameters for heatmap control passed to pheatmap.

Details

The plotMarkerHeatmap function creates a heatmap where each row is a marker gene for label and each column is a cell in the test dataset. The aim is to check the effectiveness of the reference-derived markers for distinguishing between labels in the test dataset. “Interesting” markers should show strong upregulation in cells assigned to label compared to cells assigned to all other.labels. We identify such markers by scoring all reference-derived markers with scoreMarkers on the test expression. The top markers based on the specified order.by.* fields are shown in the heatmap. If only one label is present, markers are ranked by average abundance intead.

The configureMarkerHeatmap function performs all the calculations underlying plotMarkerHeatmap. This can be used to apply the same general approach with other plots, e.g., using functions from scuttle or dittoSeq.

Value

For plotMarkerHeatmap, the output of pheatmap is returned showing the heatmap on the current graphics device.

For configureMarkerHeatmap, a list is returned containing:

  • rows, an integer vector of row indices for the markers of label, ordered from most to least interesting.

  • columns, an integer vector of column indices to show in the heatmap. This is ordered by the predicted labels so that cells assigned to the same label are contiguous.

  • predictions, a character vector of predicted labels for cells to be shown in the heatmap. Each entry corresponds to an entry of columns. The labels in this vector are guaranteed to be sorted.

Author(s)

Aaron Lun

Examples

# Running the SingleR() example.
example(SingleR, echo=FALSE)

plotMarkerHeatmap(pred, test, pred$labels[1])
plotMarkerHeatmap(pred, test, pred$labels[1], use.pruned=TRUE)
plotMarkerHeatmap(pred, test, pred$labels[1], order.by.effect="auc")

# Manually configuring a simpler heatmap by label:
config <- configureMarkerHeatmap(pred, test, pred$labels[1])
mat <- assay(test, "logcounts")[head(config$rows, 20), config$columns]
aggregated <- scuttle::summarizeAssayByGroup(mat, config$predictions)
pheatmap::pheatmap(assay(aggregated), cluster_col=FALSE)


LTLA/SingleR documentation built on Dec. 22, 2024, 5:10 p.m.