Accessing and modifying information in MultiAssayExperiment
Source:R/MultiAssayExperiment-class.R
, R/MultiAssayExperiment-methods.R
MultiAssayExperiment-methods.Rd
A set of accessor and setter generic functions to extract
either the sampleMap
, the ExperimentList
,
colData
, or metadata
slots of a
MultiAssayExperiment
object
Usage
# S4 method for class 'MultiAssayExperiment'
sampleMap(x)
# S4 method for class 'MultiAssayExperiment'
experiments(x)
# S4 method for class 'MultiAssayExperiment'
colData(x, ...)
# S4 method for class 'MultiAssayExperiment'
drops(x)
# S4 method for class 'MultiAssayExperiment,DataFrame'
sampleMap(object) <- value
# S4 method for class 'MultiAssayExperiment,ANY'
sampleMap(object) <- value
drops(x, ...) <- value
# S4 method for class 'MultiAssayExperiment,ExperimentList'
experiments(object) <- value
# S4 method for class 'MultiAssayExperiment,List'
experiments(object) <- value
# S4 method for class 'MultiAssayExperiment,DataFrame'
colData(x) <- value
# S4 method for class 'MultiAssayExperiment,ANY'
colData(x) <- value
# S4 method for class 'MultiAssayExperiment'
drops(x, ...) <- value
# S4 method for class 'MultiAssayExperiment'
x$name <- value
# S4 method for class 'MultiAssayExperiment'
names(x) <- value
# S4 method for class 'MultiAssayExperiment,List'
colnames(x) <- value
# S4 method for class 'MultiAssayExperiment,list'
colnames(x) <- value
# S4 method for class 'MultiAssayExperiment'
x$name
# S4 method for class 'MultiAssayExperiment'
metadata(x, ...)
# S4 method for class 'MultiAssayExperiment'
metadata(x, ...) <- value
Value
Accessors: Either a sampleMap
, ExperimentList
, or
DataFrame
object
Setters: A MultiAssayExperiment
object
Accessors
Eponymous names for accessing MultiAssayExperiment
slots with the
exception of the ExperimentList
accessor named experiments
.
colData: Access the
colData
slotsampleMap: Access the
sampleMap
slotexperiments: Access the
ExperimentList
slot[[
: Access theExperimentList
slot$
: Access a column incolData
drops
: Get a vector of droppedExperimentList
names
Setters
Setter method values (i.e., 'function(x) <- value
'):
experiments<-: An
ExperimentList
object containing experiment data of supported classessampleMap<-: A
DataFrame
object relating samples to biological units and assayscolData<-: A
DataFrame
object describing the biological unitsmetadata<-: A
list
object of metadata[[<-
: Equivalent to theexperiments<-
setter method for convenience$<-
: A vector to replace the indicated column incolData
drops<-
: TraceExperimentList
names that have been removed
Examples
## Load example MultiAssayExperiment
example(MultiAssayExperiment)
#>
#> MltAsE> ## Run the example ExperimentList
#> MltAsE> 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)
#>
#> MltAsE> ## Create sample maps for each experiment
#> MltAsE> exprmap <- data.frame(
#> MltAsE+ primary = c("Jack", "Jill", "Barbara", "Bob"),
#> MltAsE+ colname = c("array1", "array2", "array3", "array4"),
#> MltAsE+ stringsAsFactors = FALSE)
#>
#> MltAsE> methylmap <- data.frame(
#> MltAsE+ primary = c("Jack", "Jack", "Jill", "Barbara", "Bob"),
#> MltAsE+ colname = c("methyl1", "methyl2", "methyl3", "methyl4", "methyl5"),
#> MltAsE+ stringsAsFactors = FALSE)
#>
#> MltAsE> rnamap <- data.frame(
#> MltAsE+ primary = c("Jack", "Jill", "Bob", "Barbara"),
#> MltAsE+ colname = c("samparray1", "samparray2", "samparray3", "samparray4"),
#> MltAsE+ stringsAsFactors = FALSE)
#>
#> MltAsE> gistmap <- data.frame(
#> MltAsE+ primary = c("Jack", "Bob", "Jill"),
#> MltAsE+ colname = c("samp0", "samp1", "samp2"),
#> MltAsE+ stringsAsFactors = FALSE)
#>
#> MltAsE> ## Combine as a named list and convert to a DataFrame
#> MltAsE> maplist <- list(Affy = exprmap, Methyl450k = methylmap,
#> MltAsE+ RNASeqGene = rnamap, GISTIC = gistmap)
#>
#> MltAsE> ## Create a sampleMap
#> MltAsE> sampMap <- listToMap(maplist)
#>
#> MltAsE> ## Create an example phenotype data
#> MltAsE> colDat <- data.frame(sex = c("M", "F", "M", "F"), age = 38:41,
#> MltAsE+ row.names = c("Jack", "Jill", "Bob", "Barbara"))
#>
#> MltAsE> ## Create a MultiAssayExperiment instance
#> MltAsE> mae <- MultiAssayExperiment(experiments = ExpList, colData = colDat,
#> MltAsE+ sampleMap = sampMap)
## Access the sampleMap
sampleMap(mae)
#> DataFrame with 16 rows and 3 columns
#> assay primary colname
#> <factor> <character> <character>
#> 1 Affy Jack array1
#> 2 Affy Jill array2
#> 3 Affy Barbara array3
#> 4 Affy Bob array4
#> 5 Methyl450k Jack methyl1
#> ... ... ... ...
#> 12 RNASeqGene Bob samparray3
#> 13 RNASeqGene Barbara samparray4
#> 14 GISTIC Jack samp0
#> 15 GISTIC Bob samp1
#> 16 GISTIC Jill samp2
## Replacement method for a MultiAssayExperiment sampleMap
sampleMap(mae) <- S4Vectors::DataFrame()
#> harmonizing input:
#> removing 4 colData rownames not in sampleMap 'primary'
## Access the ExperimentList
experiments(mae)
#> ExperimentList class object of length 0:
#>
## Replace with an empty ExperimentList
experiments(mae) <- ExperimentList()
## Access the metadata
metadata(mae)
#> list()
## Replace metadata with a list
metadata(mae) <- list(runDate =
format(Sys.time(), "%B %d, %Y"))
## Access the colData
colData(mae)
#> DataFrame with 0 rows and 2 columns
## Access a column in colData
mae$age
#> integer(0)
## Replace a column in colData
mae$age <- mae$age + 1