waldronlab / MultiAssayExperiment

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

All data dropped unless sampleMap provided #291

Closed lwaldron closed 3 years ago

lwaldron commented 3 years ago

As of 1.17.3 (https://github.com/waldronlab/MultiAssayExperiment/issues/287), MAE construction drops all data if sampleMap is not provided, even if ExperimentList colnames can be mapped to colData rownames. For example:

suppressPackageStartupMessages(library(MultiAssayExperiment))
exprss1 <- matrix(rnorm(16), ncol = 4,
                  dimnames = list(sprintf("ENST00000%i", sample(288754:290000, 4)),
                                  c("Jack", "Jill", "Bob", "Bobby")))
exprss2 <- matrix(rnorm(12), ncol = 3,
                  dimnames = list(sprintf("ENST00000%i", sample(288754:290000, 4)),
                                  c("Jack", "Jane", "Bob")))
doubleExp <- list("methyl 2k"  = exprss1, "methyl 3k" = exprss2)
patient.data <- data.frame(sex=c("M", "F", "M", "F"),
                           age=38:41,
                           row.names=c("Jack", "Jill", "Bob", "Barbara"))
doubleExp
#> $`methyl 2k`
#>                         Jack       Jill        Bob       Bobby
#> ENST00000289226 -0.891095277  0.4657854 -0.9058943 -0.57724207
#> ENST00000289025  1.275012571 -1.5994465 -0.7934947  1.87262868
#> ENST00000288882  0.531066848  0.1141618 -0.1785224  0.04596409
#> ENST00000289657 -0.007680015 -1.3818726  1.6230181  0.87131962
#> 
#> $`methyl 3k`
#>                        Jack       Jane        Bob
#> ENST00000289943  0.40976643 -0.1768286 -2.3526097
#> ENST00000289781 -0.38286508 -0.6700528 -0.9337765
#> ENST00000289728 -0.23463424  0.1294052 -1.9588455
#> ENST00000288843 -0.07077102 -0.8307042 -1.9907022
patient.data
#>         sex age
#> Jack      M  38
#> Jill      F  39
#> Bob       M  40
#> Barbara   F  41
simpleMultiAssay2 <- MultiAssayExperiment(experiments=doubleExp,
                                          colData=patient.data)
#> harmonizing input:
#>   removing 4 colData rownames not in sampleMap 'primary'
simpleMultiAssay2
#> A MultiAssayExperiment object of 0 listed
#>  experiments with no user-defined names and respective classes.
#>  Containing an ExperimentList class object of length 0:
#>  Functionality:
#>  experiments() - obtain the ExperimentList instance
#>  colData() - the primary/phenotype DataFrame
#>  sampleMap() - the sample coordination DataFrame
#>  `$`, `[`, `[[` - extract colData columns, subset, or experiment
#>  *Format() - convert into a long or wide DataFrame
#>  assays() - convert ExperimentList to a SimpleList of matrices
#>  exportClass() - save all data to files
colData(simpleMultiAssay2)
#> DataFrame with 0 rows and 2 columns
LiNk-NY commented 3 years ago

Thanks Levi for the detailed example. This should be fixed in 1.17.4 3c9dd3f209467bb9fba0b1af290b90326e3d1dea