mergeDGEList: Merge two DGEList objects into one

View source: R/mergeDGEList.R

mergeDGEListR Documentation

Merge two DGEList objects into one

Description

Merge two DGEList objects into one

Usage

mergeDGEList(firstDgeList, secondDgeList, DGEListLabels = NULL)

Arguments

firstDgeList

First DGEList object

secondDgeList

Second DGELIst object

DGEListLabels

Labels, either NULL or a vector of character strings with length two

The function merges two DGEList objects. It does essentially three things:

  • Feature annotationIt extracts the common features from both objects, and use the feature annotation in the firstDgeList object as the annotation for the final object.

  • Sample annotationIt extracts the common columns from sample annotation of both objects, and row-bind them as the annotaiton for the final object.

  • countsMatching final features and samples, the counts matrices are column-binded.

In case DGEListLabels is available, its values will be turned into a factor vector, and appended as the column DGEListLabel in the samples object of the returned value.

Examples

y1 <- matrix(rnbinom(1000, mu=5, size=2), ncol=4)
genes1 <- data.frame(GeneSymbol=sprintf("Gene%d", 1:nrow(y1)))
rownames(y1) <- rownames(genes1) <- 1:nrow(y1)
anno1 <- data.frame(treatment=gl(2,2, labels=c("ctrl", "tmt")),
    donor=factor(rep(c(1,2), each=2)))
d1 <- DGEList(counts=y1, genes=genes1, samples=anno1)

y2 <- matrix(rnbinom(1000, mu=5, size=2), ncol=4)
genes2 <- data.frame(GeneSymbol=sprintf("Gene%d", 1:nrow(y2)+100))
rownames(y2) <- rownames(genes1) <- 1:nrow(y2)+100
anno2 <- data.frame(treatment=gl(2,2, labels=c("ctrl", "tmt")),
    sex=factor(rep(c("m", "f"), each=2)))
d2 <- DGEList(counts=y2, genes=genes2, samples=anno2)

md <- mergeDGEList(d1, d2)
md2 <- mergeDGEList(d1, d2, DGEListLabels=c("d1", "d2"))


bedapub/ribiosNGS documentation built on Feb. 10, 2025, 12:34 a.m.