# Getting started with MuData for MultiAssayExperiment

Danila Bredikhin1* and Ilia Kats2**

1European Molecular Biology Laboratory, Heidelberg, Germany
2German Cancer Research Center, Heidelberg, Germany

*danila.bredikhin@embl.de
**i.kats@dkfz-heidelberg.de

#### 2025-11-13

## 1 Introduction

Multimodal data format — MuData — has been introduced to address the need for cross-platform standard for sharing large-scale multimodal omics data. Importantly, it develops ideas of and is compatible with AnnData standard for storing raw and derived data for unimodal datasets.

In Bioconductor, multimodal datasets have been stored in MultiAssayExperiment (MAE) objects. This `MuData` package provides functionality to read data from MuData files into MAE objects as well as to save MAE objects into H5MU files.

## 2 Installation

The most recent dev build can be installed from GitHub:

    library(remotes)
    remotes::install_github("ilia-kats/MuData")

Stable version of `MuData` will be available in future bioconductor versions.

## 3 Loading libraries

    library(MuData)
    library(MultiAssayExperiment)

    library(rhdf5)

## 4 Writing H5MU files

We’ll use a simple MAE object from the `MultiAssayExperiment` package that we’ll then save in a H5MU file.

    data(miniACC)
    miniACC
    #> A MultiAssayExperiment object of 5 listed
    #>  experiments with user-defined names and respective classes.
    #>  Containing an ExperimentList class object of length 5:
    #>  [1] RNASeq2GeneNorm: SummarizedExperiment with 198 rows and 79 columns
    #>  [2] gistict: SummarizedExperiment with 198 rows and 90 columns
    #>  [3] RPPAArray: SummarizedExperiment with 33 rows and 46 columns
    #>  [4] Mutations: matrix with 97 rows and 90 columns
    #>  [5] miRNASeqGene: SummarizedExperiment with 471 rows and 80 columns
    #> 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 data to flat files

We will now write its contents into an H5MU file with `WriteH5MU`:

    writeH5MU(miniACC, "miniacc.h5mu")

## 5 Reading H5MU files

We can manually check the top level of the structure of the file:

    rhdf5::h5ls("miniacc.h5mu", recursive = FALSE)
    #>   group   name     otype dclass dim
    #> 0     /    mod H5I_GROUP
    #> 1     /    obs H5I_GROUP
    #> 2     /   obsm H5I_GROUP
    #> 3     / obsmap H5I_GROUP
    #> 4     /    uns H5I_GROUP
    #> 5     /    var H5I_GROUP

Or dig deeper into the file:

    h5 <- rhdf5::H5Fopen("miniacc.h5mu")
    h5&'mod'
    #> HDF5 GROUP
    #>         name /mod
    #>     filename
    #>
    #>              name     otype dclass dim
    #> 0 Mutations       H5I_GROUP
    #> 1 RNASeq2GeneNorm H5I_GROUP
    #> 2 RPPAArray       H5I_GROUP
    #> 3 gistict         H5I_GROUP
    #> 4 miRNASeqGene    H5I_GROUP
    rhdf5::H5close()

### 5.1 Creating MAE objects from H5MU files

This package provides `ReadH5MU` to create an object with data from an H5MU file. Since H5MU structure has been designed to accommodate more structured information than MAE, only some data will be read. For instance, MAE has no support for loading multimodal embeddings or pairwise graphs.

    acc <- readH5MU("miniacc.h5mu")
    #> Reading as SingleCellExperiment where the original object class is matrix
    #> Warning: sampleMap[['assay']] coerced with as.factor()
    acc
    #> A MultiAssayExperiment object of 5 listed
    #>  experiments with user-defined names and respective classes.
    #>  Containing an ExperimentList class object of length 5:
    #>  [1] RNASeq2GeneNorm: SummarizedExperiment with 198 rows and 79 columns
    #>  [2] gistict: SummarizedExperiment with 198 rows and 90 columns
    #>  [3] RPPAArray: SummarizedExperiment with 33 rows and 46 columns
    #>  [4] Mutations: SingleCellExperiment with 97 rows and 90 columns
    #>  [5] miRNASeqGene: SummarizedExperiment with 471 rows and 80 columns
    #> 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 data to flat files

Importantly, we recover the information from the original MAE object:

    head(colData(miniACC)[,1:4])
    #> DataFrame with 6 rows and 4 columns
    #>                 patientID years_to_birth vital_status days_to_death
    #>               <character>      <integer>    <integer>     <integer>
    #> TCGA-OR-A5J1 TCGA-OR-A5J1             58            1          1355
    #> TCGA-OR-A5J2 TCGA-OR-A5J2             44            1          1677
    #> TCGA-OR-A5J3 TCGA-OR-A5J3             23            0            NA
    #> TCGA-OR-A5J4 TCGA-OR-A5J4             23            1           423
    #> TCGA-OR-A5J5 TCGA-OR-A5J5             30            1           365
    #> TCGA-OR-A5J6 TCGA-OR-A5J6             29            0            NA
    head(colData(acc)[,1:4])
    #> DataFrame with 6 rows and 4 columns
    #>                 patientID years_to_birth vital_status days_to_death
    #>               <character>      <integer>    <integer>       <array>
    #> TCGA-OR-A5J1 TCGA-OR-A5J1             58            1          1355
    #> TCGA-OR-A5J2 TCGA-OR-A5J2             44            1          1677
    #> TCGA-OR-A5J3 TCGA-OR-A5J3             23            0            NA
    #> TCGA-OR-A5J4 TCGA-OR-A5J4             23            1           423
    #> TCGA-OR-A5J5 TCGA-OR-A5J5             30            1           365
    #> TCGA-OR-A5J6 TCGA-OR-A5J6             29            0            NA

Features metadata is also recovered:

    head(rowData(miniACC[["gistict"]]))
    #> DataFrame with 6 rows and 3 columns
    #>        Gene.Symbol    Locus.ID    Cytoband
    #>        <character> <character> <character>
    #> DIRAS3      DIRAS3        9077      1p31.3
    #> MAPK14      MAPK14        1432     6p21.31
    #> YAP1          YAP1       10413     11q22.1
    #> CDKN1B      CDKN1B        1027     12p13.1
    #> ERBB2        ERBB2        2064       17q12
    #> G6PD          G6PD        2539        Xq28
    head(rowData(acc[["gistict"]]))
    #> DataFrame with 6 rows and 3 columns
    #>        Gene.Symbol    Locus.ID    Cytoband
    #>        <character> <character> <character>
    #> DIRAS3      DIRAS3        9077      1p31.3
    #> MAPK14      MAPK14        1432     6p21.31
    #> YAP1          YAP1       10413     11q22.1
    #> CDKN1B      CDKN1B        1027     12p13.1
    #> ERBB2        ERBB2        2064       17q12
    #> G6PD          G6PD        2539        Xq28

#### 5.1.1 Backed objects

It is possible to read H5MU files while keeping matrices (both `.X` and `.layers`) on disk.

    acc_b <- readH5MU("miniacc.h5mu", backed = TRUE)
    #> Reading as SingleCellExperiment where the original object class is matrix
    #> Warning: sampleMap[['assay']] coerced with as.factor()
    assay(acc_b, "RNASeq2GeneNorm")[1:5,1:3]
    #> <5 x 3> DelayedMatrix object of type "double":
    #>        TCGA-OR-A5J1-01A-11R-A29S-07 TCGA-OR-A5J2-01A-11R-A29S-07
    #> DIRAS3                    1487.0317                       9.6631
    #> MAPK14                     778.5783                    2823.6469
    #> YAP1                      1009.6061                    2305.0590
    #> CDKN1B                    2101.3449                    4248.9584
    #> ERBB2                      651.2968                     246.4098
    #>        TCGA-OR-A5J3-01A-11R-A29S-07
    #> DIRAS3                      18.9602
    #> MAPK14                    1061.7686
    #> YAP1                      1561.2502
    #> CDKN1B                    1348.5410
    #> ERBB2                       90.0607

The data in the assay is a `DelayedMatrix` object:

    class(assay(acc_b, "RNASeq2GeneNorm"))
    #> [1] "DelayedMatrix"
    #> attr(,"package")
    #> [1] "DelayedArray"

This is in contrast to the `acc` object that has matrices in memory:

    assay(acc, "RNASeq2GeneNorm")[1:5,1:3]
    #>        TCGA-OR-A5J1-01A-11R-A29S-07 TCGA-OR-A5J2-01A-11R-A29S-07
    #> DIRAS3                    1487.0317                       9.6631
    #> MAPK14                     778.5783                    2823.6469
    #> YAP1                      1009.6061                    2305.0590
    #> CDKN1B                    2101.3449                    4248.9584
    #> ERBB2                      651.2968                     246.4098
    #>        TCGA-OR-A5J3-01A-11R-A29S-07
    #> DIRAS3                      18.9602
    #> MAPK14                    1061.7686
    #> YAP1                      1561.2502
    #> CDKN1B                    1348.5410
    #> ERBB2                       90.0607
    class(assay(acc, "RNASeq2GeneNorm"))
    #> [1] "matrix" "array"

## 6 References

- Muon: multimodal omics analysis framework preprint

- mudata (Python) documentation

- muon documentation and web page

## 7 Session Info

    sessionInfo()
    #> R Under development (unstable) (2025-11-04 r88984)
    #> Platform: aarch64-apple-darwin20
    #> Running under: macOS Ventura 13.7.8
    #>
    #> Matrix products: default
    #> BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    #> LAPACK: /Library/Frameworks/R.framework/Versions/4.6-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
    #>
    #> locale:
    #> [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    #>
    #> time zone: America/New_York
    #> tzcode source: internal
    #>
    #> attached base packages:
    #> [1] stats4    stats     graphics  grDevices utils     datasets  methods
    #> [8] base
    #>
    #> other attached packages:
    #>  [1] SingleCellMultiModal_1.23.0 scater_1.39.0
    #>  [3] ggplot2_4.0.0               scuttle_1.21.0
    #>  [5] CiteFuse_1.23.0             MultiAssayExperiment_1.37.1
    #>  [7] SingleCellExperiment_1.33.0 SummarizedExperiment_1.41.0
    #>  [9] Biobase_2.71.0              GenomicRanges_1.63.0
    #> [11] Seqinfo_1.1.0               IRanges_2.45.0
    #> [13] MatrixGenerics_1.23.0       matrixStats_1.5.0
    #> [15] MuData_1.15.0               rhdf5_2.55.8
    #> [17] S4Vectors_0.49.0            BiocGenerics_0.57.0
    #> [19] generics_0.1.4              Matrix_1.7-4
    #> [21] BiocStyle_2.39.0
    #>
    #> loaded via a namespace (and not attached):
    #>   [1] RColorBrewer_1.1-3       tensorA_0.36.2.1         jsonlite_2.0.0
    #>   [4] magrittr_2.0.4           ggbeeswarm_0.7.2         magick_2.9.0
    #>   [7] farver_2.1.2             rmarkdown_2.30           vctrs_0.6.5
    #>  [10] memoise_2.0.1            tinytex_0.57             BiocBaseUtils_1.13.0
    #>  [13] htmltools_0.5.8.1        S4Arrays_1.11.0          curl_7.0.0
    #>  [16] AnnotationHub_4.1.0      BiocNeighbors_2.5.0      Rhdf5lib_1.33.0
    #>  [19] SparseArray_1.11.1       sass_0.4.10              bslib_0.9.0
    #>  [22] htmlwidgets_1.6.4        httr2_1.2.1              plyr_1.8.9
    #>  [25] plotly_4.11.0            cachem_1.1.0             igraph_2.2.1
    #>  [28] lifecycle_1.0.4          pkgconfig_2.0.3          rsvd_1.0.5
    #>  [31] R6_2.6.1                 fastmap_1.2.0            digest_0.6.38
    #>  [34] AnnotationDbi_1.73.0     dqrng_0.4.1              irlba_2.3.5.1
    #>  [37] ExperimentHub_3.1.0      RSQLite_2.4.4            beachmat_2.27.0
    #>  [40] filelock_1.0.3           labeling_0.4.3           randomForest_4.7-1.2
    #>  [43] httr_1.4.7               polyclip_1.10-7          abind_1.4-8
    #>  [46] compiler_4.6.0           bit64_4.6.0-1            withr_3.0.2
    #>  [49] S7_0.2.0                 BiocParallel_1.45.0      viridis_0.6.5
    #>  [52] DBI_1.2.3                HDF5Array_1.39.0         ggforce_0.5.0
    #>  [55] MASS_7.3-65              bayesm_3.1-7             rappdirs_0.3.3
    #>  [58] DelayedArray_0.37.0      rjson_0.2.23             bluster_1.21.0
    #>  [61] tools_4.6.0              vipor_0.4.7              beeswarm_0.4.0
    #>  [64] glue_1.8.0               h5mread_1.3.0            dbscan_1.2.3
    #>  [67] nlme_3.1-168             rhdf5filters_1.23.0      grid_4.6.0
    #>  [70] Rtsne_0.17               cluster_2.1.8.1          reshape2_1.4.5
    #>  [73] gtable_0.3.6             tidyr_1.3.1              data.table_1.17.8
    #>  [76] BiocSingular_1.27.0      tidygraph_1.3.1          ScaledMatrix_1.19.0
    #>  [79] metapod_1.19.0           XVector_0.51.0           BiocVersion_3.23.1
    #>  [82] ggrepel_0.9.6            pillar_1.11.1            stringr_1.6.0
    #>  [85] limma_3.67.0             robustbase_0.99-6        splines_4.6.0
    #>  [88] dplyr_1.1.4              tweenr_2.0.3             BiocFileCache_3.1.0
    #>  [91] lattice_0.22-7           survival_3.8-3           bit_4.6.0
    #>  [94] compositions_2.0-9       tidyselect_1.2.1         locfit_1.5-9.12
    #>  [97] Biostrings_2.79.2        knitr_1.50               gridExtra_2.3
    #> [100] bookdown_0.45            edgeR_4.9.0              xfun_0.54
    #> [103] graphlayouts_1.2.2       mixtools_2.0.0.1         statmod_1.5.1
    #> [106] DEoptimR_1.1-4           pheatmap_1.0.13          stringi_1.8.7
    #> [109] lazyeval_0.2.2           yaml_2.3.10              evaluate_1.0.5
    #> [112] codetools_0.2-20         kernlab_0.9-33           ggraph_2.2.2
    #> [115] tibble_3.3.0             BiocManager_1.30.26      cli_3.6.5
    #> [118] uwot_0.2.4               segmented_2.1-4          jquerylib_0.1.4
    #> [121] dichromat_2.0-0.1        Rcpp_1.1.0               dbplyr_2.5.1
    #> [124] png_0.1-8                parallel_4.6.0           blob_1.2.4
    #> [127] scran_1.39.0             SpatialExperiment_1.21.0 viridisLite_0.4.2
    #> [130] scales_1.4.0             ggridges_0.5.7           crayon_1.5.3
    #> [133] purrr_1.2.0              rlang_1.1.6              KEGGREST_1.51.0
    #> [136] cowplot_1.2.0