knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)

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.

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.

Loading libraries

library(MuData)
library(SingleCellExperiment)
library(MultiAssayExperiment)
library(CiteFuse)
library(scater)

library(rhdf5)

Loading data

We will use CITE-seq data available within CiteFuse Bioconductor package.

data("CITEseq_example", package = "CiteFuse")
lapply(CITEseq_example, dim)

This dataset contains three matrices — one with RNA counts, one with antibody-derived tags (ADT) counts and one with hashtag oligonucleotide (HTO) counts.

Processing count matrices

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

Following the CiteFuse tutorial, we start with creating a SingleCellExperiment object with the three matrices:

sce_citeseq <- preprocessing(CITEseq_example)
sce_citeseq

We will add a new assay with normalised RNA counts:

sce_citeseq <- scater::logNormCounts(sce_citeseq)
sce_citeseq  # new assay: logcounts

To the ADT modality, we will add an assay with normalised counts:

sce_citeseq <- CiteFuse::normaliseExprs(
  sce_citeseq, altExp_name = "ADT", transform = "log"
)
altExp(sce_citeseq, "ADT")  # new assay: logcounts

We will also generate reduced dimensions:

sce_citeseq <- scater::runPCA(
  sce_citeseq, exprs_values = "logcounts", ncomponents = 20
)
scater::plotReducedDim(sce_citeseq, dimred = "PCA", 
                       by_exprs_values = "logcounts", colour_by = "CD27")

Making a MultiAssayExperiment object

An appropriate structure for multimodal datasets is MultiAssayExperiment.

We will make a respective MultiAssayExperiment object from sce_citeseq:

experiments <- list(
  ADT = altExp(sce_citeseq, "ADT"),
  HTO = altExp(sce_citeseq, "HTO")
)

# Drop other modalities from sce_citeseq
altExp(sce_citeseq) <- NULL
experiments[["RNA"]] <- sce_citeseq

mae <- MultiAssayExperiment(experiments)

Writing to H5MU

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

writeH5MU(mae, "citefuse_example.h5mu")

We can check that all the modalities were written to the file:

h5 <- rhdf5::H5Fopen("citefuse_example.h5mu")
h5ls(H5Gopen(h5, "mod"), recursive = FALSE)

... both assays for ADT — raw counts are stored in X and normalised counts are in the corresponding layer:

h5ls(H5Gopen(h5, "mod/ADT"), FALSE)
h5ls(H5Gopen(h5, "mod/ADT/layers"), FALSE)

... as well as reduced dimensions (PCA):

h5ls(H5Gopen(h5, "mod/RNA/obsm"), FALSE)
# There is an alternative way to access groups:
# h5&'mod'&'RNA'&'obsm'
rhdf5::H5close()

References

Session Info

sessionInfo()


PMBio/MuDataMAE documentation built on Oct. 20, 2023, 12:14 p.m.