Learn R Programming

NMF (version 0.2.2)

heatmap-NMF: Heatmaps of NMF Factors

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

basismap(object, ...)

## S3 method for class '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, ...)

## S3 method for class '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, ...)

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

## S3 method for class '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, ...)

## S3 method for class '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.
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 aheatma
tracks
Special additional annotation tracks to highlight associations between basis components and sample clusters: [object Object]
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.
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
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:
    Rowv
    clustering specification(s) for the rows. It allows to specify the distance/clustering/ordering/display parameters to be used for the rows only. Possible values are:
    • TRUEorNULL(to be consistent with
    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
    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 lis
    main
    Main title as a character string or a grob.
    distfun
    default distance measure used in clustering rows and columns. Possible values are:
    • all the distance methods supported bydist(e.g. "euclidean" or "maximum").
    • all correlation methods supporte
    hclustfun
    default clustering method used to cluster rows and columns. Possible values are:
    • a method name (a character string) supported byhclust(e.g.'average').
    • an object of class

    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:

    • the color palette;
    • the scaling specification, which by default scales each row separately so that they sum up to one (scale='r1');
    • the column ordering which is disabled;
    • allowing for passing feature extraction methods in argumentsubsetRow, that are passed toextractFeatures. See argument description here and therein.
    • the addition of a default named annotation track, that shows the dominant basis component for each row (i.e. each feature).

    This track is specified in argumenttracks(see its argument description). By default, a matching column annotation track is also displayed, but may be disabled usingtracks=':basis'.

  • a suitable title and extra information like the fitting algorithm, whenobjectis a fitted NMF model.
  • coefmap redefines default values for the following arguments of aheatmap:

    • the color palette;
    • the scaling specification, which by default scales each column separately so that they sum up to one (scale='c1');
    • the row ordering which is disabled;
    • the addition of a default annotation track, that shows the most contributing basis component for each column (i.e. each sample).

    This track is specified in argumenttracks(see its argument description). By default, a matching row annotation track is also displayed, but can be disabled usingtracks='basis:'.

  • a suitable title and extra information like the fitting algorithm, whenobjectis a fitted NMF model.
  • consensusmap redefines default values for the following arguments of aheatmap:

    • the colour palette;
    • the column ordering which is set equal to the row ordering, since a consensus matrix is symmetric;
    • the distance and linkage methods used to order the rows (and columns). The default is to use 1 minus the consensus matrix itself as distance, and average linkage.
    • the addition of two special named annotation tracks,'basis:'and'consensus:', that show, for each column (i.e. each sample), the dominant basis component in the best fit and the hierarchical clustering of the consensus matrix respectively (using 1-consensus as distance and average linkage).

    These tracks are specified in argumenttracks, which behaves as inbasismap.

  • a suitable title and extra information like the type of NMF model or the fitting algorithm, whenobjectis a fitted NMF model.
  • Examples

    Run this code
    # roxygen generated flag
    options(R_CHECK_RUNNING_EXAMPLES_=TRUE)
    
    #----------
    # heatmap-NMF
    #----------
    ## More examples are provided in demo `heatmaps`
    demo(heatmaps)
    ##
    
    # random data with underlying NMF model
    v <- syntheticNMF(20, 3, 10)
    # estimate a model
    x <- nmf(v, 3)
    
    #----------
    # basismap
    #----------
    # show basis matrix
    basismap(x)
    # without the default annotation tracks
    basismap(x, tracks=NA)
    
    #----------
    # coefmap
    #----------
    # coefficient matrix
    coefmap(x)
    # without the default annotation tracks
    coefmap(x, tracks=NA)
    
    #----------
    # consensusmap
    #----------
    res <- nmf(x, 3, nrun=3)
    consensusmap(res)

    Run the code above in your browser using DataLab