The answer to your first question is a little hidden in the longFormat
section of ?MultiAssayExperiment-helpers
:
longFormat(object, colDataCols = NULL, i = 1L)
wideFormat(object, colDataCols = NULL, check.names = TRUE, collapse = "_", i = 1L)
longFormat
The longFormat method takes data from the ExperimentList in a MultiAssayExperiment and returns a uniform DataFrame. The resulting DataFrame has columns indicating primary, rowname, colname and value. This method can optionally include colData columns with the colDataCols argument (MultiAssayExperiment method only). The ... argument allows the user to specify the assay value for the SummarizedExperiment assay function's i argument.
So you can specify the SummarizedExperiment assay function's i
argument, but it will be the same i
across all SummarizedExperiments. For example:
> example("MultiAssayExperiment")
> mae <- myMultiAssayExperiment[, , c(1, 4)]
> assay(mae[[1]], 2) <- log2(assay(mae[[1]], 1))
> assay(mae[[2]], 2) <- log2(assay(mae[[2]], 1))
> head(wideFormat(mae), 1)
DataFrame with 1 row and 11 columns
primary Affy_ENST00000234812 Affy_ENST00000294241
<character> <numeric> <numeric>
1 Jack 104 101
Affy_ENST00000355076 Affy_ENST00000383323 Affy_ENST00000383706
<numeric> <numeric> <numeric>
1 102 105 103
GISTIC_GENEa GISTIC_GENEb GISTIC_GENEc GISTIC_GENEd GISTIC_GENEe
<numeric> <numeric> <numeric> <numeric> <numeric>
1 1 1 1 0 0
> head(wideFormat(mae, i=2), 1)
DataFrame with 1 row and 11 columns
primary Affy_ENST00000234812 Affy_ENST00000294241
<character> <numeric> <numeric>
1 Jack 6.70043971814109 6.65821148275179
Affy_ENST00000355076 Affy_ENST00000383323 Affy_ENST00000383706
<numeric> <numeric> <numeric>
1 6.6724253419715 6.71424551766612 6.68650052718322
GISTIC_GENEa GISTIC_GENEb GISTIC_GENEc GISTIC_GENEd GISTIC_GENEe
<numeric> <numeric> <numeric> <numeric> <numeric>
1 0 0 0 -Inf -Inf
>
As for your second question, the answer is that if you want both assays extracted by wideFormat
, you'll have to split them into different MAE elements, like this hack-ish example:
> se <- mae[[1]]
> assay(se) <- assay(se, 2)
> mae2 <- c(mae, log2affy=se)
> head(wideFormat(mae2), 1)
DataFrame with 1 row and 16 columns
primary Affy_ENST00000234812 Affy_ENST00000294241
<character> <numeric> <numeric>
1 Jack 104 101
Affy_ENST00000355076 Affy_ENST00000383323 Affy_ENST00000383706
<numeric> <numeric> <numeric>
1 102 105 103
GISTIC_GENEa GISTIC_GENEb GISTIC_GENEc GISTIC_GENEd GISTIC_GENEe
<numeric> <numeric> <numeric> <numeric> <numeric>
1 1 1 1 0 0
log2affy_ENST00000234812 log2affy_ENST00000294241
<numeric> <numeric>
1 6.70043971814109 6.65821148275179
log2affy_ENST00000355076 log2affy_ENST00000383323
<numeric> <numeric>
1 6.6724253419715 6.71424551766612
log2affy_ENST00000383706
<numeric>
1 6.68650052718322
>
Thank you very much Levi!