ggSmartBoxplot: ggSmartBoxplot

Description Usage Arguments Value Author(s) See Also Examples

View source: R/aveytoolkit_ggSmartBoxplot.R

Description

Boxplot wrapper for ggplot

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
ggSmartBoxplot(
  x,
  mat,
  splitRowBy = NA,
  splitColBy = NA,
  colorBy = NULL,
  rows,
  cols = NA,
  whichCols = NA,
  sep = ".",
  outlier.shape = 17,
  ylab = NULL,
  space = "fixed",
  scales = "fixed",
  fileName = NA,
  plot = TRUE,
  ...
)

Arguments

x

the variable to group by for boxplots

mat

data.frame or matrix of values to plot with samples in columns

splitRowBy

a factor used to split the data by row in facet_grid

splitColBy

a factor used to split the data by col in facet_grid

colorBy

a factor used for coloring. No coloring will be done if NULL (default)

rows

row names or row indices of the items to be plotted

cols

substring to search for with "grep" in column names to be plotted

whichCols

the column indices or full column names

sep

a separator used in searching for cols in the column names

outlier.shape

shape of outliers (default is 17, filled triangle)

ylab

if NULL, default is to use rownames. Can specify a string instead to use

space

If "fixed", the default, all panels have the same size. If "free_y" their height will be proportional to the length of the y scale; if "free_x" their width will be proportional to the length of the x scale; or if "free" both height and width will vary. This setting has no effect unless the appropriate scales also vary.

scales

Are scales shared across all facets (the default, "fixed"), or do they vary across rows ("free_x"), columns ("free_y"), or both rows and columns ("free")

fileName
plot

logical specifying whether or not to plot the plot(s). Default is TRUE.

...

other arguments that are passed to qplot

filename

the name of a file to write a PDF to or NA to plot in standard graphics device.

Value

invisibly returns a list with 2 elements: ggplot: the ggplot object to be plotted (this can be added to dat: a named list of the data frame(s) passed to data in ggplot. The names come from converting the rows argument to a character vector.

Author(s)

Stefan Avey

See Also

ggplot2, qplot

Examples

 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
data(OrchardSprays)
## Example of functionality
ggSmartBoxplot(x=OrchardSprays$treatment,
               mat=t(OrchardSprays[,1]),
              rows=1, whichCols=1:ncol(t(OrchardSprays)),
              colorBy=factor(OrchardSprays$rowpos+OrchardSprays$colpos > 9),
              xlab="Treatment")

## Not run: 
cellType <- "PBMC"
## expr would be an expression matrix with genes in rows and samples in columns 
geneSub <- grep("HLA-A29.1", rownames(expr))
age <- "Young"
ages <- c("Young", "Old")
responses <- c("NR", "R")
subset <- targetFClist[[cellType]]$Age %in% ages & 
  targetFClist[[cellType]]$Response %in% responses
ggSmartBoxplot(x=targetFClist[[cellType]][subset, "Time"],
               mat=exprFClist[[cellType]], ylim=c(-1,1),
               rows=geneSub, whichCols=which(subset), 
               colorBy=targetFClist[[cellType]][subset,"Response"],
               splitRowBy=targetFClist[[cellType]][subset,"Age"],
               xlab="Days (Post Vaccination)",
               fileName=NA)

## End(Not run)

stefanavey/aveytoolkit documentation built on March 5, 2020, 12:49 a.m.