waldronlab / MultiAssayExperiment

Bioconductor package for management of multi-assay data
https://waldronlab.io/MultiAssayExperiment/
69 stars 32 forks source link

`c` method for `MultiAssayExperiment` #143

Closed LiNk-NY closed 6 years ago

LiNk-NY commented 8 years ago

A "concatenate" or "combine" method for the MultiAssayExperiment class. It should modify sampleMap and pData on the fly

lwaldron commented 7 years ago

"bumping" this issue. Perhaps start with a addExperiment function, that takes two required arguments (a MAE and an object of a supported class), plus optional arguments to resolve potential ambiguity in the sampleMap. A "sampleMap" argument could specify the sampleMap for the additional samples, and a "sampleMapFrom" argument could specify an existing experiment as a template. With neither specified, existing sampleMap rows could be used if the column names of the new assay can be unambiguously mapped. There is no ambiguity if:

  1. you subset the existing sampleMap to rows where the assay column matches column names in the new assay
  2. take unique rows of this subsetted sampleMap
  3. there are no duplicates in the assay column of the subsetted sampleMap
LiNk-NY commented 7 years ago

@lwaldron: add a warning to mapFrom argument use

LiNk-NY commented 6 years ago

This was added in b62037c7.

lwaldron commented 6 years ago

The documentation on this isn't clear to me, from ?MultiAssayExperiment-class:

The dots (...) argument allows the user to specify additional arguments in several instances. When subsetting ([) a MultiAssayExperiment, the dots allow for additional arguments to be sent to findOverlaps. When using the mergeReplicates method, the dots are used to specify arguments for the supplied simplify argument and function. When using the assay method. When using c method to add experiments to a MultiAssayExperiment, the dots allow extra data classes compatible with the MultiAssayExperiment API. See the MultiAssayExperiment API

A couple things that seem possible from this documentation don't work:

library(MultiAssayExperiment)
library(SummarizedExperiment)
example("MultiAssayExperiment")
se <- myMultiAssayExperiment[["Affy"]]
assay(se) <- log2(assay(se))
c(myMultiAssayExperiment, ExperimentList(log2affy=se))
c(myMultiAssayExperiment, se)

first gives Error in .generateMap(colData(x), newExperiments): no way to map colData to ExperimentList and second gives Error in validObject(.Object): invalid class “ExperimentList” object: ExperimentList elements must be named.

(side note: When using the assay method. in above documentation is truncated)

LiNk-NY commented 6 years ago

When introducing a new experiment, you would have to provide the sampleMap since there is no way to know how the experiment maps to the colData. I have provided the convenience argument mapFrom which will work as:

c(myMultiAssayExperiment, ExperimentList(log2affy=se), mapFrom = "Affy")

You can also do:

c(myMultiAssayExperiment, log2affy = se, mapFrom = 1L)

Regards, Marcel

lwaldron commented 6 years ago

What about the above comment?

There is no ambiguity if:

  1. you subset the existing sampleMap to rows where the assay column matches column names in the new assay
  2. take unique rows of this subsetted sampleMap
  3. there are no duplicates in the assay column of the subsetted sampleMap
LiNk-NY commented 6 years ago

This sounds good. I'll work on this soon. Thanks!