0.1 Introduction

CITE-seq data provide RNA and surface protein counts for the same cells. This tutorial shows how MuData can be integrated into with Bioconductor workflows to analyse CITE-seq data.

0.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.

0.3 Loading libraries

library(MuData)
library(SingleCellExperiment)
library(MultiAssayExperiment)
library(SingleCellMultiModal)
library(scater)

library(rhdf5)

0.4 Loading data

We will use CITE-seq data accessible with the SingleCellMultiModal Bioconductor package, which was originally described in Stoeckius et al., 2017.

mae <- CITEseq(
    DataType="cord_blood", modes="*", dry.run=FALSE, version="1.0.0"
)
#> Dataset: cord_blood
#> Working on: scADT_Counts
#> Working on: scRNAseq_Counts
#> Working on: coldata_scRNAseq
#> Working on: scADT_clrCounts
#> see ?SingleCellMultiModal and browseVignettes('SingleCellMultiModal') for documentation
#> loading from cache
#> see ?SingleCellMultiModal and browseVignettes('SingleCellMultiModal') for documentation
#> loading from cache
#> see ?SingleCellMultiModal and browseVignettes('SingleCellMultiModal') for documentation
#> loading from cache
#> see ?SingleCellMultiModal and browseVignettes('SingleCellMultiModal') for documentation
#> loading from cache
#> Warning: 'ExperimentList' contains 'data.frame' or 'DataFrame',
#>   potential for errors with mixed data types
#> harmonizing input:
#>   removing 2277 sampleMap rows with 'primary' not in colData

mae
#> A MultiAssayExperiment object of 3 listed
#>  experiments with user-defined names and respective classes.
#>  Containing an ExperimentList class object of length 3:
#>  [1] scADT_clr: matrix with 13 rows and 7858 columns
#>  [2] scADT: matrix with 13 rows and 7858 columns
#>  [3] scRNAseq: matrix with 36280 rows and 7858 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 see two modalities in the object — scRNAseq and scADT, the latter providing counts for antibody-derived tags. Notably, each experiment is a matrix.

0.5 Processing ADT data

While CITE-seq analysis workflows such as CiteFuse should be consulted for more details, below we exemplify simple data transformation in order to demonstrate how their output can be saved to an H5MU file later on.

For ADT counts, we will apply CLR transformation following Hao et al., 2020:

# Define CLR transformation as in the Seurat workflow
clr <- function(data) t(
  apply(data, 1, function(x) log1p(
    x / (exp(sum(log1p(x[x > 0]), na.rm = TRUE) / length(x)))
  ))
)

We will make the ADT modality a SingleCellExperiment object and add an assay with CLR-transformed counts:

adt_counts <- mae[["scADT"]]

mae[["scADT"]] <- SingleCellExperiment(adt_counts)
assay(mae[["scADT"]], "clr") <- clr(adt_counts)

We will also generate reduced dimensions taking advantage of the functionality in the scater package:

mae[["scADT"]] <- runPCA(
  mae[["scADT"]], exprs_values = "clr", ncomponents = 20
)
#> Warning in check_numbers(k = k, nu = nu, nv = nv, limit = min(dim(x)) - : more
#> singular values/vectors requested than available
#> Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
#> TRUE, : You're computing too large a percentage of total singular values, use a
#> standard svd instead.
#> Warning in (function (A, nv = 5, nu = nv, maxit = 1000, work = nv + 7, reorth =
#> TRUE, : did not converge--results might be invalid!; try increasing work or
#> maxit
plotReducedDim(mae[["scADT"]], dimred = "PCA",
               by_exprs_values = "clr", colour_by = "CD3")

plotReducedDim(mae[["scADT"]], dimred = "PCA",
               by_exprs_values = "clr", colour_by = "CD14")

0.6 Writing H5MU files

We can write the contents of the MultiAssayExperiment object into an H5MU file:

writeH5MU(mae, "cord_blood_citeseq.h5mu")

We can check that both modalities were written to the file, whether it was a matrix for RNA or SingleCellExperiment for ADT:

h5 <- rhdf5::H5Fopen("cord_blood_citeseq.h5mu")
h5ls(H5Gopen(h5, "mod"), recursive = FALSE)
#>   group      name     otype dclass dim
#> 0     /     scADT H5I_GROUP           
#> 1     / scADT_clr H5I_GROUP           
#> 2     /  scRNAseq H5I_GROUP

… both assays for ADT — raw counts are stored in X and CLR-transformed counts are in the corresponding layer:

h5ls(H5Gopen(h5, "mod/scADT"), recursive = FALSE)
#>   group   name       otype  dclass       dim
#> 0     /      X H5I_DATASET INTEGER 13 x 7858
#> 1     / layers   H5I_GROUP                  
#> 2     /    obs   H5I_GROUP                  
#> 3     /   obsm   H5I_GROUP                  
#> 4     /    var   H5I_GROUP
h5ls(H5Gopen(h5, "mod/scADT/layers"), recursive = FALSE)
#>   group name       otype dclass       dim
#> 0     /  clr H5I_DATASET  FLOAT 13 x 7858

… as well as reduced dimensions (PCA):

h5ls(H5Gopen(h5, "mod/scADT/obsm"), recursive = FALSE)
#>   group name       otype dclass       dim
#> 0     /  PCA H5I_DATASET  FLOAT 12 x 7858
# There is an alternative way to access groups:
# h5&'mod'&'scADT'&'obsm'
rhdf5::H5close()

0.7 References

  • Muon: multimodal omics analysis framework preprint

  • mudata (Python) documentation

  • muon documentation and web page

  • Stoeckius, M., Hafemeister, C., Stephenson, W., Houck-Loomis, B., Chattopadhyay, P.K., Swerdlow, H., Satija, R. and Smibert, P., 2017. Simultaneous epitope and transcriptome measurement in single cells. Nature methods, 14(9), pp.865-868.

  • Hao, Y., Hao, S., Andersen-Nissen, E., Mauck III, W.M., Zheng, S., Butler, A., Lee, M.J., Wilk, A.J., Darby, C., Zager, M. and Hoffman, P., 2021. Integrated analysis of multimodal single-cell data. Cell.

0.8 Session Info

sessionInfo()
#> R version 4.4.0 beta (2024-04-15 r86425)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 22.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/biocbuild/bbs-3.19-bioc/R/lib/libRblas.so 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: America/New_York
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats4    stats     graphics  grDevices utils     datasets  methods  
#> [8] base     
#> 
#> other attached packages:
#>  [1] SingleCellMultiModal_1.15.2 scater_1.32.0              
#>  [3] ggplot2_3.5.1               scuttle_1.14.0             
#>  [5] CiteFuse_1.16.0             MultiAssayExperiment_1.30.0
#>  [7] SingleCellExperiment_1.26.0 SummarizedExperiment_1.34.0
#>  [9] Biobase_2.64.0              GenomicRanges_1.56.0       
#> [11] GenomeInfoDb_1.40.0         IRanges_2.38.0             
#> [13] MatrixGenerics_1.16.0       matrixStats_1.3.0          
#> [15] MuData_1.8.0                rhdf5_2.48.0               
#> [17] S4Vectors_0.42.0            BiocGenerics_0.50.0        
#> [19] Matrix_1.7-0                BiocStyle_2.32.0           
#> 
#> loaded via a namespace (and not attached):
#>   [1] splines_4.4.0             filelock_1.0.3           
#>   [3] tibble_3.2.1              polyclip_1.10-6          
#>   [5] lifecycle_1.0.4           edgeR_4.2.0              
#>   [7] lattice_0.22-6            MASS_7.3-60.2            
#>   [9] magrittr_2.0.3            limma_3.60.0             
#>  [11] plotly_4.10.4             sass_0.4.9               
#>  [13] rmarkdown_2.26            jquerylib_0.1.4          
#>  [15] yaml_2.3.8                metapod_1.12.0           
#>  [17] cowplot_1.1.3             bayesm_3.1-6             
#>  [19] DBI_1.2.2                 RColorBrewer_1.1-3       
#>  [21] abind_1.4-5               zlibbioc_1.50.0          
#>  [23] Rtsne_0.17                purrr_1.0.2              
#>  [25] mixtools_2.0.0            ggraph_2.2.1             
#>  [27] tensorA_0.36.2.1          tweenr_2.0.3             
#>  [29] rappdirs_0.3.3            GenomeInfoDbData_1.2.12  
#>  [31] ggrepel_0.9.5             irlba_2.3.5.1            
#>  [33] pheatmap_1.0.12           dqrng_0.3.2              
#>  [35] DelayedMatrixStats_1.26.0 codetools_0.2-20         
#>  [37] DelayedArray_0.30.0       ggforce_0.4.2            
#>  [39] tidyselect_1.2.1          UCSC.utils_1.0.0         
#>  [41] farver_2.1.1              ScaledMatrix_1.12.0      
#>  [43] viridis_0.6.5             BiocFileCache_2.12.0     
#>  [45] jsonlite_1.8.8            BiocNeighbors_1.22.0     
#>  [47] tidygraph_1.3.1           ggridges_0.5.6           
#>  [49] survival_3.6-4            dbscan_1.1-12            
#>  [51] segmented_2.0-4           tools_4.4.0              
#>  [53] Rcpp_1.0.12               glue_1.7.0               
#>  [55] BiocBaseUtils_1.6.0       gridExtra_2.3            
#>  [57] SparseArray_1.4.0         xfun_0.43                
#>  [59] dplyr_1.1.4               withr_3.0.0              
#>  [61] BiocManager_1.30.22       fastmap_1.1.1            
#>  [63] rhdf5filters_1.16.0       bluster_1.14.0           
#>  [65] fansi_1.0.6               digest_0.6.35            
#>  [67] rsvd_1.0.5                mime_0.12                
#>  [69] R6_2.5.1                  colorspace_2.1-0         
#>  [71] RSQLite_2.3.6             utf8_1.2.4               
#>  [73] tidyr_1.3.1               generics_0.1.3           
#>  [75] data.table_1.15.4         robustbase_0.99-2        
#>  [77] graphlayouts_1.1.1        httr_1.4.7               
#>  [79] htmlwidgets_1.6.4         S4Arrays_1.4.0           
#>  [81] uwot_0.2.2                pkgconfig_2.0.3          
#>  [83] gtable_0.3.5              blob_1.2.4               
#>  [85] XVector_0.44.0            htmltools_0.5.8.1        
#>  [87] bookdown_0.39             scales_1.3.0             
#>  [89] png_0.1-8                 SpatialExperiment_1.14.0 
#>  [91] scran_1.32.0              knitr_1.46               
#>  [93] rjson_0.2.21              reshape2_1.4.4           
#>  [95] nlme_3.1-164              curl_5.2.1               
#>  [97] cachem_1.0.8              stringr_1.5.1            
#>  [99] BiocVersion_3.19.1        parallel_4.4.0           
#> [101] vipor_0.4.7               AnnotationDbi_1.66.0     
#> [103] pillar_1.9.0              grid_4.4.0               
#> [105] vctrs_0.6.5               randomForest_4.7-1.1     
#> [107] BiocSingular_1.20.0       dbplyr_2.5.0             
#> [109] beachmat_2.20.0           cluster_2.1.6            
#> [111] beeswarm_0.4.0            evaluate_0.23            
#> [113] tinytex_0.50              magick_2.8.3             
#> [115] cli_3.6.2                 locfit_1.5-9.9           
#> [117] compiler_4.4.0            rlang_1.1.3              
#> [119] crayon_1.5.2              labeling_0.4.3           
#> [121] plyr_1.8.9                ggbeeswarm_0.7.2         
#> [123] stringi_1.8.3             viridisLite_0.4.2        
#> [125] BiocParallel_1.38.0       Biostrings_2.72.0        
#> [127] munsell_0.5.1             lazyeval_0.2.2           
#> [129] compositions_2.0-8        ExperimentHub_2.12.0     
#> [131] sparseMatrixStats_1.16.0  bit64_4.0.5              
#> [133] Rhdf5lib_1.26.0           KEGGREST_1.44.0          
#> [135] statmod_1.5.0             highr_0.10               
#> [137] AnnotationHub_3.12.0      kernlab_0.9-32           
#> [139] igraph_2.0.3              memoise_2.0.1            
#> [141] bslib_0.7.0               DEoptimR_1.1-3           
#> [143] bit_4.0.5