obsPlot2: Function obsPlot2

Description Usage Arguments Details Value Author(s) Examples

View source: R/obsPlot2.R

Description

Provides a summary plot (box/violin/points)for each observation (gene), showing data for each experiment group. The plot can optionally include one or more of the following layers: boxplot, violin plot, individual points and/or mean of all points. The layers are built up in the order listed with user settable transparency, colors etc. By default, the Boxplot, Point and Mean layers are active. Also, by default, the plots are faceted. Facet plot can be turned off to return a list of individual ggplot graphics for each gene.

Usage

 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
obsPlot2(
  data,
  plotByCol,
  groupCol,
  valueCol,
  groupOrder = unique(as.character(data[groupCol, , drop = TRUE])),
  boxLayer = TRUE,
  violinLayer = FALSE,
  pointLayer = TRUE,
  meanLayer = TRUE,
  xlab = groupCol,
  ylab = valueCol,
  title,
  boxColor = "grey30",
  boxFill = "deepskyblue3",
  boxAlpha = 0.5,
  boxNotch = FALSE,
  boxNotchWidth = 0.8,
  violinColor = "grey30",
  violinFill = "goldenrod1",
  ViolinAlpha = 0.5,
  pointColor = "grey30",
  pointFill = "dodgerblue4",
  pointShape = 21,
  pointAlpha = 1,
  pointSize = 2,
  pointJitter = 0,
  meanColor = "red2",
  meanFill = "goldenrod1",
  meanShape = 22,
  meanAlpha = 0.7,
  meanSize = 3,
  legenPosition = "right",
  baseFontSize = 12,
  themeStyle = "grey",
  facet = TRUE,
  facetRow,
  xAngle = 30,
  scales = "free_y",
  debug = FALSE
)

Arguments

data

A tidy dataframe of intensity data with row and colnames (required)

plotByCol

Define the column name to separate plots (typically a gene ID column) (required)

groupCol

Define the column name to group boxplots by (typically a replicate group column) (required)

valueCol

Define the column of values for plotting (typically a log intensity measure) (required)

groupOrder

Define the order for the groups in each plot. Should contain values in unique(data$group) listed in the order that you want the groups to appear in the plot. (optional; default = unique(data[groupCol]))

boxLayer

Adds a boxplot layer (Default = TRUE)

violinLayer

Adds a violin layer (Default = FALSE)

pointLayer

Adds a point layer (Default = True)

meanLayer

Adds a mean layer (Default = True)

xlab

X axis label (defaults to groupCol)

ylab

Y axis label (defaults to valueCol)

title

Plot title (optional)

boxColor

Color for the boxplot layer (Default = "grey30")

boxFill

Fill Color for the boxplot layer (Default = "deepskyblue3")

boxAlpha

Transparency for the box layer (Default = 0.5)

boxNotch

turn on/off confidence interval notches on boxplots (Default = FALSE)

boxNotchWidth

Set the width of boxnotches (0-1) (Default = 0.8)

violinColor

Color for the violin layer (Default = "grey30")

violinFill

Fill Color for the violin (Default = "yellow")

pointColor

Color for the point layer (Default = "grey30")

pointFill

Fill color for the point layer (Default = "dodgerblue4")

pointShape

Shape for the point layer (Default = 21; fillable circle)

pointAlpha

Transparency for the box layer (Default = 1)

pointSize

Size of the points (Default = 4)

pointJitter

Amount to jitter the points (Default = 0) Try 0.2 if you have alot of points.

meanColor

Color for the mean layer (Default = "red2")

meanFill

Fill color for the mean layer (Default = "goldenrod1")

meanShape

Shape for the mean layer (Default = 21; fillable circle)

meanAlpha

Transparency for the mean layer (Default = 0.7)

meanSize

Size of the mean points (Default = 3)

baseFontSize

The smallest size font in the figure in points. (Default = 12)

themeStyle

"bw" or "grey" which correspond to theme_bw or theme_grey respectively. Default = bw"

facet

Specifies whether to facet (TRUE) or print individual plots (FALSE) (Default = TRUE)

facetRow

Explicitly set the number of rows for the facet plot. Default behavior will automatically set the columns. (Default = NULL)

xAngle

Angle to set the sample labels on the Xaxis. (Default = 30; Range = 0-90)

scales

Specify same scales or independent scales for each subplot (Default = "free_y"; Allowed values: "fixed", "free_x", "free_y", "free")

debug

Turn on debug mode (default = FALSE)

violinAlpha

Transparency for the box layer (Default = 0.5)

Details

Input is a tidy dataframe of intensity data.

Value

ggplot If Facet=TRUE (default) returns a facetted ggplot object. If facet=FALSE, returns a list of ggplot objects indexed by observation (gene) names.

Author(s)

John Thompson, jrt@thompsonclan.org

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  #simulate some data with row and colnames
  groups <- paste("group", factor(rep(1:4, each=100)), sep="")
  x <- matrix(rnorm(2400, mean=10), ncol=length(groups))
  colnames(x) <- paste("sample", 1:ncol(x), sep="")
  rownames(x) <- paste("gene", 1:nrow(x), sep="")
  #reformat into tidy dataframe
  tidyInt <- tidyIntensity(x,

 #Or get data from a DGEobj with RNA-Seq data
 log2cpm <- convertCount(dgeObj$counts, unit="cpm", log=TRUE, normalize="tmm")
 tidyInt <- tidyIntensity(log2cpm,
                           rowidColname="GeneID",
                           keyColname="Sample",
                           valueColname="Log2CPM",
                           group=dgeObj$design$ReplicateGroup)

  #Facetted boxplot
  obsPlot2(tidyInt, plotByCol="GeneID",
           groupCol = "group",
           valueCol ="Log2CPM",
           pointJitter = 0.1,
           facetRow = 2)

  #Facetted violin plot
  obsPlot2(tidyInt, plotByCol = "GeneID",
           violinLayer = TRUE,
           boxLayer = FALSE,
           groupCol="group",
           valueCol = "Log2CPM",
           pointJitter = 0.1,
           facetRow = 2)

  #Return a list of ggplots for each individual gene
  myplots <- obsPlot2(tidyInt, plotByCol="GeneID",
           groupCol = "group",
           valueCol ="Log2CPM",
           pointJitter = 0.1,
           facet = FALSE)
  #plot one from the list
  myplots[[2]]

jrthompson54/DGE.Tools2 documentation built on May 12, 2021, 8:47 p.m.