average.replicates-methods: Average replicate columns

Description Arguments Details Value Author(s) See Also Examples

Description

Average the replicate samples within a dataset x, based on the groupings indicated in by classes, where identical values indicate samples to be averaged. Note that averaged is a bit of a generalisation, since some dataslots, eg detection within LumiBatch objects contains p-values, which are not averaged per se, see the average.pval.replicates S4 methods.

Arguments

x

a matrix, data.frame, eSet, LumiBatch or AnnotatedDataFrame of data

classes

a character or factor: the sample classes, 1 per sample in x, with as many unique values or levels as there are unique samples.

Details

x can be either a matrix, data.frame, eSet, LumiBatch, AnnotatedDataFrame. Note that for most of these data types, each sample is assumed to be in a column. AnnotatedDataFrame has 1 row per sample, thus the result will have fewer rows than x.

classes can be a character or factor vector. Note that the sampleNames of the result are derived from the unique values, or levels in the classes vector

matrix will return a matrix, with 1 column per levels(classes), in the same order as classes. Note this is different

eSet is a virtual object, thus all sub-classes of eSet, like ExpressionSet or AffyBatch should end up calling this method. This method will work as long as there are no additional slots defined in the class (which is why I have a separate LumiBatch-specific method). average.replicates on eSet's does: (1) resizes all elements within AssayData, (which should all be matrix-like, and includes exprs, se.exprs & any other items found), as well as (2) phenoData and (3) protocolData, which indeed are the only elements defined in the eSet interface, which depend on the number of samples.
IF you get an error indicating that not all slots in the result contain the correct number of samples, then you may need to create another S4 method for that particular eSet-sub-class. Use the method implementation for eSet as a starting point, and then the method for LumiBatch as a worked example of an eSet-sub-class with a few additional slots. For (2,3) above, which are AnnotatedDataFrame's the replicate samples are averaged using the average.replicates for AnnotatedDataFrame method.

LumiBatch objects contain a few additional slots in addition to those required by the eSet interface: QC, controlData. Also, one of the assayData slots, detection contains detection p-values which shouldn't really just be averaged. This uses average.pval.replicates to properly average the detection pvalues from LumiBatch objects with replicates.

AnnotatedDataFrame contains 1 row per sample, there's nothing in the spec as to required columns. The default for LumiBatch objects is a single column called sampleID, but this does not have to be the case. It's not clear how to average character values, so we retain the rows for the first sample matching each unique class.

Value

The same data type as x, but with fewer samples, where the replicates have been averaged.

Author(s)

Mark Cowley, 2011-09-01

See Also

average.pval.replicates

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
load("Rmisc/x.norm.RDa.gz")
classes <- sub("\\.[12]$", "", sampleNames(x.norm))

# Matrix example
mat <- exprs(x.norm)
avg <- average.replicates(mat, classes)

# data.frame example
df <- as.data.frame(mat)
df.avg <- average.replicates(df, classes)

# LumiBatch example
x.av <- average.replicates(x.norm, classes)

# AnnotatedDataFrame example
adf <- PhenoData(x.norm)
adf.avg <- average.replicates(adf, classes)
adf.avg
as(adf.avg, "data.frame")

## End(Not run)

drmjc/microarrays documentation built on May 15, 2019, 2:26 p.m.