Skip to contents

Applies the variance stabilizing transformation (VST) to a DESeqDataSet, removes genes with zero variance, converts each gene to Z-scores across samples and orders the columns.

Usage

get_heatmap_mat(dds_object, sample_order = colnames(dds_object))

Arguments

dds_object

A DESeqDataSet (for example, the samples of a single cell type).

sample_order

Character vector with the sample IDs in the order in which the columns should appear. By default, the order of dds_object.

Value

A numeric matrix of Z-scores (genes in rows, samples in columns).

Details

Requires the Bioconductor packages DESeq2 and SummarizedExperiment.

Examples

if (requireNamespace("DESeq2", quietly = TRUE)) {
  # small simulated DESeqDataSet: 1,200 genes x 6 samples
  # (with the lesson data: dds <- download_data("dds"))
  set.seed(1)
  counts <- matrix(rnbinom(1200 * 6, mu = 100, size = 10), ncol = 6,
                   dimnames = list(paste0("gene", 1:1200), paste0("S", 1:6)))
  col_data <- data.frame(Group = factor(rep(c("Ctrl", "SLE"), each = 3)),
                         row.names = colnames(counts))
  sim_dds <- DESeq2::DESeqDataSetFromMatrix(counts, col_data, design = ~ Group)
  sim_mat <- get_heatmap_mat(sim_dds)
  dim(sim_mat)
}
#> converting counts to integer mode
#> [1] 1200    6