ggplotMDS: Function ggplotMDS

Description Usage Arguments Details Value Author(s) Examples

View source: R/ggplotMDS.R

Description

This is a wrapper around the plotMDS function that generates the plot with ggplot2 instead of base graphics.

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
ggplotMDS(
  DGEdata,
  colorBy,
  shapeBy,
  sizeBy,
  top = Inf,
  labels,
  labelSize,
  title,
  textColor = "blue2",
  hlineIntercept,
  vlineIntercept,
  reflineColor = "darkgoldenrod1",
  reflineSize = 0.5,
  baseFontSize = 12,
  themeStyle = "grey",
  symShape = 16,
  symSize = 5,
  symFill = "blue2",
  symColor = "blue2",
  alpha = 0.7,
  shapes,
  colors,
  dim.plot = c(1, 2),
  colorName,
  shapeName,
  sizeName
)

Arguments

DGEdata

A DGEList object taken after normalization OR a DGEobj that contains a DGEList OR a log2cpm matrix. (Required)

colorBy

A grouping vector to color by (e.g. ReplicateGroup) (Required)

shapeBy

A grouping vector to map to shape (Optional)

sizeBy

A numeric vector to define point size (Optional)

top

Number of most variant genes to include (default = Inf)

labels

Text labels for the samples. These should be short abbreviations of the sample identifiers. Default = ReplicateGroup or rownames of DGEdata. Set to NULL to disable text labels

labelSize

control the Size for the text labels in the plot if you don't like the default

title

A title for the plot (Optional)

textColor

Color for the text labels in the plot (default = "blue2")

hlineIntercept

Y intercept of horizontal line (Optional)

vlineIntercept

X intercept of vertical line (Optional)

reflineColor

Color for the horizontal and vertiacl reference lines (Default = "darkgoldenrod1")

reflineSize

Thickness of the reference lines (Default = 0.5)

baseFontSize

Base fontsize for the plot (Default = 12)

themeStyle

One of "grey" or "bw" (Default = "grey")

symShape

Set the default shape of the symbols if not mapped to a column (Default = 19 solid circle)

symSize

Set the default size of the symbols if not mapped to a column (Default = 5)

symFill

Set color for the fill on open symbols (Default = "blue2")

symColor

set color for solid symbols or outline for open symbols (Default = "blue2")

alpha

Set transparency (Default = 0.7)

shapes

A vector of shapes to override the default 8 shapes used in shapeBy (optional)

colors

A color pallet to substitute for the default 8 color pallet used by colorBy (optional)

dim.plot

Define which dimension to plot (default = c(1,2))

colorName

Legend title for color (optional)

shapeName

Legend title for shape (optional)

sizeName

Legend title for size (optional)

Details

colorBy, shapeBy and sizeBy are grouping variables to encode group info by color, shape or size. These are vectors that must be the same length as ncol(DGEdata). colorBy and sizeBy will plot as continuous color or size changes if a numeric vector is used. Convert the vector to a factor to treat as groups instead of continuous.

The underlying plotMDS function uses a default of top=500 to use the top 500 highest fold change genes for the analysis. The method runs quick and I've found situations where a larger value produced a more stable result. Thus I've change the default to top=Inf. You should play with this parameter and at least try a number that is close to the number of differential genes detected in your data.

Value

A list with two elements, the ggplot object and the mds object returned by the plotMDS function.

Author(s)

John Thompson, jrt@thompsonclan.org

Examples

1
2
3
4
5
6
7
8
     #Plot the first two dimensions using all genes
     MyMDS = ggplotMDS (MyDGEList)
     #display the plot and save a png file.
     printAndSave (MyMDS[[1]], file = "MyMDS.PNG", width=5, height=5)

     #plot the 2nd and 3rd dimensions using the top 1000 genes
     MyMDS = ggplotMDS (MyDGEList, dim.plot=c(2,3) ndim =3)
     MyMDS[[1]]

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