Description Usage Arguments Details Value Author(s) Examples
In the simpliest form it draws a nicely formatted scatterplot of the first two columns in a dataframe. Several formatting options are available to enhance the plots. If you supply pvalues or FDR values and a threshold, the plot is color coded to show X unique, Y Unique and Common differentialy expressed (DE) genes in different colors.
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 | comparePlot(
df,
pthreshold = 0.01,
xlab = NULL,
ylab = NULL,
title = NULL,
symbolSize = c(4, 4, 4, 2),
symbolShape = c(21, 21, 21, 20),
symbolColor = c("black", "grey0", "grey1", "grey25"),
symbolFill = c("darkgoldenrod1", "deepskyblue4", "red3", "grey25"),
alpha = 0.5,
rugColor = NULL,
rugAlpha = 1,
crosshair = "grey50",
referenceLine = "darkgoldenrod1",
refLineThickness = 1,
dens2D = TRUE,
legendPosition = "right",
baseFontSize = 12,
themeStyle = "bw",
footnote,
footnoteSize = 3,
footnoteColor = "black",
footnoteJust = 1
)
|
df |
A dataframe with the first two columns representing the x and y variables. Optionally add xp and yp columns to hold pvalues or FDR values. |
pthreshold |
Used to color points (default = 0.01) |
xlab |
X axis label (default to first column name) |
ylab |
Y axis label (default to second column name) |
title |
Plot title (optional) |
symbolSize |
Size of symbols; default = c(4, 4, 4, 2) |
symbolShape |
Shape of the symbols; Default = c(21, 21, 21, 20) (20 = filled circle, 21 = fillable open circle) See http://www.cookbook-r.com/Graphs/Shapes_and_line_types |
symbolColor |
c(Common, xUnique, yUnique, NoChange); default = c("black", "grey0", "grey1", "grey25") |
symbolFill |
Set the fill color for the symbols. Note only symbols 21-25 are fillable. This will have no effect on other symbols. Default = c("darkgoldenrod1", "deepskyblue4", "red3", "grey25") |
alpha |
Controls the transparency of the plotted points (0-1; default = 0.5) |
rugColor |
Specify color for rug density plot along xy axes. Set to NULL to disable rug layer. (Default=NULL) |
rugAlpha |
Sets the transparency for the rug layer. An alpha <1.0 takes a long time to draw (~10 min on 32bit Win7). So I set the default at 1.0, but for a final plot try 0.1 or 0.2 for alpha for more informative rug. |
crosshair |
Color for the crosshair; (Default = "grey50", NULL disables) See http://research.stowers-institute.org/efg/R/Color/Chart |
referenceLine |
Color for a slope=1, intercept=0 reference line (Default = "darkgoldenrod1"; NULL disables) |
refLineThickness |
Set thickness for crosshair and referenceLine (Default=1) |
dens2D |
Overlay a density2D layer (Default = TRUE) Note: only applies to simple compare plot without pvalue coloring. |
legendPosition |
One of "top", "bottom", "left", "right", "ne", "se", "nw", "sw", NULL. top/bottom/left/right place the legend outside the figure. ne/se/nw/sw place the figure inside the figure. NULL disables the legend. Default = "right" |
baseFontSize |
The smallest size font in the figure in points. Default = 12 |
themeStyle |
"bw" or "grey" which corresponds to theme_bw or theme_grey respectively. Default = bw" |
footnote |
optional string placed right justified at bottom of plot. |
footnoteSize |
applies to footnote. (default = 3) |
footnoteColor |
applies to footnote. (default = "black") |
footnoteJust |
Value 0-1. 0 is left justified, 1 is right justified, 0.5 is centered. (default=1) |
Other options add an identity line (slope=1, intercept=0) and/or a crosshair at (0,0).
The comparePlot has also been implemented with a scalable theme that makes it easy to scale font sizes larger or smaller for PPT or Knitr output. Just add either theme_grey(n) or theme_bw(n), where n equals the base font size (12 works well for knitr, 18 or 24 works well for PPT). e.g. MyPlot + theme_grey(18). However, theme_gray and theme_bw have the side effect of resetting the legend position. Thus, do not use those standard themes if you want to preserve the custom legend locations. You must rely on the baseFontSize argument in this function to set font sizes to preserve a custom legend location.
Data Structure for the input dataframe:
The x and y values should be in the first two columns. By default, their column names will be used for the axis labels. You can overide the xylabels the xlab and ylab arguments.
Optionally, significance measures in the form of pvalues or FDR values can be supplied for X and Y respectively. If provided, these columns must be named "xp" and "yp" respectively. Together with a threshold (which defaults to 0.01), these values will be used to color code the plot to show X Unique, Y Unique and Common DE genes. You can use either pvalues or FDR values for the signficance columns. Use the pthreshold argument to set a proper threshold for FDR values.
Sensible defaults are chosen for symbols (Size, Shape, Color and Fill). Optionally, there are arguments to allow you to fiddle with these settings. A length of 4 is required for these arguments which applies the attributes in this order: Common, X Unique, Y Unique and Not Significant.
Note if you're not using pvalues or FDR values to color the plot, the X Unique color values are used.
ggplot object
John Thompson, jrt@thompsonclan.org
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #Retrieve the 1st two contrasts from a DGEobj as a list of dataframes (length=2; named items)
ttList <- getType(dgeObj, "topTable")[1:2]
#capture the default logFC and P.Value
compareDat <- comparePrep(ttList)
#switch to an FDR value for the significance measure
compareDat <- comparePrep(ttList, significanceCol="adj.P.Val")
#draw the plot
cPlot <- comparePlot(compareDat, title = "Plot Title")
print(cPlot)
Deluxe Plot with bells and whistles.
MyPlot = comparePlot (df, pthreshold = 0.5,
xlab = "x Axis Label", ylab = "y Axis Label",
title = "Plot Title",
crosshair = "red",
referenceLine = "blue",
legendPosition="nw")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.