import cellestial as cl
import scanpy as sc
from lets_plot import *
LetsPlot.setup_html()
= sc.read("data/pbmc3k_pped.h5ad")
data = sc.read("data/pbmc3k_mini.h5ad") mini
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.
= cl.dimensional(
plot
data,="umap",
dimensions="leiden",
key=0.6,
size="arrow",
axis_type=False,
legend_ondata
) 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.
= cl.dimensional(
plot
data,="umap",
dimensions="leiden",
key=0.6,
size=True,
interactive="arrow",
axis_type
) 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(
[+ scale_color_hue() + labs(title="Change color palette"),
plot
plot+ theme(legend_text=element_text(size=15))
+ labs(title="Change legend text size"),
],=2,
ncol+ ggsize(1000, 400) )
Indeed, you can modify the size.
+= ggsize(500, 400)
plot plot
1.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",
="leiden",
fill="#3f3f3f",
boxplot_color=True,
show_points=1,
outlier_shape
)+ ggsize(1000, 400)
+ scale_y_log2()
+ scale_fill_brewer(palette="Set2")
) plot
1.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,=["leiden", "HBD", "NEAT1", "IGKC"],
keys=2,
ncol=0.6,
size="#D2042D", # works with hex codes, rgb codes, and names (red, blue, etc.)
color_high
)+ ggsize(900, 700)
) umap_grid
or with violins
cl.violins(
mini,
["n_genes_by_counts",
"pct_counts_in_top_100_genes",
"log1p_total_counts_mt",
"pct_counts_hb",
],=2,
ncol="sample",
fill=True,
show_points=[scale_y_log10()],
layers )
cl.versions()
cellestial: 0.6.0
scanpy: 1.10.4
anndata: 0.11.3
polars: 1.12.0