Skip to contents

The purpose of this function is to auto-handle outliers in the numerical vectors, because outliers compress the color mapping and make it difficult to distinguish among the values of non-outliers.Here are the ways to achieve that goal in this function if outliers are present:

  1. only non-outliers are used in color-value mapping.

  2. a '<' or '>' sign is prefixed to the first or last tick labels.

Usage

setColMapAndLegend(
  vec,
  colMap = NULL,
  whiteValue = NA,
  intAsDiscreteCutoff = 6,
  rmLegendOutliers = T,
  isAnnotation = F,
  legendTicks = NULL,
  legendTickLabels = NULL
)

Arguments

vec

numerical; a vector or matrix

colMap

a named numerical vector for the color mapping,NULL; if colMap is not provided, the names of colMap is set as the followings: * if isAnnotation, c('white',x) where x is a random color from getDistinctColors. * otherwise, c('green4', 'white', 'red').

whiteValue

Numeric, NA; it is the value of the white or middle color in the legend if colMap consists of three colors representing, e.g. up, no change, down, etc.

intAsDiscreteCutoff

integer, 6; if mat1 is an integer matrix and has < 6 unique values, the color mapping in the legend will be discrete.

rmLegendOutliers

logical, TRUE; If colMap is not provided, if FALSE, the range of legend ticks covers all values of vac if TRUE, the range of legend ticks covers only non-outliers

isAnnotation

logical, FALSE; if TRUE, the legend is for the annotation of a heatmap, not for heatmap itself;

legendTicks

numerical vector, NULL;

legendTickLabels

character vector, NULL;

Value

a list of following items

  1. colmap: the completed colMap

  2. legendParas: list(at = legendTicks,labels = legendTickLabels). it may also contains legend_gp if vec is discrete integers; passed to ComplexHeatmap::HeatmapAnnotation(annotation_legend_param)

  3. newVals: infinite values in vec, if present, are set to NA

  4. isDiscrete: is vec discrete?

Examples

# none