Skip to contents

The constructor function for the MultiAssayExperiment combines multiple data elements from the different hierarchies of data (study, experiments, and samples). It can create instances where neither a sampleMap or a colData set is provided. Please see the MultiAssayExperiment API documentation for more information.

Usage

MultiAssayExperiment(
  experiments = ExperimentList(),
  colData = S4Vectors::DataFrame(),
  sampleMap = S4Vectors::DataFrame(assay = factor(), primary = character(), colname =
    character()),
  metadata = list(),
  drops = list()
)

Arguments

experiments

A list or ExperimentList of all combined experiments

colData

A DataFrame or data.frame of characteristics for all biological units

sampleMap

A DataFrame or data.frame of assay names, sample identifiers, and colname samples

metadata

An optional argument of "ANY" class (usually list) for content describing the experiments

drops

A list of unmatched information (included after subsetting)

Value

A MultiAssayExperiment object that can store experiment and phenotype data

colData

The colData input can be either DataFrame or data.frame with subsequent coercion to DataFrame. The rownames in the colData must match the colnames in the experiments if no sampleMap is provided.

experiments

The experiments input can be of class SimpleList or list. This input becomes the ExperimentList. Each element of the input list or List must be named, rectangular with two dimensions, and have dimnames.

sampleMap

The sampleMap can either be input as DataFrame or data.frame with eventual coercion to DataFrame. The sampleMap relates biological units and biological measurements within each assay. Each row in the sampleMap is a single such link. The standard column names of the sampleMap are "assay", "primary", and "colname". Note that the "assay" column is a factor corresponding to the names of each experiment in the ExperimentList. In the case where these names do not match between the sampleMap and the experiments, the documented experiments in the sampleMap take precedence and experiments are dropped by the harmonization procedure. The constructor function will generate a sampleMap in the case where it is not provided and this method may be a 'safer' alternative for creating the MultiAssayExperiment (so long as the rownames are identical in the colData, if provided). An empty sampleMap may produce empty experiments if the levels of the "assay" factor in the sampleMap do not match the names in the ExperimentList.

Examples

## Run the example ExperimentList
example("ExperimentList")
#> 
#> ExprmL> ## Create an empty ExperimentList instance
#> ExprmL> ExperimentList()
#> ExperimentList class object of length 0:
#>  
#> ExprmL> ## Create array matrix and AnnotatedDataFrame to create an ExpressionSet class
#> ExprmL> arraydat <- matrix(data = seq(101, length.out = 20), ncol = 4,
#> ExprmL+     dimnames = list(
#> ExprmL+         c("ENST00000294241", "ENST00000355076",
#> ExprmL+         "ENST00000383706","ENST00000234812", "ENST00000383323"),
#> ExprmL+         c("array1", "array2", "array3", "array4")
#> ExprmL+     ))
#> 
#> ExprmL> colDat <- data.frame(slope53 = rnorm(4),
#> ExprmL+     row.names = c("array1", "array2", "array3", "array4"))
#> 
#> ExprmL> ## SummarizedExperiment constructor
#> ExprmL> exprdat <- SummarizedExperiment::SummarizedExperiment(arraydat,
#> ExprmL+     colData = colDat)
#> 
#> ExprmL> ## Create a sample methylation dataset
#> ExprmL> methyldat <- matrix(data = seq(1, length.out = 25), ncol = 5,
#> ExprmL+     dimnames = list(
#> ExprmL+         c("ENST00000355076", "ENST00000383706",
#> ExprmL+           "ENST00000383323", "ENST00000234812", "ENST00000294241"),
#> ExprmL+         c("methyl1", "methyl2", "methyl3",
#> ExprmL+           "methyl4", "methyl5")
#> ExprmL+     ))
#> 
#> ExprmL> ## Create a sample RNASeqGene dataset
#> ExprmL> rnadat <- matrix(
#> ExprmL+     data = sample(c(46851, 5, 19, 13, 2197, 507,
#> ExprmL+         84318, 126, 17, 21, 23979, 614), size = 20, replace = TRUE),
#> ExprmL+     ncol = 4,
#> ExprmL+     dimnames = list(
#> ExprmL+         c("XIST", "RPS4Y1", "KDM5D", "ENST00000383323", "ENST00000234812"),
#> ExprmL+         c("samparray1", "samparray2", "samparray3", "samparray4")
#> ExprmL+     ))
#> 
#> ExprmL> ## Create a mock RangedSummarizedExperiment from a data.frame
#> ExprmL> rangedat <- data.frame(chr="chr2", start = 11:15, end = 12:16,
#> ExprmL+     strand = c("+", "-", "+", "*", "."),
#> ExprmL+     samp0 = c(0,0,1,1,1), samp1 = c(1,0,1,0,1), samp2 = c(0,1,0,1,0),
#> ExprmL+     row.names = c(paste0("ENST", "00000", 135411:135414), "ENST00000383323"))
#> 
#> ExprmL> rangeSE <- SummarizedExperiment::makeSummarizedExperimentFromDataFrame(rangedat)
#> 
#> ExprmL> ## Combine to a named list and call the ExperimentList constructor function
#> ExprmL> assayList <- list(Affy = exprdat, Methyl450k = methyldat, RNASeqGene = rnadat,
#> ExprmL+                 GISTIC = rangeSE)
#> 
#> ExprmL> ## Use the ExperimentList constructor
#> ExprmL> ExpList <- ExperimentList(assayList)

## Create sample maps for each experiment
exprmap <- data.frame(
    primary = c("Jack", "Jill", "Barbara", "Bob"),
    colname = c("array1", "array2", "array3", "array4"),
    stringsAsFactors = FALSE)

methylmap <- data.frame(
    primary = c("Jack", "Jack", "Jill", "Barbara", "Bob"),
    colname = c("methyl1", "methyl2", "methyl3", "methyl4", "methyl5"),
    stringsAsFactors = FALSE)

rnamap <- data.frame(
    primary = c("Jack", "Jill", "Bob", "Barbara"),
    colname = c("samparray1", "samparray2", "samparray3", "samparray4"),
    stringsAsFactors = FALSE)

gistmap <- data.frame(
    primary = c("Jack", "Bob", "Jill"),
    colname = c("samp0", "samp1", "samp2"),
    stringsAsFactors = FALSE)

## Combine as a named list and convert to a DataFrame
maplist <- list(Affy = exprmap, Methyl450k = methylmap,
    RNASeqGene = rnamap, GISTIC = gistmap)

## Create a sampleMap
sampMap <- listToMap(maplist)
## Create an example phenotype data
colDat <- data.frame(sex = c("M", "F", "M", "F"), age = 38:41,
    row.names = c("Jack", "Jill", "Bob", "Barbara"))

## Create a MultiAssayExperiment instance
mae <- MultiAssayExperiment(experiments = ExpList, colData = colDat,
    sampleMap = sampMap)