Description Usage Arguments Details Value Examples
Plot several groups of repeated observations, e.g. abundance/half-life of several proteins each observed in several cell lines in several replicates. Observations can be grouped either by protein (in which case cell lines will be annotated as X axis labels and proteins above the plot) or by cell line. Related parameters can be plotted in separate plots below each other, sharing the groupings and annotations (see examples)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | plotgroups(data, names, colors = NULL, legend.text = NULL,
legend.col = NULL, legend.pars = list(), legend.lwd = NULL,
groups.spacing = 0, names.split = NULL, names.italicize = NULL,
names.style = c("plain", "combinatorial"), names.pch.cex = 1,
names.pch = 19, names.adj = NA, names.map.fun = NULL,
names.margin = 0.5, names.rotate = NULL, names.placeholder = NA,
features = NA, log = FALSE, range = 1.5, conf.level = 0.95,
ci.fun = plotgroups.ci, cex.xlab = 1, ylim = NULL,
legendmargin = NULL, plot.type = plotgroups.boxplot,
plot.fun.pars = list(), barwidth = 0.8, main = NULL, ylab = NULL,
ylab.line = NULL, signif.test = NULL, signif.test.fun = t.test,
signif.test.text = plotgroups.pval, signif.test.col = "black",
signif.test.lwd = legend.lwd, signif.test.pars = legend.pars,
extrafun.before = NULL, extrafun.after = NULL, ...)
|
data |
list, each element is a vector of replicates for one combination of parameters, or each element is a list containing a vector of replicates, in which case the data sets will be plotted below each other in separate plots |
names |
character vector of X axis labels |
colors |
colors for plotting |
legend.text |
character vector of the same length as |
legend.col |
colors for group annotations. Defaults to plotting colors |
legend.pars |
parameters for group annotation. Will be passed to |
legend.lwd |
line width for grouping annotations. Defaults to |
groups.spacing |
extra space between the groups in user coordinates. |
names.split |
character by which to split the |
names.italicize |
if a part of a |
names.style |
how the
|
names.pch.cex |
character expansion factor for |
names.pch |
character to be used for annotation of observations when
|
names.adj |
text adjustment for |
names.map.fun |
Function mapping between names string and pch/cex/adj/rotate for the respective combination. Useful for more complicated experimental layouts where different names.pch must be used for different genes, see examples. Must accept six arguments:
Must return a named list, with the names being the split genes that should be used to
label the rows, each element being itself a named list containing the plotting
parameters for that particular annotation, i.e. |
names.margin |
spacing between the bottom edge of the plot and the annotation, in inches |
names.rotate |
Degrees by which to rotate the annotation strings. |
names.placeholder |
Only used when |
features |
which features of the sample distributions to plot. Availability of features
depends on
Can be a list containing character vectors, in which case the specified feature set will apply to the corresponding plot if multiple data sets are plotted (see examples). Will be recycled to the number of plots. |
log |
Whether to plot the Y axis on log scale |
range |
determines how far the the |
conf.level |
Confidence level for plotting of confidence intervals. Will be recycled to the number of plots |
ci.fun |
Function to compute confidence intervals. Will be recycled to the number of plots. Must accept five arguments:
If |
cex.xlab |
character expansion factor for X axis annotation |
ylim |
Y axis limits. Will be determined automatically if |
legendmargin |
spacing between the upper-most data point/feature and the upper edge of the
plot, required for group annotation. Will be determined automatically if |
plot.type |
list containint three functions:
Can be a list of lists, in which case the elements will apply to the corresponding plot. |
plot.fun.pars |
additional parameters to pass to |
barwidth |
width of the individual bars/boxes etc. as fraction of 1 |
main |
main title |
ylab |
Y axis label. Will be recycled to the number of plots. |
ylab.line |
The margin line for the Y axis label. |
signif.test |
list of 2-element integer vectors giving the elements of |
signif.test.fun |
function to perform the significance testing. Must accept 2 vectors and
return a list containing at least the element |
signif.test.text |
function accepting a p-value and returning a formatted string to be used
for plotting or |
signif.test.col |
color of p-value annotations. |
signif.test.lwd |
line width for p-value annotations. Can be a list, in which case the lwd will apply to the corresponding plot if multiple data sets are plotted. |
signif.test.pars |
parameters for group annotation. Will be passed to |
extrafun.before |
additional function to call after the coordinate system has been set up, but before plotting, e.g. to add a background grid to the plot. Can be a list of functions, in which case each element will apply to the corresponding plot if multiple data sets are plotted. |
extrafun.after |
additional function to call after plotting, e.g. to add additional elements to the plot. Can be a list of functions, in which case each element will apply to the corresponding plot if multiple data sets are plotted. |
... |
additional parameters passed to |
This is a wrapper function around plot.type$plot
. It sets up the coordinate system, calls
extrafun.before
followed by plot.type$plot
, which does the actual plotting, and
extrafun.after
. All three functions are passed the following arguments:
the data
argument passed to plotgroups
X coordinates of the data. Particularly important when groups.spacing != 0
summary statistics of the data. List with the following components:
means
standard deviations
standard errors of the mean
medians
third quartile
tirst quartile
the maximal data point within range
times
the interquartile range of boxmax
the minimal data point within range
times
the interquartile range of boxmin
the upper confidence bound, computed by ci.fun
according to conf.level
the lower confidence bound, computed by ci.fun
according to conf.level
the range of the extreme data points within
[iqrmin
, iqrmax
]
the confidence level at which cimax
,
cimin
apply
the colors
argument passed to plotgroups
the features
argument passed to plotgroups
the barwidth
argument passed to plotgroups
plot.type$plot
is additionally passed the arguments given by plot.fun.pars
.
Significance testing is performed by calling signif.test.fun
with two vector arguments
containing the samples to be compared. signif.test.fun
must return a list containing
a p.value
element. The p value is passed as single argument to signif.test.text
which returns a character vector (or anything usable by text
).
list with the following components:
summary statistics of the data.
Character vector of features actually plotted.
Return value of plot.type$plot
X coordinates of the data.
Height of the annotation in inches.
Width of the annotation in inches. If
names.style='combinatorial'
this is the width of the left margin.
Top margin required for the legend, in user coordinates.
If significance testing was performed, also contains a component
signiftest
, which is a list with elements ordered by
signif.test
with the following components:
return value of the testing function
return value of signif.test.text
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 | data <- list()
for (i in 1:14) data[[i]] <- rnorm(50, i, 0.5)
names <- rep(c('gene1', 'gene2', 'gene3', 'gene1 gene2', 'gene1 gene3', 'gene2 gene3', 'gene1 gene2 gene3'),
times=2)
names2 <- as.character(rep(1:7,times=2))
names2[2] <- "abc\nefg"
colors <- c("green", "blue")
legend.text <- rep(c("protein1", "protein2"), each=7)
plotgroups(data, names, colors, legend.text,
plot.type=plotgroups.beeswarm, features=c('mean', 'sd'), ylim=c(0,Inf))
plotgroups(data, names2, colors, legend.text,plot.type=plotgroups.vioplot, ylim=c(0,Inf),
names.rotate=0, names.adj=c(0.5, 1))
plotgroups(data, names, colors, legend.text, log=TRUE,
plot.type=plotgroups.beeswarm, features=c('mean', 'sd'),
names.style='combinatorial', names.split=" ", names.pch='\u0394',
plot.fun.pars=list(palpha=0.5, bxpcols="black"))
plotgroups(data, names, colors, legend.text,
names.style='combinatorial', names.split=" ", names.pch='\u0394',
names.placeholder='+')
plotgroups(data, names, colors, legend.text,
names.style='combinatorial', names.split=" ", names.pch=19,
main="test", plot.type=plotgroups.barplot, features=c("mean", "sd"),
plot.fun.pars=list(whiskerswidth=0.6))
map.fun <- function(n, split, pch, cex, rotate, adj) {
n <- strsplit(n, split, fixed=TRUE)[[1]]
nlist <- lapply(n, function(x){
if (x != "gene2") {
list(pch=pch, cex=cex, rotate=rotate, adj=adj)
} else {
list(pch='S158T', cex=cex, rotate=90, adj=c(0,0.5))
}
})
names(nlist) <- n
nlist
}
plotgroups(data, names, colors, legend.text,names.style='combinatorial', names.split=" ",
names.pch='\u0394', names.map.fun=map.fun)
## significance testing
plotgroups(data, names, colors, legend.text,names.style='combinatorial',
names.split=" ", names.pch='\u0394',
signif.test=list(c(1,3), c(2,5), c(5,8), c(3,10)))
plotgroups(data, names, colors, legend.text,names.style='combinatorial',
names.split=" ", names.pch='\u0394',
signif.test=list(c(1,3), c(2,5), c(5,8), c(3,10)),
signif.test.text=function(p) {
if (p < 0.001) {
return('***')
} else if (p < 0.01) {
return('**')
} else if (p < 0.05) {
return('*')
} else {
return(NULL)
}})
## multiple plots
plotgroups(list(data, rev(data)), names, colors, legend.text,names.style='combinatorial',
names.split=" ",names.pch='\u0394', names.map.fun=map.fun,
ylim=c(0,Inf), ylab=c("data1", "data2"), main="test", features=list(NULL,
c("median", "box")), plot.type=list(plotgroups.boxplot, plotgroups.beeswarm),
signif.test=list(NULL,list(c(1,3), c(2,5), c(5,8), c(3,10))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.