Last data update: 2014.03.03

R: Draw heatmap of square of correlations among arrays
R2PlotFuncR Documentation

Draw heatmap of square of correlations among arrays

Description

Draw heatmap of square of correlations among arrays.

Usage

R2PlotFunc(
    es, 
    hybName = "Hybridization_Name",
    arrayType = c("all", "replicates", "GC"), 
    GCid = c("128115", "Hela", "Brain"),
    probs = seq(0, 1, 0.25), 
    col = gplots::greenred(75), 
    labelVariable = "subjID", 
    outFileName = "test_R2_raw.pdf", 
    title = "Raw Data R^2 Plot", 
    requireLog2 = FALSE, 
    plotOutPutFlag = FALSE, 
    las = 2, 
    keysize = 1, 
    margins = c(10, 10), 
    sortFlag = TRUE,
    varSort=c("Batch_Run_Date", "Chip_Barcode", "Chip_Address"), 
    timeFormat=c("%m/%d/%Y", NA, NA),
    ...)

Arguments

es

ExpressionSet object of QC probe profiles.

hybName

character string. indicating the phenotype variable Hybridization_Name.

arrayType

A character string indicating if the correlations are calculated based on all arrays, arrays with replicates, or genetic control arrays.

GCid

A vector of character string. symbols for genetic control samples. The symbols can be more than one.

probs

A vector of probabilities specify the quantiles of correlations to be output.

col

colors used for the image. see the function heatmap.2 in R package gplots.

labelVariable

A character string indicating how to label the arrays.

outFileName

A character string. The name of output file.

title

Title of the plot.

requireLog2

logical. requiredLog2=TRUE indicates probe expression levels will be log2 transformed. Otherwise, no transformation will be performed.

plotOutPutFlag

logical. plotOutPutFlag=TRUE indicates the plots will be output to pdf format files. Otherwise, the plots will not be output to external files.

las

'las' numeric in 0,1,2,3; the style of axis labels. 0 - always parallel to the axis, 1 - always horizontal, 2 - always perpendicular to the axis, or 3 - always vertical.

see par.

keysize

numeric value indicating the size of the key. see the function heatmap.2 in R package gplots.

margins

numeric vector of length 2 containing the margins. see the function heatmap.2 in R package gplots.

sortFlag

logical. Indicates if arrays need to be sorted according to Batch_Run_Date, Chip_Barcode, and Chip_Address.

varSort

A vector of phenotype variable names to be used to sort the samples of es.

timeFormat

A vector of time format for the possible time variables in varSort. The length of timeFormat should be the same as that of varSort. For non-time variable, the corresponding time format should be set to be equal to NA. The details of the time format for time variable can be found in the R function strptime.

...

Arguments to be passed to heatmap.2.

Value

A list with 3 elments. The first element R2Mat is the matrix of squared correlation. The second element R2vec is the vector of the upper triangle of the matrix of squared correlation (diagnoal elements are excluded). The third element R2vec.within.req is the vector of within-replicate R^2, that is, any element in R2vec.within.req is the squared correlation coefficient between two arrays/replicates for a subject.

Author(s)

Weiliang Qiu <stwxq@channing.harvard.edu>, Brandon Guo <brandowonder@gmail.com>, Christopher Anderson <christopheranderson84@gmail.com>, Barbara Klanderman <BKLANDERMAN@partners.org>, Vincent Carey <stvjc@channing.harvard.edu>, Benjamin Raby <rebar@channing.harvard.edu>

Examples

    # generate simulated data set from conditional normal distribution
    set.seed(1234567)
    es.sim = genSimData.BayesNormal(nCpGs = 100, 
      nCases = 20, nControls = 20,
      mu.n = -2, mu.c = 2,
      d0 = 20, s02 = 0.64, s02.c = 1.5, testPara = "var",
      outlierFlag = FALSE, 
      eps = 1.0e-3, applier = lapply) 
    print(es.sim)

    es.sim$Batch_Run_Date = 1:ncol(es.sim)
    es.sim$Chip_Barcode = 1:ncol(es.sim)
    es.sim$Chip_Address = 1:ncol(es.sim)
  
    # draw heatmap for the first 5 subjects
    png(file="r2plot.png")
    R2PlotFunc(
      es = es.sim[, 1:5], 
      hybName = "memSubj",
      arrayType = c("all", "replicates", "GC"), 
      GCid = c("128115", "Hela", "Brain"),
      probs = seq(0, 1, 0.25), 
      col = gplots::greenred(75), 
      labelVariable = "subjID", 
      outFileName = "test_R2_raw.pdf", 
      title = "Raw Data R^2 Plot", 
      requireLog2 = FALSE, 
      plotOutPutFlag = FALSE, 
      las = 2, 
      keysize = 1, 
      margins = c(10, 10), 
      sortFlag = TRUE,
      varSort=c("Batch_Run_Date", "Chip_Barcode", "Chip_Address"), 
      timeFormat=c("%m/%d/%Y", NA, NA))
    dev.off()
        

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(iCheck)
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: lumi
Setting options('download.file.method.GEOquery'='auto')
Setting options('GEOquery.inmemory.gpl'=FALSE)
Loading required package: gplots

Attaching package: 'gplots'

The following object is masked from 'package:stats':

    lowess

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/iCheck/R2PlotFunc.Rd_%03d_medium.png", width=480, height=480)
> ### Name: R2PlotFunc
> ### Title: Draw heatmap of square of correlations among arrays
> ### Aliases: R2PlotFunc
> ### Keywords: methods
> 
> ### ** Examples
> 
>     # generate simulated data set from conditional normal distribution
>     set.seed(1234567)
>     es.sim = genSimData.BayesNormal(nCpGs = 100, 
+       nCases = 20, nControls = 20,
+       mu.n = -2, mu.c = 2,
+       d0 = 20, s02 = 0.64, s02.c = 1.5, testPara = "var",
+       outlierFlag = FALSE, 
+       eps = 1.0e-3, applier = lapply) 
>     print(es.sim)
ExpressionSet (storageMode: lockedEnvironment)
assayData: 100 features, 40 samples 
  element names: exprs 
protocolData: none
phenoData
  sampleNames: subj1 subj2 ... subj40 (40 total)
  varLabels: arrayID memSubj
  varMetadata: labelDescription
featureData
  featureNames: probe1 probe2 ... probe100 (100 total)
  fvarLabels: probe gene chr memGenes
  fvarMetadata: labelDescription
experimentData: use 'experimentData(object)'
Annotation:  
> 
>     es.sim$Batch_Run_Date = 1:ncol(es.sim)
>     es.sim$Chip_Barcode = 1:ncol(es.sim)
>     es.sim$Chip_Address = 1:ncol(es.sim)
>   
>     # draw heatmap for the first 5 subjects
> #    png(file="r2plot.png")
>     R2PlotFunc(
+       es = es.sim[, 1:5], 
+       hybName = "memSubj",
+       arrayType = c("all", "replicates", "GC"), 
+       GCid = c("128115", "Hela", "Brain"),
+       probs = seq(0, 1, 0.25), 
+       col = gplots::greenred(75), 
+       labelVariable = "subjID", 
+       outFileName = "test_R2_raw.pdf", 
+       title = "Raw Data R^2 Plot", 
+       requireLog2 = FALSE, 
+       plotOutPutFlag = FALSE, 
+       las = 2, 
+       keysize = 1, 
+       margins = c(10, 10), 
+       sortFlag = TRUE,
+       varSort=c("Batch_Run_Date", "Chip_Barcode", "Chip_Address"), 
+       timeFormat=c("%m/%d/%Y", NA, NA))
quantile of R^2>>
          0%          25%          50%          75%         100% 
0.0003602554 0.0025207654 0.0177165449 0.0350714356 0.0557552174 

> #    dev.off()
>         
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>