Learn R Programming

methylKit (version 0.99.2)

reorganize: Reorganize methylKit objects by creating new objects from subset of samples

Description

The function creates a new methylRawList, methylRawListDB, methylBase or methylBaseDB object by selecting a subset of samples from the input object, which is a methylRawList or methylBase object. You can use the function to partition a large methylRawList or methylBase object to smaller object based on sample ids or when you want to reorder samples and/or give a new treatmet vector.

Usage

reorganize(methylObj, sample.ids, treatment, chunk.size = 1e+06,
  save.db = FALSE, ...)

# S4 method for methylBase reorganize(methylObj, sample.ids, treatment, chunk.size = 1e+06, save.db = FALSE, ...)

# S4 method for methylRawList reorganize(methylObj, sample.ids, treatment, chunk.size = 1e+06, save.db = FALSE, ...)

# S4 method for methylRawListDB reorganize(methylObj, sample.ids, treatment, chunk.size = 1e+06, save.db = TRUE, ...)

# S4 method for methylBaseDB reorganize(methylObj, sample.ids, treatment, chunk.size = 1e+06, save.db = TRUE, ...)

Arguments

methylObj

a methylRawList, methylRawListDB, methylBase or methylBaseDB object

sample.ids

a vector for sample.ids to be subset. Order is important and the order should be similar to treatment. sample.ids should be a subset or reordered version of sample ids in the input object.

treatment

treatment vector, should be same length as sample.ids vector

chunk.size

Number of rows to be taken as a chunk for processing the methylBaseDB or methylRawListDB objects, default: 1e6

save.db

A Logical to decide whether the resulting object should be saved as flat file database or not, default: explained in Details sections

...

optional Arguments used when save.db is TRUE

suffix A character string to append to the name of the output flat file database, only used if save.db is true, default actions: append “_filtered” to current filename if database already exists or generate new file with filename “sampleID_filtered”

dbdir The directory where flat file database(s) should be stored, defaults to getwd(), working directory for newly stored databases and to same directory for already existing database dbtype The type of the flat file database, currently only option "tabix"

Value

returns a methylRawList, methylRawListDB, methylBase or methylBaseDB object depending on the input object

Details

The parameter chunk.size is only used when working with methylBaseDB or methylRawListDB objects, as they are read in chunk by chunk to enable processing large-sized objects which are stored as flat file database. Per default the chunk.size is set to 1M rows, which should work for most systems. If you encounter memory problems or have a high amount of memory available feel free to adjust the chunk.size.

The parameter save.db is per default TRUE for methylDB objects as methylBaseDB and methylRawListDB, while being per default FALSE for methylBase and methylRawList. If you wish to save the result of an in-memory-calculation as flat file database or if the size of the database allows the calculation in-memory, then you might want to change the value of this parameter.

Examples

Run this code
# NOT RUN {
# this is a list of example files, ships with the package
file.list=list( system.file("extdata", "test1.myCpG.txt", package = "methylKit"),
               system.file("extdata", "test2.myCpG.txt", package = "methylKit"),
               system.file("extdata", "control1.myCpG.txt", package = "methylKit"),
               system.file("extdata", "control2.myCpG.txt", package = "methylKit") )


# read the files to a methylRawList object: myobj
myobj=methRead( file.list,
          sample.id=list("test1","test2","ctrl1","ctrl2"),
          assembly="hg18",pipeline="amp",treatment=c(1,1,0,0))
meth=unite(myobj,destrand=TRUE)

# get samples named "test1" and "ctrl2" from myobj and create a new methylRawList object
myobj2=reorganize(myobj,sample.ids=c("test1","ctrl2"),treatment=c(1,0) )

# # get samples named "test1" and "ctrl2" from meth and create a new methylBase object
meth2 =reorganize(meth,sample.ids=c("test1","ctrl2"),treatment=c(1,0) )


# }

Run the code above in your browser using DataLab