Description Usage Arguments Details Value Objects from the Class Slots Methods Author(s) See Also Examples
A class for associating plotting symbols and colors with a logical vector or with levels of a factor.
1 2 | ColorCoding(v, color, mark = 1)
colorCode(fac, colorScheme = 1:length(levels(fac)), mark = 1)
|
v |
a logical vector |
color |
a string or integer representing a color |
mark |
an integer representing a plotting symbol, or list of
plotting symbols that should be associated with levels of the factor
|
fac |
A factor |
colorScheme |
A list of colors that should be associated with
levels of the factor |
It is often necessary with microarray data to produce multiple plots,
where each point on the plot corresponds to a gene or a spot on the
microarray. Across multiple plots, we often want to use symbols or
colors to mark subsets of he genes with certain properties. The
ColorCoding
class works in tandem with the
ColorCodedPair
class to make it easier to maintain
consistent plotting conventions across multiple graphs.
The constructor returns a valid object of the ColorCoding
class.
The colorCode
function provides a simple interface to associate
colors and symbols with the levels of a factor. It returns a list of
valid ColorCoding
objects that can be passed directly to the
constructor of a ColorCodedPair
object.
Although objects can be created using new
, the preferred method
is to use the constructor function, ColorCoding
. To create a
set of colors and symbols associated with different levels of a
factor, use the colorCode
function.
v
a logical vector
color
a string or integer representing a color
mark
an integer representing a plotting symbol
There are no specialized methods for objects of this class; all activities can be performed by directly accessing the documented slots.
Kevin R. Coombes krc@silicovore.com, P. Roebuck proebuck@mdanderson.org
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 | showClass("ColorCoding")
theta <- (0:360)*pi/180
x <- cos(theta)
y <- sin(theta)
xp <- x > 0
yp <- y > 0
colors <- list(ColorCoding(xp&yp, oompaColor$BORING),
ColorCoding(xp&!yp, oompaColor$TOP.TEN),
ColorCoding(!xp&yp, oompaColor$BOTTOM.TEN),
ColorCoding(!xp&!yp, oompaColor$CONFIDENCE.CURVE))
plot(ColorCodedPair(x, y, colors))
plot(ColorCodedPair(theta, x, colors))
plot(ColorCodedPair(theta, y, colors),
xlab='angle in radians', ylab='sine', main='colored sine')
fac <- factor(rep(c('left', 'right'), c(180, 181)))
colors <- colorCode(fac, c('blue', 'red'))
plot(ColorCodedPair(x, y, colors))
## cleanup
rm(x, y, xp, yp, theta, colors, fac)
colorList <- c(oompaColor$BORING, oompaColor$SIGNIFICANT,
oompaColor$EXPECTED, oompaColor$OBSERVED,
oompaColor$PERMTEST, oompaColor$FITTED,
oompaColor$CENTRAL.LINE, oompaColor$CONFIDENCE.CURVE,
oompaColor$BAD.REPLICATE, oompaColor$WORST.REPLICATE,
oompaColor$FOLD.DIFFERENCE, oompaColor$BAD.REPLICATE.RATIO,
oompaColor$TOP.TEN, oompaColor$BOTTOM.TEN,
oompaColor$TOP.TEN.SOLO, oompaColor$BOTTOM.TEN.SOLO
)
plot(c(1,4), c(1,4), type='n')
for (i in 1:4) {
for (j in 1:4) {
points(i,j, col=colorList[i + 4*(j-1)], pch=16, cex=4)
}
}
rm(colorList, i, j)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.