Learn R Programming

Genominator (version 1.26.0)

joinExpData: Merge ExpData objects

Description

This function merges multiple ExpData object into one in an efficient manner.

Usage

joinExpData(expDataList, fields = NULL, tablename = "aggtable", overwrite = TRUE, deleteOriginals = FALSE, verbose = getOption("verbose"))

Arguments

expDataList
List of ExpData objects. Must all be contained in the same database.
fields
A named list whose names correspond to tables of ExpData objects and whose entries indicate the column names to be pulled from each table.
tablename
Name of database table to write output data to.
overwrite
Logical indicating whether database table referred to in tablename argument should be overwritten.
deleteOriginals
Logical indicating whether original database tables in ExpData objects should be deleted.
verbose
Logical indicating whether details should be printed.

Value

An object of class ExpData containing data columns from all the original ExpData objects.

See Also

See Genominator vignette for more information.

Examples

Run this code
N  <- 10000 # the number of observations. 
df1 <- data.frame(chr = sample(1:16, size = N, replace = TRUE),
                 location = sample(1:1000, size = N, replace = TRUE),
                 strand = sample(c(1L,-1L), size = N, replace = TRUE))
df2 <- data.frame(chr = sample(1:16, size = N, replace = TRUE),
                 location = sample(1:1000, size = N, replace = TRUE),
                 strand = sample(c(1L,-1L), size = N, replace = TRUE))

eDataRaw1 <- aggregateExpData(importToExpData(df1, dbFilename = "my.db",
                              tablename = "ex_tbl_1", overwrite = TRUE))
eDataRaw2 <- aggregateExpData(importToExpData(df1, dbFilename = "my.db",
                              tablename = "ex_tbl_2", overwrite = TRUE))
jd <- joinExpData(list(eDataRaw1, eDataRaw2), tablename = "combined", 
                  fields = list("ex_tbl_1" = c("counts" = "e1"),
                                "ex_tbl_2" = c("counts" = "e2")))
head(jd)    

Run the code above in your browser using DataLab