waldronlab / MultiAssayExperiment

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

Unexpected behavior after recursive call to `subsetByColData` #302

Closed cvanderaa closed 3 years ago

cvanderaa commented 3 years ago

Hello,

Calling the subsetByColData two times leads to dropping assays when empty assay are generated after the first call. Here is an example:

library(MultiAssayExperiment)
example("MultiAssayExperiment")
(mae <- subsetByColData(mae, mae$age > 40 ))
harmonizing input:
  removing 1 sampleMap rows with 'colname' not in colnames of experiments
A MultiAssayExperiment object of 4 listed
 experiments with user-defined names and respective classes.
 Containing an ExperimentList class object of length 4:
 [1] Affy: SummarizedExperiment with 5 rows and 1 columns
 [2] Methyl450k: matrix with 5 rows and 1 columns
 [3] RNASeqGene: matrix with 5 rows and 1 columns
 [4] GISTIC: RangedSummarizedExperiment with 5 rows and 0 columns

Up to here, everything behaves as expected. The GISTIC assay does not contain a patient with age over 40, therefore it has 0 columns. Now let's reapply the subsetting:

(mae <- subsetByColData(mae, mae$age > 40 ))
A MultiAssayExperiment object of 3 listed
 experiments with user-defined names and respective classes.
 Containing an ExperimentList class object of length 3:
 [1] Affy: SummarizedExperiment with 5 rows and 1 columns
 [2] Methyl450k: matrix with 5 rows and 1 columns
 [3] RNASeqGene: matrix with 5 rows and 1 columns

Here, the GISTIC assay disappeared. Since we apply twice the exact same subsetting, I would expect this output to stay identical to the first output. Note that this observation holds even when the subsetting condition (the logical vector) is different in the second call.

LiNk-NY commented 3 years ago

Hi Chris, @cvanderaa Thanks for pointing this out. I have a patch ready but I will have to do more testing before pushing. See the nodrop branch. Best, Marcel

LiNk-NY commented 3 years ago

Hi Chris, @cvanderaa I've merged the branch and it should be resolved. Thanks! -Marcel

cvanderaa commented 3 years ago

Hi Marcel, @LiNk-NY Thanks a lot for the fix!