Title: | Incrementally Build Complex Plots using Natural Semantics |
---|---|
Description: | Builds complex plots, heatmaps in particular, using natural semantics. Bigger plots can be assembled using directives such as 'LeftOf', 'RightOf', 'TopOf', and 'Beneath' and more. Other features include clustering, dendrograms and integration with 'ggplot2' generated grid objects. This package is particularly designed for bioinformaticians to assemble complex plots for publication. |
Authors: | Wanding Zhou [aut, cre] |
Maintainer: | Wanding Zhou <[email protected]> |
License: | GPL-3 |
Version: | 0.2.0 |
Built: | 2024-11-03 03:34:44 UTC |
Source: | https://github.com/zwdzwd/wheatmap |
subset WGroup
## S3 method for class 'WGroup' x[i]
## S3 method for class 'WGroup' x[i]
x |
a WGroup object |
i |
integer indexing element |
a subset of WGroup or NULL
merge plotting objects
## S3 method for class 'WObject' group + p
## S3 method for class 'WObject' group + p
group |
a WGroup or a plotting object |
p |
a new plotting object |
a WGroup
The object to be added are in the same coordinate system as the group.
AddWGroup(group.obj, new.obj)
AddWGroup(group.obj, new.obj)
group.obj |
WGroup object to be added to |
new.obj |
plotting object to be added |
a WGroup object where new.obj is added.
Generate dimension beneath another object
Beneath( x = NULL, height = NULL, pad = 0.01, min.ratio = 0.02, h.aln = NULL, v.scale = NULL, v.scale.proportional = FALSE )
Beneath( x = NULL, height = NULL, pad = 0.01, min.ratio = 0.02, h.aln = NULL, v.scale = NULL, v.scale.proportional = FALSE )
x |
an object with dimension |
height |
the height of the new object (when NULL set proportional to the data) |
pad |
padding between the target and current |
min.ratio |
minimum ratio of dimensions when auto-scale |
h.aln |
object for horizontal alignment (when NULL, set to x) |
v.scale |
object for vertical scaling (when NULL, set to x) |
v.scale.proportional |
when v.scale is provided, whether to make proportional to data |
a dimension generator beneath x
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarH(1:20, cmp=CMPar(), continuous=FALSE, Beneath())
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarH(1:20, cmp=CMPar(), continuous=FALSE, Beneath())
row- and column-cluster a matrix
both.cluster( mat, extra.row = NULL, extra.column = NULL, hc.method = "ward.D2", dist.method = "euclidean" )
both.cluster( mat, extra.row = NULL, extra.column = NULL, hc.method = "ward.D2", dist.method = "euclidean" )
mat |
input matrix |
extra.row |
extra row reordering |
extra.column |
extra column reordering |
hc.method |
method to use in hclust |
dist.method |
method to use in dist |
a list of clustered row, column and matrix
WHeatmap(both.cluster(matrix(rnorm(100),nrow=10))$mat)
WHeatmap(both.cluster(matrix(rnorm(100),nrow=10))$mat)
Place a new object to the bottom left corner of another.
BottomLeftOf(x = NULL, just = c("right", "bottom"), v.pad = 0, h.pad = 0)
BottomLeftOf(x = NULL, just = c("right", "bottom"), v.pad = 0, h.pad = 0)
x |
target object, either a name, a object or NULL which refers to the last plotting object |
just |
the part from the new object that should be attached to |
v.pad |
vertical translational padding [0.0] |
h.pad |
horizontal translational padding [0.0] |
a WDimGenerator
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomLeftOf(just=c('right','top'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomLeftOf(just=c('right','bottom'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomLeftOf(just=c('left','bottom')))
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomLeftOf(just=c('right','top'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomLeftOf(just=c('right','bottom'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomLeftOf(just=c('left','bottom')))
Place a new object to the bottom right corner of another.
BottomRightOf(x = NULL, just = c("left", "bottom"), v.pad = 0, h.pad = 0)
BottomRightOf(x = NULL, just = c("left", "bottom"), v.pad = 0, h.pad = 0)
x |
target object, either a name, a object or NULL which refers to the last plotting object |
just |
the part from the new object that should be attached to |
v.pad |
vertical translational padding [0.0] |
h.pad |
horizontal translational padding [0.0] |
a WDimGenerator
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomRightOf(just=c('left','top'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomRightOf(just=c('left','bottom'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomRightOf(just=c('right','bottom')))
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomRightOf(just=c('left','top'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomRightOf(just=c('left','bottom'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), BottomRightOf(just=c('right','bottom')))
Calculate bounding box including texts.
CalcTextBounding(x, ...)
CalcTextBounding(x, ...)
x |
object |
... |
extra options |
W.R.T lower left corner of the view port in the unit of points
Calculate Texting Bounding for WHeatmap
## S3 method for class 'WHeatmap' CalcTextBounding(hm, group)
## S3 method for class 'WHeatmap' CalcTextBounding(hm, group)
hm |
an object of class WHeatmap |
group |
an object of class WGroup |
an object of class WDim in coordinate points
Create color map parameters
CMPar( dmin = NULL, dmax = NULL, brewer.name = NULL, brewer.n = 3, colorspace.name = NULL, colorspace.n = 2, cmap = NULL, label2color = NULL, use.data = FALSE, stop.points = NULL, na.color = "#C0C0C0", rev = FALSE, grey.scale = FALSE )
CMPar( dmin = NULL, dmax = NULL, brewer.name = NULL, brewer.n = 3, colorspace.name = NULL, colorspace.n = 2, cmap = NULL, label2color = NULL, use.data = FALSE, stop.points = NULL, na.color = "#C0C0C0", rev = FALSE, grey.scale = FALSE )
dmin |
minimum for continuous color map |
dmax |
maximum for continuous color map |
brewer.name |
palette name for RColorbrewer |
brewer.n |
number of stop points in RColorBrewer for continuous color map |
colorspace.name |
colorspace name |
colorspace.n |
number of stops in colorspace palettes |
cmap |
customized colormap name |
label2color |
a named vector or list that defines label to color mapping explicitly for discrete color mapping |
use.data |
use data as color, data must be either common color names or hexdecimal color names |
stop.points |
custome stop points |
na.color |
color for NA |
rev |
reverse stop points |
grey.scale |
whether to use grey scale |
an object of class CMPar
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarV(1:20, cmp=CMPar(brewer.name = 'RdBu'), RightOf())
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarV(1:20, cmp=CMPar(brewer.name = 'RdBu'), RightOf())
Create color maps
ColorMap( continuous = TRUE, colors = NULL, dmin = NULL, dmax = NULL, scaler = NULL, mapper = NULL )
ColorMap( continuous = TRUE, colors = NULL, dmin = NULL, dmax = NULL, scaler = NULL, mapper = NULL )
continuous |
whether colormap is continuous |
colors |
colors for each data point |
dmin |
miminum in continuous color map |
dmax |
maximum in continuous color map |
scaler |
scaler function from data range to 0-1 |
mapper |
function that maps data to color |
an object of class ColorMap
column cluster a matrix
column.cluster(mat, ..., hc.method = "ward.D2", dist.method = "euclidean")
column.cluster(mat, ..., hc.method = "ward.D2", dist.method = "euclidean")
mat |
input matrix |
... |
extra color bars or matrix that needs column reordered |
hc.method |
method to use in hclust |
dist.method |
method to use in dist |
a list of clustered row, column and matrix
WHeatmap(column.cluster(matrix(rnorm(100),nrow=10))$mat)
WHeatmap(column.cluster(matrix(rnorm(100),nrow=10))$mat)
darker jet color stops
darkjet.stops
darkjet.stops
An object of class character
of length 6.
Convert from affine coordinates to absolute coordinates
FromAffine(dm.affine, dm.sys)
FromAffine(dm.affine, dm.sys)
dm.affine |
dimension on affine coordinates (relative coordinates) |
dm.sys |
dimension of the affine system |
dimension on the same coordinate system
Get dimensions
getdim(x)
getdim(x)
x |
WDim object or a plotting object |
vector of dimensions
The dendrogram can be renderred. A viewport is created which contains the dendrogram.
grid.dendrogram( dend, facing = c("bottom", "top", "left", "right"), max_height = NULL, order = c("normal", "reverse"), ... )
grid.dendrogram( dend, facing = c("bottom", "top", "left", "right"), max_height = NULL, order = c("normal", "reverse"), ... )
dend |
a stats::dendrogram object. |
facing |
facing of the dendrogram. |
max_height |
maximum height of the dendrogram. |
order |
order |
... |
additional options |
-order should leaves of dendrogram be put in the normal order (1, ..., n) or reverse order (n, ..., 1)? -... pass to 'grid::viewport' which contains the dendrogram.
This function only plots the dendrogram without adding labels. The leaves of the dendrogram locates at unit(c(0.5, 1.5, ...(n-0.5))/n, "npc").
view port that plots dendrogram
Check whether group names are unique
GroupCheckNameUnique(group.obj)
GroupCheckNameUnique(group.obj)
group.obj |
a WGroup |
TRUE or FALSE
Get an plotting object from a group's descendants
GroupDeepGet(x, nm, force.unique = TRUE)
GroupDeepGet(x, nm, force.unique = TRUE)
x |
a WGroup object |
nm |
name |
force.unique |
assume the name is unique in the descendants and get one object instead of a list |
if 'force.unique==FALSE' return a list. Otherwise, one plotting object.
jet color stops
jet.stops
jet.stops
An object of class character
of length 75.
Generate dimension to the left of another object
LeftOf( x = NULL, width = NULL, pad = 0.01, min.ratio = 0.02, v.aln = NULL, h.scale = NULL, h.scale.proportional = FALSE )
LeftOf( x = NULL, width = NULL, pad = 0.01, min.ratio = 0.02, v.aln = NULL, h.scale = NULL, h.scale.proportional = FALSE )
x |
an object with dimension |
width |
the width of the new object (when NULL, set proportional to data) |
pad |
padding between the target and current |
min.ratio |
minimum ratio of dimensions when auto-scale |
v.aln |
object for vertical alignment (when NULL, set to x) |
h.scale |
object for horizontal scaling (when NULL, set to x) |
h.scale.proportional |
when h.scale is provided, whether to make proportional to data |
a dimension to the left of x
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarV(1:20, cmp=CMPar(), continuous=FALSE, LeftOf())
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarV(1:20, cmp=CMPar(), continuous=FALSE, LeftOf())
show layout
ly(x)
ly(x)
x |
plot |
ly( WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(rnorm(2000),nrow=40), cmp=CMPar(brewer.name = 'RdBu'), BottomRightOf(just=c('left','top'))))
ly( WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(rnorm(2000),nrow=40), cmp=CMPar(brewer.name = 'RdBu'), BottomRightOf(just=c('left','top'))))
map data to continuous color
MapToContinuousColors(data, cmp = CMPar(), given.cm = NULL)
MapToContinuousColors(data, cmp = CMPar(), given.cm = NULL)
data |
numeric vector |
cmp |
an color map parameter object of class CMPar |
given.cm |
given colormap |
an object of ColorMap
barplot(1:10, col=MapToContinuousColors(1:10)$colors) barplot(1:20, col=MapToContinuousColors(c(1:10,10:1))$colors)
barplot(1:10, col=MapToContinuousColors(1:10)$colors) barplot(1:20, col=MapToContinuousColors(c(1:10,10:1))$colors)
map data to discrete color
MapToDiscreteColors(data, cmp = CMPar(), given.cm = NULL)
MapToDiscreteColors(data, cmp = CMPar(), given.cm = NULL)
data |
numeric vector |
cmp |
an color map parameter object of class CMPar |
given.cm |
given color map |
an object of ColorMap
pie(rep(1,6), col=MapToDiscreteColors(c(1:3,10:13))$colors)
pie(rep(1,6), col=MapToDiscreteColors(c(1:3,10:13))$colors)
print a dendrogram
## S3 method for class 'WDendrogram' print(x, stand.alone = TRUE, layout.only = FALSE, cex = 1, ...)
## S3 method for class 'WDendrogram' print(x, stand.alone = TRUE, layout.only = FALSE, cex = 1, ...)
x |
a dendrogram |
stand.alone |
plot is stand alone |
layout.only |
plot layout only |
cex |
factor to scaling texts |
... |
additional options (ignored) |
view port that contains the plotted dendrogram
WDendrogram(column.cluster(matrix(1:24,nrow=4))$column.clust)
WDendrogram(column.cluster(matrix(1:24,nrow=4))$column.clust)
This calls WGenerator and creates a WGroup to enclose the produced object.
## S3 method for class 'WGenerator' print(x, ...)
## S3 method for class 'WGenerator' print(x, ...)
x |
a WGenerator object |
... |
additional options |
the WGroup containing the plotting object
plot WGG object
## S3 method for class 'WGG' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
## S3 method for class 'WGG' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
x |
WGG |
cex |
scaling factor for text |
layout.only |
plot layout |
stand.alone |
produce a stand.alone plot |
... |
extra options |
printed ggobj object
plot WGrob object
## S3 method for class 'WGrob' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
## S3 method for class 'WGrob' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
x |
WGrob |
cex |
scaling factor for text |
layout.only |
plot layout |
stand.alone |
produce a stand.alone plot |
... |
extra options |
Draw WGroup
## S3 method for class 'WGroup' print(x, stand.alone = TRUE, cex = 1, layout.only = FALSE, ...)
## S3 method for class 'WGroup' print(x, stand.alone = TRUE, cex = 1, layout.only = FALSE, ...)
x |
a WGroup |
stand.alone |
to plot stand alone |
cex |
factor for scaling fonts |
layout.only |
to plot layout only |
... |
additional options |
plot WHeatmap
## S3 method for class 'WHeatmap' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
## S3 method for class 'WHeatmap' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
x |
a WHeatmap |
cex |
factor to scaling texts |
layout.only |
plot layout only |
stand.alone |
plot is stand alone |
... |
additional options |
NULL
print(WHeatmap(matrix(1:12, nrow=2)))
print(WHeatmap(matrix(1:12, nrow=2)))
print WLabel
## S3 method for class 'WLabel' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
## S3 method for class 'WLabel' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
x |
a WLabel object |
cex |
factor to scale text |
layout.only |
plot layout only |
stand.alone |
plot label stand alone |
... |
additional options |
print(WLabel("This is a label."))
print(WLabel("This is a label."))
print WRect
## S3 method for class 'WRect' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
## S3 method for class 'WRect' print(x, cex = 1, layout.only = FALSE, stand.alone = TRUE, ...)
x |
a WRect object |
cex |
factor for scaling text |
layout.only |
print layout only |
stand.alone |
plot WRect standalone |
... |
additional options |
the WRect object
Resolve name to object
Resolve(x, ...)
Resolve(x, ...)
x |
the target |
... |
extra options |
Generate dimension to the right of another object
RightOf( x = NULL, width = NULL, pad = 0.01, min.ratio = 0.02, v.aln = NULL, h.scale = NULL, h.scale.proportional = FALSE )
RightOf( x = NULL, width = NULL, pad = 0.01, min.ratio = 0.02, v.aln = NULL, h.scale = NULL, h.scale.proportional = FALSE )
x |
an object with dimension |
width |
the width of the new object (when NULL, set proportional to data) |
pad |
padding between the target and current |
min.ratio |
minimum ratio of dimensions when auto-scale |
v.aln |
object for vertical alignment (when NULL, set to x) |
h.scale |
object for horizontal scaling (when NULL, set to x) |
h.scale.proportional |
when h.scale is provided, whether to make proportional to data |
a dimension to the right of x
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarV(1:20, cmp=CMPar(), continuous=FALSE, RightOf())
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarV(1:20, cmp=CMPar(), continuous=FALSE, RightOf())
row cluster a matrix
row.cluster(mat, ..., hc.method = "ward.D2", dist.method = "euclidean")
row.cluster(mat, ..., hc.method = "ward.D2", dist.method = "euclidean")
mat |
input matrix |
... |
extra color bars or matrix that needs row reordered. |
hc.method |
method to use in hclust |
dist.method |
method to use in dist |
a list of clustered row, column and matrix
WHeatmap(row.cluster(matrix(rnorm(100),nrow=10))$mat)
WHeatmap(row.cluster(matrix(rnorm(100),nrow=10))$mat)
Scale group to incorporate text on margins
ScaleGroup(group.obj)
ScaleGroup(group.obj)
group.obj |
group object that needs to be scaled |
scaled group obj
Convert from absolute coordinates to affine coordinates
ToAffine(dm, dm.sys)
ToAffine(dm, dm.sys)
dm |
dimension on the same coordinate system as the affine system (absolute coordinates) |
dm.sys |
dimension of the affine system |
dimension on affine coordinates (relative coordinates)
Place a new object to the top left corner of another.
TopLeftOf(x = NULL, just = c("right", "bottom"), v.pad = 0, h.pad = 0)
TopLeftOf(x = NULL, just = c("right", "bottom"), v.pad = 0, h.pad = 0)
x |
target object, either a name, a object or NULL which refers to the last plotting object |
just |
the part from the new object that should be attached to |
v.pad |
vertical translational padding [0.0] |
h.pad |
horizontal translational padding [0.0] |
a WDimGenerator
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopLeftOf(just=c('right','bottom'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopLeftOf(just=c('right','top'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopLeftOf(just=c('left','top')))
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopLeftOf(just=c('right','bottom'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopLeftOf(just=c('right','top'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopLeftOf(just=c('left','top')))
Generate dimension top of another object
TopOf( x = NULL, height = NULL, pad = 0.01, min.ratio = 0.02, h.aln = NULL, v.scale = NULL, v.scale.proportional = FALSE )
TopOf( x = NULL, height = NULL, pad = 0.01, min.ratio = 0.02, h.aln = NULL, v.scale = NULL, v.scale.proportional = FALSE )
x |
an object with dimension |
height |
the height of the new object (when NULL, set to proportional to data) |
pad |
padding between the target and current |
min.ratio |
minimum ratio of dimensions when auto-scale |
h.aln |
object for horizontal alignment (when NULL, set to x) |
v.scale |
object for vertical scaling (when NULL, set to x) |
v.scale.proportional |
when v.scale is provided, whether to make proportional to data |
a dimension generator on top of x
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarH(1:20, cmp=CMPar(), continuous=FALSE, TopOf())
WHeatmap(matrix(rnorm(2000),nrow=40)) + WColorBarH(1:20, cmp=CMPar(), continuous=FALSE, TopOf())
Place a new object to the top right corner of another.
TopRightOf(x = NULL, just = c("left", "bottom"), v.pad = 0, h.pad = 0)
TopRightOf(x = NULL, just = c("left", "bottom"), v.pad = 0, h.pad = 0)
x |
target object, either a name, a object or NULL which refers to the last plotting object |
just |
the part from the new object that should be attached to |
v.pad |
vertical translational padding [0.0] |
h.pad |
horizontal translational padding [0.0] |
a WDimGenerator
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopRightOf(just=c('left','bottom'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopRightOf(just=c('right','top'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopRightOf(just=c('left','top')))
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopRightOf(just=c('left','bottom'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopRightOf(just=c('right','top'))) WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), TopRightOf(just=c('left','top')))
a horizontal color bar
WColorBarH( data, ..., label = NULL, label.side = "r", label.fontsize = 12, label.pad = 0.005, label.space = 0.05, label.use.data = FALSE )
WColorBarH( data, ..., label = NULL, label.side = "r", label.fontsize = 12, label.pad = 0.005, label.space = 0.05, label.use.data = FALSE )
data |
numeric vector |
... |
additional options to WHeatmap |
label |
colorbar label |
label.side |
l (for left) or r (for right) |
label.fontsize |
label font size |
label.pad |
label padding |
label.space |
when label.use.data, the space between labels |
label.use.data |
use data to show legend in situ |
an object of class WColorBarH
WColorBarH(matrix(1:50))
WColorBarH(matrix(1:50))
a vertical color bar
WColorBarV( data, ..., label = NULL, label.side = "t", label.fontsize = 12, label.pad = 0.005, label.space = 0.05, label.use.data = FALSE )
WColorBarV( data, ..., label = NULL, label.side = "t", label.fontsize = 12, label.pad = 0.005, label.space = 0.05, label.use.data = FALSE )
data |
numeric vector |
... |
additional options to WHeatmap |
label |
colorbar label |
label.side |
t (for top) or b (for bottom) |
label.fontsize |
label font size |
label.pad |
label padding |
label.space |
when label.use.data, the space between labels |
label.use.data |
use data to show legend in situ |
an object of class WColorBarV
WColorBarV(matrix(50:1))
WColorBarV(matrix(50:1))
column bind non-overlapping objects
WColumnBind(..., nr = NULL, nc = NULL)
WColumnBind(..., nr = NULL, nc = NULL)
... |
plotting objects |
nr |
number of rows |
nc |
number of columns |
an object of class WDim
WHeatmap(matrix(rnorm(2000),nrow=40),name='a') + WHeatmap(matrix(rnorm(30), nrow=3), RightOf(),name='b') + WColorBarH(1:10, TopOf(WColumnBind('a','b')))
WHeatmap(matrix(rnorm(2000),nrow=40),name='a') + WHeatmap(matrix(rnorm(30), nrow=3), RightOf(),name='b') + WColorBarH(1:10, TopOf(WColumnBind('a','b')))
Customize an existing plot
WCustomize( mar.left = NULL, mar.right = NULL, mar.top = NULL, mar.bottom = NULL, mar = NULL )
WCustomize( mar.left = NULL, mar.right = NULL, mar.top = NULL, mar.bottom = NULL, mar = NULL )
mar.left |
left margin [0.03] |
mar.right |
right margin [0.03] |
mar.top |
top margin [0.03] |
mar.bottom |
bottom margin [0.03] |
mar |
margin in all directions [0.03] |
an object of class WCustomize
WHeatmap(matrix(c('fred','frank','brad', 'frank','fred','frank'), ncol=2)) + WLegendV(NULL, RightOf(), label.fontsize = 20) + WCustomize(mar.right=0.1)
WHeatmap(matrix(c('fred','frank','brad', 'frank','fred','frank'), ncol=2)) + WLegendV(NULL, RightOf(), label.fontsize = 20) + WCustomize(mar.right=0.1)
WDendrogram class
WDendrogram( clust = NULL, dm = WDim(0, 0, 1, 1), name = "", facing = c("bottom", "top", "left", "right") )
WDendrogram( clust = NULL, dm = WDim(0, 0, 1, 1), name = "", facing = c("bottom", "top", "left", "right") )
clust |
hclust object |
dm |
plotting dimension |
name |
name of the dendrogram plot |
facing |
direction of the dendrogram plot |
an object of class WDendrogram
WDendrogram(column.cluster(matrix(1:24,nrow=4))$column.clust)
WDendrogram(column.cluster(matrix(1:24,nrow=4))$column.clust)
class WDim
WDim( left = 0, bottom = 0, width = 1, height = 1, nr = 1, nc = 1, text.x = 0, text.y = 0, text.just = c("center", "center"), column.split = NULL, row.split = NULL )
WDim( left = 0, bottom = 0, width = 1, height = 1, nr = 1, nc = 1, text.x = 0, text.y = 0, text.just = c("center", "center"), column.split = NULL, row.split = NULL )
left |
left coordinate |
bottom |
bottom coordinate |
width |
width |
height |
height |
nr |
number of row |
nc |
number of column |
text.x |
x anchor for text |
text.y |
y anchor for text |
text.just |
just for text |
column.split |
a list of WDim objects for column split |
row.split |
a list of WDim objects for row split |
a WDim object
WGG object form ggplot with coordinates
WGG(ggobj, dm = NULL, name = "")
WGG(ggobj, dm = NULL, name = "")
ggobj |
ggplot plotting object |
dm |
dimension |
name |
name |
WGG object
WGrob object plot from a gList of grob objects
WGrob(glist, dm = NULL, name = "")
WGrob(glist, dm = NULL, name = "")
glist |
gList object |
dm |
dimension |
name |
name |
WGrob object
Construct a WGroup
WGroup( ..., name = "", group.dm = NULL, group.from.member = FALSE, mar = WMar(), affine = FALSE, nr = NULL, nc = NULL )
WGroup( ..., name = "", group.dm = NULL, group.from.member = FALSE, mar = WMar(), affine = FALSE, nr = NULL, nc = NULL )
... |
plotting objects to be grouped |
name |
name of the group |
group.dm |
group dimension, by default use the dm of the merge of members |
group.from.member |
group merged from member coordinates (require affine == FALSE), the supplied group.dm is ignored |
mar |
a WMar object |
affine |
whether the group members are on affine coordinates already |
nr |
number of rows |
nc |
number of columns |
a WGroup object
Create a heatmap
WHeatmap( data = NULL, dm = NULL, name = "", continuous = NULL, cmp = NULL, cm = NULL, xticklabels = NULL, xticklabels.n = NULL, xticklabel.side = "b", xticklabel.fontsize = 12, xticklabel.rotat = 90, xticklabel.pad = 0.005, xticklabel.space = 0.05, xticklabel.use.data = FALSE, yticklabels = NULL, yticklabels.n = NULL, yticklabel.side = "l", yticklabel.fontsize = 12, yticklabel.rotat = 0, yticklabel.pad = 0.005, yticklabel.space = 0.05, yticklabel.use.data = FALSE, sub.name = NULL, bbox = FALSE, gp = NULL )
WHeatmap( data = NULL, dm = NULL, name = "", continuous = NULL, cmp = NULL, cm = NULL, xticklabels = NULL, xticklabels.n = NULL, xticklabel.side = "b", xticklabel.fontsize = 12, xticklabel.rotat = 90, xticklabel.pad = 0.005, xticklabel.space = 0.05, xticklabel.use.data = FALSE, yticklabels = NULL, yticklabels.n = NULL, yticklabel.side = "l", yticklabel.fontsize = 12, yticklabel.rotat = 0, yticklabel.pad = 0.005, yticklabel.space = 0.05, yticklabel.use.data = FALSE, sub.name = NULL, bbox = FALSE, gp = NULL )
data |
data matrix |
dm |
plotting dimension (a WDim or a WDimGenerator object) |
name |
name of the plot |
continuous |
whether the data should be treated as continuous or discrete |
cmp |
a CMPar object, for tunning color mapping parameters |
cm |
a given color map |
xticklabels |
to plot xtick labels, one may supply characters to plot just a subset of xtick labels |
xticklabels.n |
number of xtick labels to plot (resample for aethetics by default) |
xticklabel.side |
xticklabel side (t or b) |
xticklabel.fontsize |
xticklabel font size |
xticklabel.rotat |
xticklabel rotation |
xticklabel.pad |
padding between xticklabel and x-axis |
xticklabel.space |
xticklabel space |
xticklabel.use.data |
use data to label x-axis (most likely used by colorbar) |
yticklabels |
to plot ytick labels, one may supply characters to plot just a subset of ytick labels |
yticklabels.n |
number of ytick labels to plot (resample for aethetics by default) |
yticklabel.side |
yticklabel side (l or r) |
yticklabel.fontsize |
yticklabel font size |
yticklabel.rotat |
yticklabel rotation |
yticklabel.pad |
padding between yticklabel and y-axis |
yticklabel.space |
yticklabel space |
yticklabel.use.data |
use data to label y-axis (most likely used by colorbar) |
sub.name |
subclass name |
bbox |
whether to plot the boundary box (useful with white matrix elements) |
gp |
a list of graphical parameters |
one or a list of heatmaps (depends on whether dimension is split)
WHeatmap(matrix(1:10, nrow=2), cmp=CMPar(brewer.name='Greens')) 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 could use %>% too, in combination with magrittr's add function ## Not run: library(magrittr) WColorBarH(1:10) %>% add(WColorBarV(rep(c('black','red','blue'),3), RightOf())) ## End(Not run)
WHeatmap(matrix(1:10, nrow=2), cmp=CMPar(brewer.name='Greens')) 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 could use %>% too, in combination with magrittr's add function ## Not run: library(magrittr) WColorBarH(1:10) %>% add(WColorBarV(rep(c('black','red','blue'),3), RightOf())) ## End(Not run)
construct a WLabel
WLabel( x = NULL, dm = WDim(), name = "", fontsize = 12, rot = 0, color = "black" )
WLabel( x = NULL, dm = WDim(), name = "", fontsize = 12, rot = 0, color = "black" )
x |
text to be labeled |
dm |
position |
name |
name |
fontsize |
font size |
rot |
rotation |
color |
color of the label |
a WLabel object
WHeatmap(matrix(rnorm(2000),nrow=40)) + WLabel("This is a label.", RightOf(), rot=-90)
WHeatmap(matrix(rnorm(2000),nrow=40)) + WLabel("This is a label.", RightOf(), rot=-90)
a horizontal legend
WLegendH( x = NULL, dm = NULL, name = "", n.stops = 20, n.text = 5, label.fontsize = 12, width = 0.02, height = 0.05, decreasing = TRUE, ... )
WLegendH( x = NULL, dm = NULL, name = "", n.stops = 20, n.text = 5, label.fontsize = 12, width = 0.02, height = 0.05, decreasing = TRUE, ... )
x |
a name or a plotting object, if NULL use the last plotting object |
dm |
position |
name |
name of the plotted legend |
n.stops |
number of stops in computing continuous legend |
n.text |
number of text labels in continuous legend |
label.fontsize |
label font size |
width |
width of each unit in plotted legend |
height |
height of each unit in plotted legend |
decreasing |
reversed color map |
... |
additional options to WHeatmap |
an object of class WLegendH
WHeatmap(matrix(1:4,nrow=2))+WLegendH(NULL, Beneath())
WHeatmap(matrix(1:4,nrow=2))+WLegendH(NULL, Beneath())
a vertical legend
WLegendV( x = NULL, dm = NULL, name = "", n.stops = 20, n.text = 5, label.fontsize = 12, width = 0.05, height = 0.02, decreasing = FALSE, ... )
WLegendV( x = NULL, dm = NULL, name = "", n.stops = 20, n.text = 5, label.fontsize = 12, width = 0.05, height = 0.02, decreasing = FALSE, ... )
x |
a name or a plotting object, if NULL use the last plotting object |
dm |
position |
name |
name of the plotted legend |
n.stops |
number of stops in computing continuous legend |
n.text |
number of text labels in continuous legend |
label.fontsize |
label font size |
width |
width of each unit in plotted legend |
height |
height of each unit in plotted legend |
decreasing |
reversed color map |
... |
additional options to WHeatmap |
an object of class WLegendV
WHeatmap(matrix(1:4,nrow=2))+WLegendV(NULL, RightOf())
WHeatmap(matrix(1:4,nrow=2))+WLegendV(NULL, RightOf())
This function can take WObject, or gg (from ggplot) since the coordinates are not set, gg can be converted to WGG
WMatrix(objs, ncols = 1)
WMatrix(objs, ncols = 1)
objs |
a list of plotting objects either WObject or gg |
ncols |
number of columns |
WGroup
Construct a WObject
WObject(dm = NULL, name = "")
WObject(dm = NULL, name = "")
dm |
position |
name |
name |
a WObject
place an arbitrary position w.r.t a subplot
WPosition( anchor.x, anchor.y, x = NULL, just = c("left", "bottom"), data.coord = FALSE )
WPosition( anchor.x, anchor.y, x = NULL, just = c("left", "bottom"), data.coord = FALSE )
anchor.x |
x coordinates |
anchor.y |
y coordinates |
x |
plotting object to anchor |
just |
adjustment of new plot |
data.coord |
whether the coordinates is in term of data |
a WDimGenerator object
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), WPosition(0.1,0.1,just=c('left','top')))
WHeatmap(matrix(rnorm(2000),nrow=40)) + WHeatmap(matrix(c(rnorm(100)+1,rnorm(100)), nrow=10), cmp=CMPar(brewer.name = 'RdGy'), WPosition(0.1,0.1,just=c('left','top')))
construct a WRect
WRect( obj = NULL, x.span = NULL, y.span = NULL, color = "black", lwd = 3, fill = NA, name = "" )
WRect( obj = NULL, x.span = NULL, y.span = NULL, color = "black", lwd = 3, fill = NA, name = "" )
obj |
a plotting object or its name |
x.span |
x-axis/horizontal span (e.g., c(2,4)) |
y.span |
y-axis/vertical span (e.g., c(5,9)) |
color |
edge color |
lwd |
edge width |
fill |
fill color |
name |
name |
a WRect object
row bind non-overlapping objects
WRowBind(..., nr = NULL, nc = NULL)
WRowBind(..., nr = NULL, nc = NULL)
... |
plotting objects |
nr |
number of rows |
nc |
number of columns |
an object of class WDim
WHeatmap(matrix(rnorm(2000),nrow=40),name='a') + WHeatmap(matrix(rnorm(30), nrow=3), Beneath(),name='b') + WColorBarV(1:10, LeftOf(WRowBind('a','b')))
WHeatmap(matrix(rnorm(2000),nrow=40),name='a') + WHeatmap(matrix(rnorm(30), nrow=3), Beneath(),name='b') + WColorBarV(1:10, LeftOf(WRowBind('a','b')))