plotDiffHeatmap {CATALYST} | R Documentation

## Plot differential heatmap

### Description

Heatmaps summarizing differental abundance & differential state testing results.

### Usage

    plotDiffHeatmap(
      x,
      y,
      k = NULL,
      top_n = 20,
      fdr = 0.05,
      lfc = 1,
      all = FALSE,
      sort_by = c("padj", "lfc", "none"),
      y_cols = list(padj = "p_adj", lfc = "logFC", target = "marker_id"),
      assay = "exprs",
      fun = c("median", "mean", "sum"),
      normalize = TRUE,
      col_anno = TRUE,
      row_anno = TRUE,
      hm_pal = NULL,
      fdr_pal = c("lightgrey", "lightgreen"),
      lfc_pal = c("blue3", "white", "red3")
    )

### Arguments

`x` | a `SingleCellExperiment`.
`y` | a `SummarizedExperiment` containing differential testing results as returned by one of `testDA_edgeR`, `testDA_voom`, `testDA_GLMM`, `testDS_limma`, or `testDS_LMM`. Alternatively, a list as returned by `diffcyt`.
`k` | character string specifying the clustering in `x` from which `y` was obtained. If NULL, `plotDiffHeatmap` will try and guess it, which will be inaccurate if multiple clusterings share the same levels.
`top_n` | numeric. Number of top clusters (if `type = "DA"`) or cluster-marker combinations (if `type = "DS"`) to display.
`fdr` | numeric threshold on adjusted p-values below which results should be retained and considered to be significant.
`lfc` | numeric threshold on logFCs above which to retain results.
`all` | logical specifying whether all `top_n` results should be displayed. If `TRUE`, `fdr,lfc` filtering is skipped.
`sort_by` | character string specifying the `y` column to sort by; `"none"` to retain original ordering. Adj. p-values will increase, logFCs will decreasing from top to bottom.
`y_cols` | named list specifying columns in `y` that contain adjusted p-values (`padj`), logFCs (`lfc`) and, for DS results, feature names (`target`). When only some `y_cols` differ from the defaults, specifying only these is sufficient.
`assay` | character string specifying which assay data to use; valid values are `assayNames(x)`.
`fun` | character string specifying the function to use as summary statistic for aggregation of `assay` data.
`normalize` | logical specifying whether Z-score normalized values should be plotted. If `y` contains DA analysis results, frequencies will be arcsine-square-root scaled prior to normalization.
`col_anno` | logical specifying whether to include column annotations for all non-numeric cell metadata variables; or a character vector in `names(colData(x))` to include only a subset of annotations. (Only variables that map uniquely to each sample will be included)
`row_anno` | logical specifying whether to include a row annotation indicating whether cluster (DA) or cluster-marker combinations (DS) are significant, labeled with adjusted p-values, as well as logFCs.
`hm_pal` | character vector of colors to interpolate for the heatmap. Defaults to `brewer.pal`'s `"RdYlBu"` for DS, `"RdBu"` for DA results heatmaps.
`fdr_pal, lfc_pal` | character vector of colors to use for row annotations `fdr_pal`length 2 for (non-)significant at given `fdr` `lfc_pal`length 3 for negative, zero and positive

### Value

a `Heatmap-class` object.

### Author(s)

Lukas M Weber & Helena L Crowell helena.crowell@uzh.ch

### Examples

    # construct SCE & run clustering
    data(PBMC_fs, PBMC_panel, PBMC_md)
    sce <- prepData(PBMC_fs, PBMC_panel, PBMC_md)
    sce <- cluster(sce)

    ## differential analysis
    library(diffcyt)

    # create design & constrast matrix
    design <- createDesignMatrix(PBMC_md, cols_design=3:4)
    contrast <- createContrast(c(0, 1, 0, 0, 0))

    # test for
    # - differential abundance (DA) of clusters
    # - differential states (DS) within clusters

    da <- diffcyt(sce, design = design, contrast = contrast,
        analysis_type = "DA", method_DA = "diffcyt-DA-edgeR",
        clustering_to_use = "meta20")

    ds <- diffcyt(sce, design = design, contrast = contrast,
        analysis_type = "DS", method_DS = "diffcyt-DS-limma",
        clustering_to_use = "meta20")

    # extract result tables
    da <- rowData(da$res)
    ds <- rowData(ds$res)

    # display test results for
    # - top DA clusters
    # - top DS cluster-marker combinations
    plotDiffHeatmap(sce, da)
    plotDiffHeatmap(sce, ds)

    # visualize results for subset of clusters
    sub <- filterSCE(sce, cluster_id %in% seq_len(5), k = "meta20")
    plotDiffHeatmap(sub, da, all = TRUE, sort_by = "none")

    # visualize results for selected feature
    # & include only selected annotation
    plotDiffHeatmap(sce["pp38", ], ds, col_anno = "condition", all = TRUE)

[Package CATALYST version 1.16.2 Index]