Before using code patterns, verify installed versions match. If versions differ:
Python: pip show <package> then help(module.function) to check signatures
R: packageVersion('<pkg>') then ?function_name to verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.
Multimodal Integration
"Integrate RNA and protein data from my CITE-seq experiment" → Jointly analyze multiple modalities (RNA + protein, RNA + ATAC) measured in the same cells using weighted nearest neighbor or factor analysis.
R: Seurat::FindMultiModalNeighbors() for WNN integration
Python: muon for MuData handling, scanpy + anndata for multimodal objects
Analyze multi-modal single-cell data where multiple measurements are made per cell.
Common Modalities
Technology
Modalities
Package
CITE-seq
RNA + surface proteins (ADT)
Seurat
10X Multiome
RNA + ATAC
Seurat, Signac, ArchR
SHARE-seq
RNA + ATAC
Seurat, Signac
Spatial (Visium)
RNA + spatial coordinates
Seurat, Squidpy
CITE-seq Analysis (Seurat)
Load Data
library(Seurat)
# Read 10X data with antibody capture
data <- Read10X('filtered_feature_bc_matrix/')
# Separate RNA and ADT
rna_counts <- data$`Gene Expression`
adt_counts <- data$`Antibody Capture`
# Create Seurat object with both assays
obj <- CreateSeuratObject(counts = rna_counts, assay = 'RNA')
obj[['ADT']] <- CreateAssayObject(counts = adt_counts)
Goal: Jointly cluster cells using both RNA and protein (or ATAC) modalities, weighting each modality's contribution per cell.
Approach: Run PCA separately on each modality, build a weighted nearest neighbor graph that adaptively combines both reductions, then cluster and embed on the combined WNN graph.
import scanpy as sc
import muon as mu
from muon import prot as pt
# Load multimodal data
mdata = mu.read_10x_h5('filtered_feature_bc_matrix.h5')
# Access modalities
rna = mdata.mod['rna']
prot = mdata.mod['prot']
# Process RNA
sc.pp.filter_cells(rna, min_genes=200)
sc.pp.normalize_total(rna, target_sum=1e4)
sc.pp.log1p(rna)
sc.pp.highly_variable_genes(rna)
sc.tl.pca(rna)
# Process protein (CLR normalization)
pt.pp.clr(prot)
# Multi-omics factor analysis
mu.tl.mofa(mdata, n_factors=20)
# Joint UMAP
mu.tl.umap(mdata)
mu.pl.umap(mdata, color=['rna:leiden', 'prot:CD3'])
Integration Metrics
Modality Weights
# Check how much each modality contributes per cell
weights <- obj@reductions$wnn@misc$weights
# Average weight by cluster
aggregate(weights, by = list(obj$seurat_clusters), mean)
Correlation Between Modalities
import numpy as np
# Correlate RNA and protein for same genes/proteins
common = set(rna.var_names) & set(prot.var_names)
for gene in common:
rna_expr = rna[:, gene].X.toarray().flatten()
prot_expr = prot[:, gene].X.toarray().flatten()
corr = np.corrcoef(rna_expr, prot_expr)[0, 1]
print(f'{gene}: r={corr:.3f}')