Learn R Programming

WHeatmap

WHeatmap designs a set of languages and a layer system that allows arbitrary positioning of heatmaps programmatically.

It makes plotting complex heatmaps using plain English such as TopOf, RightOf and BottomLeftOf etc.

To install from github using devtools,

library(devtools)
install_github('zwdzwd/wheatmap')

library(wheatmap)

For example, the following complex layout

can be generated simply by

WHeatmap(matrix(1:12,nrow=2), cmp=CMPar(brewer.name='Greens'), name='a') + 
  WHeatmap(matrix(1:6,nrow=1), Beneath(pad=0.05), cmp=CMPar(brewer.name='Set2'), name='b') +
  WHeatmap(matrix(c(1:30,30:1),nrow=5), Beneath(pad=0.05), 'c', cmp=CMPar(cmap='jet')) +
  WHeatmap(matrix(1:24,nrow=4), RightOf('c'), 'd', cmp=CMPar(brewer.name='Set1')) +
  WLegendV('c', LeftOf('c', pad=0.01), yticklabel.side='l') +
  WLegendV('b', RightOf('b', width=0.1)) + 
  WLegendV('a', RightOf('a')) + 
  WHeatmap(matrix(1:100, nrow=10), RightOf('d'), cmp=CMPar(brewer.name='RdYlGn')) +
  WColorBarH(matrix(5:1), TopOf(), cmp=CMPar(colorspace.name = 'diverge_hcl')) +
  WColorBarH(matrix(50:1), TopOf(), cmp=CMPar(colorspace.name = 'terrain_hcl')) +
  WColorBarH(matrix(1:8), TopOf(), cmp=CMPar(colorspace.name = 'sequential_hcl')) +
  WColorBarH(matrix(1:8), TopOf(), cmp=CMPar(brewer.name = 'YlOrRd'))

One who is really obssessed with %>% can do something like

library(magrittr)
WHeatmap(cc$mat, name='h1') %>% add(WColorBarV(row.data, LeftOf('h1'), 'c1'))

The layout looks like

In order to cross-refer panels in the plot, one has to use a unique name. This name can be given through the name= option and user has to make sure the uniqueness of the names from existing objects in the plot. If not specified, wheatmap can generate a unique name and that name is visible from ly() function. A special NULL tag can be used to refer to the last plotted object.

More User guides:

Acknowledgement

  • The internal grid.dendrogram() function is adapted from ComplexHeatmap package.

Copy Link

Version

Install

install.packages('wheatmap')

Monthly Downloads

877

Version

0.2.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Wanding Zhou

Last Published

February 27th, 2022

Functions in wheatmap (0.2.0)

CMPar

Color Map Parameters
FromAffine

Convert from affine coordinates to absolute coordinates
ColorMap

Constructor for ColoMap object
CalcTextBounding.WHeatmap

Calculate Texting Bounding for WHeatmap
TopOf

Top of
TopLeftOf

Top left of
GroupCheckNameUnique

Check whether group names are unique
WColumnBind

column bind non-overlapping objects
WColorBarV

WColorBarV
CalcTextBounding

Calculate Text Bounding
both.cluster

row- and column-cluster a matrix
WGroup

Construct a WGroup
WRowBind

row bind non-overlapping objects
WGrob

WGrob object plot from a gList of grob objects
WLegendV

WLegendV
WLegendH

WLegendH
BottomLeftOf

Bottom left of
getdim

Get dimensions
LeftOf

LeftOf
GroupDeepGet

Get an plotting object from a group's descendants
MapToContinuousColors

map data to continuous color
MapToDiscreteColors

map data to discrete color
WColorBarH

WColorBarH
TopRightOf

Top right of
WHeatmap

WHeatmap object
WDim

class WDim
BottomRightOf

Bottom right of
WGG

WGG object form ggplot with coordinates
ToAffine

Convert from absolute coordinates to affine coordinates
ScaleGroup

Scale group
[.WGroup

subset WGroup
grid.dendrogram

Draw dendrogram under grid system
WPosition

place an arbitrary position w.r.t a subplot
print.WGG

plot WGG object
+.WObject

merge plotting objects
print.WGrob

plot WGrob object
WRect

construct a WRect
print.WDendrogram

print a dendrogram
WLabel

construct a WLabel
print.WRect

print WRect
column.cluster

column cluster a matrix
darkjet.stops

darker jet color stops
row.cluster

row cluster a matrix
print.WGenerator

print a WGenerator
print.WGroup

Draw WGroup
RightOf

RightOf
Beneath

Beneath
WDendrogram

WDendrogram class
AddWGroup

Add a plotting object to a group
Resolve

Resolve name to object
WCustomize

Customize an existing plot
jet.stops

jet color stops
WMatrix

plot multiple figures in a matrix
WObject

Construct a WObject
ly

show layout
print.WLabel

print WLabel
print.WHeatmap

plot WHeatmap