rowsum {edgeR} | R Documentation

## Sum Over Groups of Genes

### Description

Condense the rows of a DGEList object so that counts are summed over specified groups of genes.

### Usage

    ## S3 method for class 'DGEList'
    rowsum(x, group, reorder = FALSE, na.rm=FALSE, ...)

### Arguments

`x` | a `DGEList` object
`group` | a vector or factor giving the grouping, with one element per row of `x`. Missing values will be treated as another group and a warning will be given.
`reorder` | if `TRUE`, then the row.names of the resulting DGEList will be in order of `sort(unique(group))`, if `FALSE`, they will be in the order that groups were encountered.
`na.rm` | logical (`TRUE` or `FALSE`). Should `NA` (including `NaN`) values be discarded?
`...` | other arguments are not currently used

### Details

A new `DGEList` object is computed, with the same columns as `x`, but for which the rows correspond to the unique values of `group`. The counts for rows with the same `group` value are summed.

Columns of `x$genes` will be retained in the output if they contain group-level annotation. Columns that vary within groups will be dropped.

### Value

`DGEList` object with the same number of columns as `x` and rows corresponding to the unique values of `group`.

### Author(s)

Gordon Smyth

### See Also

`rowsum` in the base package.

### Examples

    x <- DGEList(counts=matrix(1:8,4,2))
    rowsum(x, group=c("A","A","B","B"))

[Package edgeR version 3.28.1 Index]