combine,RnBSet,RnBSet-method {RnBeads} | R Documentation

## combine-methods

### Description

Combine two objects inheriting from `RnBSet` class

### Usage

    ## S4 method for signature 'RnBSet,RnBSet'
    combine(x, y, type = "all")

### Arguments

`x, y` | `RnBeadSet`, `RnBeadRawSet` or `RnBiseqSet` object
`type` | `character` singleton defining the set operation applied to the two site sets, one of "all", "all.x", "all.y" or "common"

### Details

The sample sets of `x` and `y` should be unique. Sample annotation information is merged only for columns which have identical names in both objects. CpG sites of the new object are a union of those present in both objects.

### Value

combined `RnBeadSet`, `RnBeadRawSet` or `RnBiseqSet` object

### Examples

    library(RnBeads.hg19)
    data(small.example.object)
    r1 <- rnb.set.example
    r1 <- remove.samples(r1,samples(rnb.set.example)[1:5])
    i <- which(r1@sites[,2] == 15 | r1@sites[,2] == 21)
    sites.rem.r1 <- union(sample(1:nrow(meth(rnb.set.example)),500),i)
    r1 <- remove.sites(r1,sites.rem.r1)
    r2 <- rnb.set.example
    r2 <- remove.samples(r2,samples(rnb.set.example)[6:12])
    sites.rem.r2 <- sample(1:nrow(meth(rnb.set.example)),800)
    r2 <- remove.sites(r2,sites.rem.r2)
    rc <- combine(r1,r2)
    #assertion: check the number of sites
    sites.rem.c <- intersect(sites.rem.r1,sites.rem.r2)
    (nrow(meth(rnb.set.example))-length(sites.rem.c)) == nrow(meth(rc))

[Package RnBeads version 2.0.1 Index]