heatmaps: Heatmaps of NMF Factors

Description Usage Arguments Details Methods (by generic) References Examples

Description

The NMF package ships an advanced heatmap engine implemented by the function aheatmap. Some convenience heatmap functions have been implemented for NMF models, which redefine default values for some of the arguments of aheatmap, hence tuning the output specifically for NMF models.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
basismap(object, ...)

## S4 method for signature 'NMF'
basismap(
  object,
  color = "YlOrRd:50",
  scale = "r1",
  Rowv = TRUE,
  Colv = NA,
  subsetRow = FALSE,
  annRow = NA,
  annCol = NA,
  tracks = "basis",
  main = "Basis components",
  info = FALSE,
  ...
)

coefmap(object, ...)

## S4 method for signature 'NMF'
coefmap(
  object,
  color = "YlOrRd:50",
  scale = "c1",
  Rowv = NA,
  Colv = TRUE,
  annRow = NA,
  annCol = NA,
  tracks = "basis",
  main = "Mixture coefficients",
  info = FALSE,
  ...
)

consensusmap(object, ...)

## S4 method for signature 'NMFfitX'
consensusmap(
  object,
  annRow = NA,
  annCol = NA,
  tracks = c("basis:", "consensus:", "silhouette:"),
  main = "Consensus matrix",
  info = FALSE,
  ...
)

## S4 method for signature 'NMF'
consensusmap(object, ...)

## S4 method for signature 'matrix'
consensusmap(
  object,
  color = "-RdYlBu",
  distfun = function(x) as.dist(1 - x),
  hclustfun = "average",
  Rowv = TRUE,
  Colv = "Rowv",
  main = if (is.null(nr) || nr > 1) "Consensus matrix" else "Connectiviy matrix",
  info = FALSE,
  ...
)

## S4 method for signature 'NMFfitX'
basismap(object, ...)

## S4 method for signature 'NMFfitX'
coefmap(
  object,
  Colv = TRUE,
  annRow = NA,
  annCol = NA,
  tracks = c("basis", "consensus:"),
  ...
)

Arguments

object

an object from which is extracted NMF factors or a consensus matrix

...

extra arguments passed to aheatmap.

color

colour specification for the heatmap. Default to palette '-RdYlBu2:100', i.e. reversed palette 'RdYlBu2' (a slight modification of RColorBrewer's palette 'RdYlBu') with 100 colors. Possible values are:

  • a character/integer vector of length greater than 1 that is directly used and assumed to contain valid R color specifications.

  • a single color/integer (between 0 and 8)/other numeric value that gives the dominant colors. Numeric values are converted into a pallete by rev(sequential_hcl(2, h = x, l = c(50, 95))). Other values are concatenated with the grey colour '#F1F1F1'.

  • RColorBrewer palette names (see display.brewer.all)

  • viridis palette names: 'viridis', 'inferno', 'plasma', 'magma';

  • one of 'RdYlBu2', 'rainbow', 'heat', 'topo', 'terrain', 'cm'.

When the colour palette is specified with a single value, and is negative or preceded a minus ('-'), the reversed palette is used. The number of breaks can also be specified after a colon (':'). For example, the default colour palette is specified as '-RdYlBu2:100'.

scale

character indicating how the values should scaled in either the row direction or the column direction. Note that the scaling is performed after row/column clustering, so that it has no effect on the row/column ordering. Possible values are:

  • "row": center and standardize each row separately to row Z-scores

  • "stdrow": center and standardize each row separately to row Z-scores, and force values onto [0,1] inteval.

  • "column": center and standardize each column separately to column Z-scores

  • "stdcolumn": center and standardize each column separately to column Z-scores, and force values onto [0,1] inteval.

  • "r1": scale each row to sum up to one

  • "c1": scale each column to sum up to one

  • "none": no scaling

Rowv

clustering specification(s) for the rows. It allows to specify the distance/clustering/ordering/display parameters to be used for the rows only.

See section Row/column ordering and display for details on all supported values.

Colv

clustering specification(s) for the columns. It accepts the same values as argument Rowv (modulo the expected length for vector specifications), and allow specifying the distance/clustering/ordering/display parameters to be used for the columns only.

Colv may also be set to "Rowv", in which case the dendrogram or ordering specifications applied to the rows are also applied to the columns. Note that this is allowed only for square matrices, and that the row ordering is in this case by default reversed (revC=TRUE) to obtain the diagonal in the standard way (from top-left to bottom-right).

See section Row/column ordering and display for details on all supported values.

subsetRow

Argument that specifies how to filter the rows that will appear in the heatmap. When FALSE (default), all rows are used. Besides the values supported by argument subsetRow of aheatmap, other possible values are:

  • TRUE: only the rows that are basis-specific are used. The default selection method is from Kim and Park (2007). This is equivalent to subsetRow='kim'.

  • a single character string or numeric value that specifies the method to use to select the basis-specific rows, that should appear in the heatmap (cf. argument method for function extractFeatures).

    Note extractFeatures is called with argument nodups=TRUE, so that features that are selected for multiple components only appear once.

annRow

specifications of row annotation tracks displayed as coloured columns on the left of the heatmaps. The annotation tracks are drawn from left to right. The same conversion, renaming and colouring rules as for argument annCol apply.

annCol

specifications of column annotation tracks displayed as coloured rows on top of the heatmaps. The annotation tracks are drawn from bottom to top. A single annotation track can be specified as a single vector; multiple tracks are specified as a list, a data frame, or an ExpressionSet object, in which case the phenotypic data is used (pData(eset)). Character or integer vectors are converted and displayed as factors. Unnamed tracks are internally renamed into Xi, with i being incremented for each unamed track, across both column and row annotation tracks. For each track, if no corresponding colour is specified in argument annColors, a palette or a ramp is automatically computed and named after the track's name.

tracks

Special additional annotation tracks to highlight associations between basis components and sample clusters:

basis

matches each row (resp. column) to the most contributing basis component in basismap (resp. coefmap). In basismap (resp. coefmap), adding a track ':basis' to annCol (resp. annRow) makes the column (resp. row) corresponding to the component being also highlited using the mathcing colours.

main

Main title as a character string or a grob.

info

if TRUE then the name of the algorithm that fitted the NMF model is displayed at the bottom of the plot, if available. Other wise it is passed as is to aheatmap.

distfun

default distance measure used in clustering rows and columns. Possible values are:

  • all the distance methods supported by dist (e.g. "euclidean" or "maximum").

  • all correlation methods supported by cor, such as "pearson" or "spearman". The pairwise distances between rows/columns are then computed as d <- dist(1 - cor(..., method = distfun)).

    One may as well use the string "correlation" which is an alias for "pearson".

  • an object of class dist such as returned by dist or as.dist.

hclustfun

default clustering method used to cluster rows and columns. Possible values are:

  • a method name (a character string) supported by hclust (e.g. 'average').

  • an object of class hclust such as returned by hclust

  • a dendrogram

Details

IMPORTANT: although they essentially have the same set of arguments, their order sometimes differ between them, as well as from aheatmap. We therefore strongly recommend to use fully named arguments when calling these functions.

basimap default values for the following arguments of aheatmap:

coefmap redefines default values for the following arguments of aheatmap:

consensusmap redefines default values for the following arguments of aheatmap:

Methods (by generic)

basismap:

coefmap:

consensusmap:

References

Kim H, Park H (2007). “Sparse non-negative matrix factorizations via alternating non-negativity-constrained least squares for microarray data analysis.” _Bioinformatics (Oxford, England)_, *23*(12), 1495-502. ISSN 1460-2059, doi: 10.1093/bioinformatics/btm134 (URL: https://doi.org/10.1093/bioinformatics/btm134).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
## More examples are provided in demo `heatmaps`
## Not run: 
demo(heatmaps)

## End(Not run)
##

# random data with underlying NMF model
v <- syntheticNMF(20, 3, 10)
# estimate a model
x <- nmf(v, 3)


# show basis matrix
basismap(x)
## Not run: 
# without the default annotation tracks
basismap(x, tracks=NA)

## End(Not run)


# coefficient matrix
coefmap(x)
## Not run: 
# without the default annotation tracks
coefmap(x, tracks=NA)

## End(Not run)


## Not run: 
res <- nmf(x, 3, nrun=3)
consensusmap(res)

## End(Not run)

renozao/NMF documentation built on June 14, 2020, 9:35 p.m.