What's changed
Cellestial now speaks multimodal. MuData containers are a first-class input
across the library: pass one straight to a plot, color by a feature from any
modality, and plot joint embeddings such as WNN or MOFA without unpacking the
object yourself.
import cellestial as cl
data = cl.datasets.pbmc_cite()
# a protein on the joint WNN embedding
cl.dimensional(data, dimensions="wnn_umap", key="prot:CD3_TotalSeqB")
# a bare gene name, resolved to the modality that owns it
cl.violin(data, key="MS4A1", fill="leiden")
# genes and proteins on one axis, grouped by a joint clustering
cl.dotplot(data, keys=["MS4A1", "prot:CD3_TotalSeqB"], group_by="leiden")Added
- Multimodal (
MuData) support. Frames and the dimensional, distribution,
scatter and heatmap plot families accept a multimodal container directly,
reading metadata and embeddings at the container level.- Variables resolve to the modality that owns them. A bare name works when it
is unique across modalities, andmodality:namedisambiguates otherwise,
raisingAmbiguousVariableErrorrather than silently picking one. - Observations absent from a modality surface as NaN, aligned through the
container's observation map.
- Variables resolve to the modality that owns them. A bare name works when it
- A
modalityparameter onmarkers,marker_genes,marker_genes_dict,
volcano,volcanos,elbow,highest_expressed_genes,heatmap,
dotplot,stacked_violinandannotated_heatmap, selecting which modality's
stored analysis results to use. Required for a multimodal object holding more
than one modality, and not accepted otherwise. cellestial.datasets.pbmc_cite(), a small CITE-seq multimodal dataset, and an
extensionparameter onfrom_urlso it can serve.h5mufiles.AmbiguousVariableError.
Fixed
- A variable name matching more than one column is rejected instead of producing
wrong values. Slicing on a duplicated name yielded an interleaving of the
matching columns for multimodal inputs, and an opaque pandas
InvalidIndexErrorfor AnnData; both now raiseAmbiguousVariableError. - A key stored on both axes no longer silently selects the wrong one. Metrics
such astotal_countsare written per observation and per variable, and the
variables axis always won, soviolin(data, key="total_counts", fill="leiden")
built a variables frame that could not contain the grouping column. The
grouping and aesthetic keys of the same call now break the tie. Affects AnnData
as well as multimodal inputs. group_byis validated before use, so an unknown value raises
KeyNotFoundErrorinstead of a raw polarsColumnNotFoundErrornaming the
narrowed frame. When the name exists on a modality, the error suggests the
qualified form (rna:celltype). Affects AnnData as well as multimodal inputs.- Type annotations admit multimodal inputs. Every plotting function that accepts
one at runtime was still annotatedAnnData, so type checkers rejected valid
calls. dimensionswidened fromLiteral["umap", "pca", "tsne"]to also accept any
other embedding name. Non-standard names always worked at runtime, and joint
embeddings such aswnn_umapmake the narrow annotation untenable.- Variable names containing colons resolve. A qualified
modality:namekey is
still tried first, but a key that does not match that reading is now matched
literally, so ATAC peak names (chr1:1000-2000) and datasets storing variable
names already prefixed (rna:SAMD11) work. Previously every variable in such a
dataset was unreachable. - Embeddings stored as a
DataFramerather than an array no longer fail with
InvalidIndexErrorwhen materialised into a frame. Affects AnnData as well as
multimodal inputs. - Marker-derived plots (
heatmap,dotplot,stacked_violin) read the group
column a stored ranking was computed on as the container names it. A ranking
records that column under the modality's own name, so a container carrying both
a globalleidenand a modality'srna:leidenpreviously grouped the ranked
genes by the wrong clustering. Passing the container name explicitly as
group_byis accepted too.
Notes
- Spatial plots do not accept a multimodal object, because spot coordinates and
tissue images live in a modality rather than on the container. The error names
the single-modality form, and the composition that colours spots by a variable
from another modality:
spatial(data['rna'], key='prot:CD3', frame=build_frame(data, variable_keys=['prot:CD3'])). - Only containers whose modalities share observations (
axis=0) are supported.
No breaking changes.
Install: pip install -U cellestial
Full changelog: v0.59.0...v0.60.0