degColors: Make nice colors for metadata

Description Usage Arguments Examples

View source: R/genePlots.R

Description

The function will take a metadata table and use Set2 palette when number of levels is > 3 or a set or orange/blue colors other wise.

Usage

1
2
3
4
5
6
7
degColors(
  ann,
  col_fun = FALSE,
  con_values = c("grey80", "black"),
  cat_values = c("orange", "steelblue"),
  palette = "Set2"
)

Arguments

ann

Data.frame with metadata information. Each column will be used to generate a palette suitable for the values in there.

col_fun

Whether to return a function for continuous variables (compatible with ComplexHeatmap::HeatmapAnnotation()) or the colors themself (comparible with [pheatmap::pheatmap())]).

[pheatmap::pheatmap())]: R:pheatmap::pheatmap())

con_values

Color to be used for continuous variables.

cat_values

Color to be used for 2-levels categorical variables.

palette

Palette to use from brewer.pal() for multi-levels categorical variables.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(humanGender)
library(DESeq2)
library(ComplexHeatmap)
idx <- c(1:10, 75:85)
dse <- DESeqDataSetFromMatrix(assays(humanGender)[[1]][1:10, idx],
  colData(humanGender)[idx,], design=~group)
th <- HeatmapAnnotation(df = colData(dse),
                       col = degColors(colData(dse), TRUE))
Heatmap(log2(counts(dse)+0.5), top_annotation = th)

custom <- degColors(colData(dse), TRUE,
          con_values = c("white", "red"),
          cat_values = c("white", "black"),
          palette = "Set1")
th <- HeatmapAnnotation(df = colData(dse),
                        col = custom)
Heatmap(log2(counts(dse)+0.5), top_annotation = th)

DEGreport documentation built on Nov. 8, 2020, 7:23 p.m.