reduce: Reducing a SummarizedExperiment by combinding replicates

Description Usage Arguments Details Value Methods and Functions Author(s) See Also Examples

Description

This function combines values in the assays slot for replicates e.g. of counts of the same biological sample sequenced on different lanes.

Usage

1
2
3
4
5
## S4 method for signature 'RangedSummarizedExperiment'
reduce(x, by, collapse=";", FUN=rowSums)

## S4 method for signature 'SummarizedExperiment0'
reduce(x, by, collapse=";", FUN=rowSums)

Arguments

x

The RangedSummarizedExperiment or SummarizedExperiment0 (defined in the SummarizedExperiment package) that should be reduced.

by

Either a character of length 1 specifying the column in colData(x) or a vector of the same length than colnames(x) that defines the replicates. Replicates that should be merged are assumed to be identified by e.g. the same value in by.

collapse

A character of length 1 to be used as a separator for values in columns of colData(x) that are not unique for the same replicate.

seed

The seed for the random number generator.

x

The BAM file name or a BamFile object.

Details

This function combines values from replicates in a SummarizedExperiment identified by the argument by. By default, for each row, the values of replicates are summed (assuming count data). The argument FUN however allows to apply a different aggregation function. Also, by default, the same aggregation function is applied to all assays in x. Different aggregation functions can be applied by specifying several functions, where the number of specified functions has to match length(assays(x)); functions are applied in sequential order, i.e. the first function is applied to the first assay (assays(x)[1]), the second to the second and so on.

In addition to the combination of assay data, also the colData is reduced to fit the number of unique replicates (length(unique(by))). Values in columns with non-unique values for the same replicate are collapsed using the characted defined by collapse as separator between the unique values. The original colnames of the object are collapsed in a column added to the colData named "collapsed".

Value

A SummarizedExperiment0 or RangedSummarizedExperiment.

Methods and Functions

sampleBam

the function samples the specified fraction of reads from the Bam file. The returned object is a list of lists. For more details please see the help of the scanBam function.

Author(s)

Johannes Rainer

See Also

SummarizedExperiment

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
nrows <- 200
ncols <- 6
counts <- matrix(runif(nrows * ncols, 1, 1e4), nrows)
colData <- DataFrame(Treatment=rep(c("ChIP", "Input"), 3),
                     name=c("ChIP.a", "Input.a", "ChIP.b",
                            "Input.b", "ChIP.a", "Input.a"),
                     row.names=LETTERS[1:6])
se0 <- SummarizedExperiment(assays=SimpleList(counts=counts),
                            colData=colData)

## sum assay values of replicates identified by column "name"
## in the colData.
ser <- reduce(se0, by="name")
colData(ser)
colnames(ser)

## alternatively use a vector of length=length(colnames(se0))
set <- reduce(se0, by=c(1, 2, 1, 2, 3, 4))

jotsetung/SeqUtils documentation built on May 19, 2019, 9:41 p.m.