MuData Support#

Cellestial plots multimodal MuData objects as well as AnnData. Joint embeddings (WNN, MOFA) are plotted directly, and any modality’s features can color them.

The example uses cl.datasets.pbmc_cite(), a small CITE-seq dataset with an rna and a prot (surface protein) modality.

import warnings

import cellestial as cl
from ggrust import *

warnings.filterwarnings("ignore", category=FutureWarning, module="mudata")

data = cl.datasets.pbmc_cite()
data
MuData object with n_obs × n_vars = 411 × 56
  obs:	'louvain', 'leiden', 'leiden_wnn', 'celltype'
  var:	'gene_ids', 'feature_types', 'highly_variable'
  obsm:	'X_mofa', 'X_mofa_umap', 'X_umap', 'X_wnn_umap'
  varm:	'LFs'
  obsp:	'connectivities', 'distances', 'wnn_connectivities', 'wnn_distances'
  2 modalities
    prot:	411 × 29
      var:	'gene_ids', 'feature_types', 'highly_variable'
      uns:	'neighbors', 'pca', 'umap'
      obsm:	'X_pca', 'X_umap'
      varm:	'PCs'
      layers:	'counts'
      obsp:	'connectivities', 'distances'
    rna:	411 × 27
      obs:	'n_genes_by_counts', 'total_counts', 'total_counts_mt', 'pct_counts_mt', 'leiden', 'celltype'
      var:	'gene_ids', 'feature_types', 'mt', 'n_cells_by_counts', 'mean_counts', 'pct_dropout_by_counts', 'total_counts', 'highly_variable', 'means', 'dispersions', 'dispersions_norm', 'mean', 'std'
      uns:	'celltype_colors', 'hvg', 'leiden', 'leiden_colors', 'neighbors', 'pca', 'rank_genes_groups', 'umap'
      obsm:	'X_pca', 'X_umap'
      varm:	'PCs'
      obsp:	'connectivities', 'distances'

Joint embeddings#

Pass the embedding name to dimensions. Any name stored with the data works, not only umap, pca and tsne.

cl.dimensional(data, "celltype", dimensions="wnn_umap")
WNN_UMAP1 WNN_UMAP2 celltype CD4+ naïve T CD4+ memory T Treg CD8+ naïve T CD8+ memory T NK memory-like NK pre-B mature B CD14 mono intermediate mono CD16 mono pDC

Features from any modality#

A bare variable name works when it is unique across modalities. Use modality:name to pick one explicitly.

cl.dimensionals(
    data,
    ["CD14", "prot:CD14_TotalSeqB"],
    dimensions="wnn_umap",
    ncol=2,
) + ggsize(900, 350)
WNN_UMAP1 WNN_UMAP2 CD14 0 1 2 3 WNN_UMAP1 WNN_UMAP2 prot:CD14_TotalSeqB 0 5 10 15

Distributions take the same keys.

cl.violin(data, "prot:CD14_TotalSeqB", group_by="celltype") + ggsize(800, 400)
CD4+ naïve T CD4+ memory T Treg CD8+ naïve T CD8+ memory T NK memory-like NK pre-B mature B CD14 mono intermediate mono CD16 mono pDC 0 5 10 15 prot:CD14_TotalSeqB

Stored analysis results#

Results such as marker rankings live in one modality. Plots that read them (markers, marker_genes, volcano, heatmap, dotplot, stacked_violin, annotated_heatmap and others) take modality= to say which.

cl.markers(data, modality="rna")
cl.dotplot(data, group_by="leiden", markers=True, modality="rna")

Notes#

  • Observations missing from a modality appear as NaN.

  • A name found in more than one modality raises AmbiguousVariableError, which lists the qualified names to use.

  • Only modalities that share observations (axis=0) are supported.

  • Spatial plots do not take a MuData object. Pass the modality and a frame: cl.spatial(data["rna"], key="prot:CD3", frame=cl.build_frame(data, variable_keys=["prot:CD3"])).