import cellestial as cl
import scanpy as sc
from lets_plot import *
LetsPlot.setup_html()
data = sc.read("data/pbmc3k_pped.h5ad")
mini = sc.read("data/pbmc3k_mini.h5ad")1 Overview
Cellestial is an interactive single-cell plotting library.
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",
legend_ondata=False,
)
plotdimensional 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",
)
plotNote 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"),
],
ncol=2,
) + ggsize(1000, 400)Indeed, you can modify the size.
plot += ggsize(500, 400)
plot1.4 Versatile
Cellestial offers many plotting functions to create publication-quality figures.
Such as violinplots, boxplots, scatter plots, and more.
plot = (
cl.boxplot(
mini,
"pct_counts_in_top_50_genes",
fill="leiden",
boxplot_color="#3f3f3f",
show_points=True,
outlier_shape=1,
)
+ ggsize(1000, 400)
+ scale_y_log2()
+ scale_fill_brewer(palette="Set2")
)
plot1.5 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_gridor with violins
cl.violins(
mini,
[
"n_genes_by_counts",
"pct_counts_in_top_100_genes",
"log1p_total_counts_mt",
"pct_counts_hb",
],
ncol=2,
fill="sample",
show_points=True,
layers=[scale_y_log10()],
)cl.versions()cellestial: 0.6.0
scanpy: 1.10.4
anndata: 0.11.3
polars: 1.12.0