1  Overview

Cellestial is an interactive single-cell plotting library.

import cellestial as cl
import scanpy as sc
from lets_plot import *

LetsPlot.setup_html()

data = sc.read("data/pbmc3k_pped.h5ad")

1.1 Tooltips

By default, cellestial produces HTML plots with geoms reveal tooltips when hovering.

plot = cl.dimensional(
    data, dimensions="umap", key="leiden", size=0.6, axis_type="arrow"
)
plot

dimensional plot produces dimensionalilty reduction plots by taking dimensions argument. Yet, the subset of plots pca, umap and tsne are also available.

Also, the expression plot is also a subset of dimensional plot but it only works with genes.

1.2 Zooming and Paning

There are also zoomable and panable if specified.

plot = cl.dimensional(
    data,
    dimensions="umap",
    key="leiden",
    size=0.6,
    interactive=True,
    axis_type="arrow",
)
plot

Note that this functionality can be added via + ggtb() layer of lets_plot.

1.3 High Customizability

Cellestial uses Lets-Plot, a ggplot2 impelementation in Pyton. As such, it allows adding or changing layers. Including color palettes, titles, labels, size etc., .

Here an example with switching color palette to hue which is also the ggplot2 and Seurat defaults. Also, other theme() based customizations are given as examples.

gggrid(
    [
        plot + scale_color_hue() + labs(title="Change color palette"),
        plot
        + theme(legend_text=element_text(size=15))
        + labs(title="Change legend text size"),
        plot
        + theme(axis_title=element_blank())
        + labs(title="Remove axis titles"),
    ],
    ncol=2,
) + ggsize(1000, 800)

Indeed, you can modify the size.

plot += ggsize(500, 400)
plot

1.4 Multi-Plots

Multi-plots uses dimensional plot and grids list of keys given.

While single-plot functions which generate a single-plot object, Multi-plot functions have plural names which provides predictable behaviors.

So, pca becomes pcas, umap becomes umaps, tsne becomes tsnes etc., for multi-plots.

umap_grid = (
    cl.umaps(
        data,
        keys=["leiden", "HBD", "NEAT1", "IGKC"],
        ncol=2,
        size=0.6,
        color_high="#D2042D",  # works with hex codes, rgb codes, and names (red, blue, etc.)
    )
    + ggsize(900, 700)
)
umap_grid
cl.versions()
cellestial: 0.2.0
scanpy: 1.10.4
anndata: 0.11.0
polars: 1.12.0