merge-methods: Merge a subset of the rows or columns of a...

merge-methodsR Documentation

Merge a subset of the rows or columns of a SummarizedExperiment

Description

mergeRows/mergeCols merge data on rows or columns of a SummarizedExperiment as defined by a factor alongside the chosen dimension. Metadata from the rowData or colData are retained as defined by archetype.

Usage

mergeRows(x, f, archetype = 1L, ...)

mergeCols(x, f, archetype = 1L, ...)

mergeFeatures(x, f, archetype = 1L, ...)

mergeSamples(x, f, archetype = 1L, ...)

## S4 method for signature 'SummarizedExperiment'
mergeRows(x, f, archetype = 1L, ...)

## S4 method for signature 'SummarizedExperiment'
mergeCols(x, f, archetype = 1L, ...)

## S4 method for signature 'SummarizedExperiment'
mergeFeatures(x, f, archetype = 1L, ...)

## S4 method for signature 'SummarizedExperiment'
mergeSamples(x, f, archetype = 1L, ...)

## S4 method for signature 'TreeSummarizedExperiment'
mergeRows(x, f, archetype = 1L, mergeTree = FALSE, mergeRefSeq = FALSE, ...)

## S4 method for signature 'TreeSummarizedExperiment'
mergeCols(x, f, archetype = 1L, mergeTree = FALSE, ...)

## S4 method for signature 'TreeSummarizedExperiment'
mergeFeatures(
  x,
  f,
  archetype = 1L,
  mergeTree = FALSE,
  mergeRefSeq = FALSE,
  ...
)

## S4 method for signature 'TreeSummarizedExperiment'
mergeSamples(x, f, archetype = 1L, mergeTree = FALSE, ...)

Arguments

x

a SummarizedExperiment or a TreeSummarizedExperiment

f

A factor for merging. Must be the same length as nrow(x)/ncol(x). Rows/Cols corresponding to the same level will be merged. If length(levels(f)) == nrow(x)/ncol(x), x will be returned unchanged.

archetype

Of each level of f, which element should be regarded as the archetype and metadata in the columns or rows kept, while merging? This can be single integer value or an integer vector of the same length as levels(f). (Default: archetype = 1L, which means the first element encountered per factor level will be kept)

...

Optional arguments:

  • Passed on to sumCountsAcrossFeatures, with the exception of subset_row, subset_col

mergeTree

TRUE or FALSE: Should rowTree() also be merged? (Default: mergeTree = FALSE)

mergeRefSeq

TRUE or FALSE: Should a consensus sequence be calculated? If set to FALSE, the result from archetype is returned; If set to TRUE the result from DECIPHER::ConsensusSequence is returned. (Default: mergeRefSeq = FALSE)

Details

assay are agglomerated, i.e. summed up. If the assay contains values other than counts or absolute values, this can lead to meaningless values being produced.

These functions are similar to sumCountsAcrossFeatures. However, additional support for TreeSummarizedExperiment was added and science field agnostic names were used. In addition the archetype argument lets the user select how to preserve row or column data.

For merge data of assays the function from scuttle are used.

Value

An object of the same class as x with the specified entries merged into one entry in all relevant components.

See Also

sumCountsAcrossFeatures

Examples

data(esophagus)
esophagus
plot(rowTree(esophagus))
# get a factor for merging
f <- factor(regmatches(rownames(esophagus),
                       regexpr("^[0-9]*_[0-9]*",rownames(esophagus))))
merged <- mergeRows(esophagus,f, mergeTree = TRUE)
plot(rowTree(merged))
#
data(GlobalPatterns)
GlobalPatterns
merged <- mergeCols(GlobalPatterns,colData(GlobalPatterns)$SampleType)
merged

microbiome/mia documentation built on April 27, 2024, 4:04 a.m.