Learn R Programming

a4 (version 1.20.0)

plotLogRatio: Plot a summary gene expression graph

Description

Plot ratios of expression values observed in a treatment versus those of a reference. First the ratios and variances are computated on the gene expression data.

Usage

plotLogRatio(e, reference, within = NULL, across = NULL, nReplicatesVar = 3,
 filename = "Rplots", device = "svg", orderBy = list(rows = "hclust", cols = NULL),
  colorsColumns = NULL, colorsColumnsBy = NULL, colorsColumnsByPalette = c("#1B9E77", "#D95F02",
   "#7570B3", "#E7298A", "#66A61E", "#E6AB02", "#A6761D", "#666666"), colorsUseMeanQuantiles = FALSE,
    colorsMeanQuantilesPalette = c("orange", "red", "darkred"), colorsBarsMatrix = NULL,
     colorsGenesNames = c("black"), main = paste("log2 ratio's"), shortvarnames = NULL,
      longvarnames = NULL, gene.length = 50, gene.fontsize = 6, main.fontsize = 9, 
      columnhead.fontsize = 8, mx = 1.5,
       exp.width = 1.8, exp.height = 0.2, log2l.show = TRUE, log4l.show = FALSE, quantiles.show = FALSE,
        quantiles.compute = c(0.9), error.show = TRUE, view.psid = FALSE,
         errorLabel = "Error bars show the pooled standard deviation", 
          closeX11 = FALSE, openFile = FALSE, tooltipvalues = FALSE, probe2gene = TRUE, ...)

Arguments

e
ExpressionSet object to use
reference
List with components 'var' and 'level ' -- see computeLogRatio help
within
Vector of characters for pData column -- see computeLogRatio help
across
Vector of characters for pData column -- see computeLogRatio help
nReplicatesVar
Minimum number of replicates to compute variances and pooled standard errors -- see computeLogRatio help
filename
Name of the filename to use. No need to specify extension which will be added according to device.
device
One of 'pdf', 'X11', 'png', 'svg'. For svg device, one X11 device is also opened.
orderBy
See details
colorsColumns
A vector of colors to be used for plotting columns; default value is NULL which ends up with red -- see Colors section
colorsColumnsBy
A vector of pData columns which combinations specify different colors to be used -- see Colors section
colorsColumnsByPalette
If colorsColumns is NULL, vector of colors to be used for coloring columns potentially splitted by colorsColumnsBy
colorsUseMeanQuantiles
Boolean to indicate if the quantile groups computed on averages over all treatments should be used for coloring -- see Colors section
colorsMeanQuantilesPalette
if colorsUseMeanQuantiles is TRUE, these colors will be used for the different groups -- see Colors section
colorsBarsMatrix
Matrix of colors to be used for each individual bar; colors are provided for genes in data order and thus are possibly reordered according to orderBy -- see Colors section
colorsGenesNames
Vector of colors to be used for gene names; will be recycled if necessary; colors are provided for genes in data order and thus are possibly reordered according to orderBy
main
Main title
shortvarnames
Vector or pData column to be used to display in graph columns. If NULL, those names will be used from the coded names added to pData during computations (list of columns values pasted with a dot). Warning: shortvarnames must be defined in the order columns are present in the ExpressionSet object so that they will be reordered if one asks to order columns.
longvarnames
pData column to be used in SVG tooltip title. If NULL, shortvarnames will be used.Same warning than shortvarnames about ordering.
gene.length
Maximum number of characters that will be printed of the gene names
gene.fontsize
Font size for the gene names , default = 6
main.fontsize
Font size for the main, default = 9
columnhead.fontsize
Font size for the column headers, default = 8
mx
Expansion factor for the width of the bars that represent the expression ratios
exp.width
Expansion factor for global graph width, and the space between the plotted columns
exp.height
Expansion factor for global graph height, and the space between the plotted rows
log2l.show
A logical value. If 'TRUE', the line for log2 values on each column (when max(data) > 2) is drawn
log4l.show
A logical value. If 'TRUE', the line for log4 values on each column (when max(data) > 4) is drawn
quantiles.show
A logical value. If 'TRUE', a line is drawn for quantiles computed separately on each columns
quantiles.compute
A logical value. If 'TRUE', the vector quantiles will be computed and displayed provided that quantile.show is TRUE
error.show
A logical value. If 'TRUE', errors bars are displayed on the graph (only for those columns for which they are available)
view.psid
A logical value. If 'TRUE', the genes psid is displayed on the gene names
errorLabel
A character vector describing the error bars, printed at the bottom of the figure
closeX11
If device is SVG, do we close the required X11 device at the end?
openFile
A logical value. If 'TRUE', the produced output file is opened
tooltipvalues
If device is SVG, one can choose to display each bar separately, with data values as tooltips. Note however that each bar will be considered as a distinct object instead of a column, which will takes much more time to create the graph and produces a much bigger SVG file
probe2gene
Boolean indicating whether the probeset should be translated to a gene symbol (used for the default title of the plot)
...
...

Value

  • The ExpressionSet object with the computated variables is returned.

Ordering

orderBy: A list with two components, rows and cols, each one possibly being NULL (no ordering on the specific dimension). Ordering on cols can be done according to (a) pData column(s) (for example: c('cellline','compound','dose'. Ordering on rows can be done using of the following values:
  • NULL
{no reordering on rows} numeric vector{use the vector values to sort rows} alpha{use genes names alphabetice order} effect{try to assess global gene expression level by taking sum(abs(values)) on specified exprs columns)} hclust{use the ordering returned by hclust invoked on specified exprs columns}

Colors

The management of colors is very flexible but is a little bit tricky, as a variety of parameters are available to the user. Basically, combinations of arguments allow to set colors for columns headers (text), columns as a whole (different colors for the different columns) or for each of the inividual horizontal bars. By default, everything is red. There are four main different arguments that can be used and that are applied in a consecutive order. Each one may override a previous argument value. Below is a list of arguments and their consecutive actions:
  • colorsColumns
{ The first way to assign colors is to provide a vector of colors that will be used for each column (headers and its horizontal bars). This vector is recycled so that providing one unique value will color all columns, whereas providing a vector of length 2 will alternate columnns colors.} colorsColumnsBy{To be used when the experiment involves groupings for pData, for example dose, cellline or treatment. In order to see the effects of such variables, one can color columns using combinations of those. The argument is a vector of pData columns such as c('cellline','dose'). Unique combinations will be computed and a color will be assigned for each group of columns. The vector that is provided with the argument colorsColumnsByPalette is used to assign colors. If the argument colorColumnsBy is not NULL then it overrides the previous argument colorsColumns.} colorsUseMeanQuantiles{ A logical value. The default plotGeneDE displays for each gene the expression value difference between treatment and reference, but does not reveal any information about the expression levels in these conditions. Parameter colorsUseMeanQuantiles allows to color the horizontal bars according to expression level that is derived from quantiles computed on averages of the complete ExpressionSet object. As it involves the expression data of all probesets, computations must be done before subsetting the ExpressionSet object and the plotGeneDEting. The function addQuantilesColors computes quantiles and corresponding mean expression level intervals. If colorsUseMeanQuantiles 'TRUE', previous coloring parameters are overriden. The parameter colorsMeanQuantilesPalette is used to assign colors for average-quantiles-groups. Note that columns headers are still given by previous arguments.} colorsBarsMatrix{The most flexible way to assign colors as the matrix will be used to color each bar of the plot individually. A check is done to ensure that the number of rows and columns are not less than the number of probesets and columns. If not NULL, this parameter overrides the previous ones.}

See Also

computeLogRatio,addQuantilesColors

Examples

Run this code
if (require(ALL)){
  data(ALL, package = "ALL")
  ALL <- addGeneInfo(ALL)
  ALL$BTtype <- as.factor(substr(ALL$BT,0,1))
  ALL2 <- ALL[,ALL$BT != 'T1']  # omit subtype T1 as it only contains one sample
  ALL2$BTtype <- as.factor(substr(ALL2$BT,0,1)) # create a vector with only T and B

  # Test for differential expression between B and T cells
  tTestResult <- tTest(ALL, "BTtype", probe2gene = FALSE)
  topGenes <- rownames(tTestResult)[1:20]

  # plot the log ratios versus subtype B of the top genes 
  LogRatioALL <- computeLogRatio(ALL2, reference=list(var='BT',level='B'))
  a <- plotLogRatio(e=LogRatioALL[topGenes,],openFile=FALSE, tooltipvalues=FALSE, device='X11',
      colorsColumnsBy=c('BTtype'), main = 'Top 20 genes most differentially between T- and B-cells',
      orderBy = list(rows = "hclust"), probe2gene = TRUE)
}
a <- plotLogRatio(e=LogRatioALL[topGenes,],openFile=TRUE, tooltipvalues=FALSE, device='pdf',
      colorsColumnsBy=c('BTtype'), main = 'Top 20 genes most differentially between T- and B-cells',
      orderBy = list(rows = "hclust", cols = "sex"), probe2gene = TRUE)

Run the code above in your browser using DataLab