Plotting#

Publication plots under cf.pl. Tissue coordinates use embedding(..., basis="spatial"); there is no separate spatial plotting module.

Marsilea-based dotplot / grid_dotplot need pip install cellfish[plot].

Style and fonts#

plot.setup_style(*[, font, dpi, font_dir, ...])

Load fonts if present and set publication rcParams (PDF fonttype 42).

plot.savefig(fig, path, *[, dpi, also_png])

Save fig; if path is PDF/SVG, also write a PNG sidecar unless disabled.

plot.font_signature(ttf_path)

Return (family, subfamily, weight, is_italic) for a TTF file.

plot.validate_and_load_fonts(font_list[, ...])

Validate and load custom fonts from font_dir.

plot.export_mplstyle([filename])

Write current matplotlib rcParams that differ from defaults.

Palettes#

Project-specific colors stay in the analysis repo. Pass them with palette= or group_color_dict=.

plot.get_palette(name)

Get a predefined color palette by name.

plot.create_palette_from_types(cell_types[, ...])

Create a color mapping for a list of cell types.

plot.order_labels([observed, order])

Return order first, then any extra observed labels.

plot.reorder_and_set_palettes(adata, group)

Reorder a group column in adata.obs and set its corresponding palette.

plot.show_color(color_input[, title, n_colors])

Intelligently visualizes a color input.

plot.show_palette(palette[, title, labels])

Display a palette with optional labels.

plot.list_available_palettes()

List all available predefined palettes dynamically.

Embedding#

plot.embedding(adata, basis, *[, color, ...])

Scatter plot for user specified embedding basis (e.g. umap, pca, etc).

plot.embedding_numbered(adata, basis, *[, ...])

A derived version of embedding() that: - writes numeric indices (1..N) on the embedding (at per-group centroids), - and shows a right-side legend with "<idx>  <group>" labels.

plot.umap(adata, **kwargs)

Plot UMAP embedding.

plot.tsne(adata, **kwargs)

Plot t-SNE embedding.

plot.pca(adata, **kwargs)

Plot PCA embedding.

plot.mde(adata, **kwargs)

Plot MDE embedding.

plot.embedding_celltype(adata[, figsize, ...])

Plot embedding with celltype color by omicverse.

plot.embedding_adjust(adata, groupby[, ...])

Get locations of cluster median and adjust text labels accordingly.

plot.embedding_density(adata, basis, ...)

plot.ConvexHull(adata, basis, cluster_key, ...)

Plot the ConvexHull for a cluster in embedding.

plot.add_arrow(ax, adata, basis[, fontsize, ...])

Add arrow and label to the axis :type ax: matplotlib.axes.Axes :param ax: The axis to add the arrow and label to.

Composition#

plot.get_cluster_proportions(adata[, ...])

Return percent composition (0–100) with samples as index and clusters as columns.

plot.plot_cluster_proportions(cluster_props)

Stacked bar chart of get_cluster_proportions output.

plot.cellproportion(adata, ...[, ...])

Plot cell proportion of each cell type in each visual cluster.

plot.cellstackarea(adata, celltype_clusters, ...)

Plot the cell type percentage in each groupby category

plot.cell_alluvial(adata, celltype_clusters, ...)

Temporal / grouped composition plot with smooth alluvial ribbons.

Categorical / statistical plots#

plot.bardotplot(adata, groupby, color[, ...])

plot.single_group_boxplot(adata[, groupby, ...])

adata (AnnData object): The data object containing the information for plotting.

plot.plot_boxplots(data, feature_name[, ...])

Grouped boxplot visualization.

plot.violin_box(adata, keys, groupby[, ax, ...])

plot.violin_old(adata[, keys, groupby, ax, ...])

plot.dotplot_doublegroup(adata, gene, ...[, ...])

plot.ridgeplot(adata, metric[, groupby, ...])

Ridge / overlapping KDE of adata.obs[metric] grouped by groupby.

Contours and obs scatter#

plot.add_contour(ax, adata, groupby, clusters)

Add density contour to plot.

plot.contour(ax, adata, groupby, clusters[, ...])

Add density contour to plot.

plot.plot_scatter(adata, x, y, hue, cmap[, ...])

Scatter plot from AnnData.obs with optional cluster highlighting.

plot.obs_scatter(adata, x, y, hue, cmap[, ...])

Scatter plot from AnnData.obs with optional cluster highlighting.

plot1cell#

plot.plot1cell(adata, clusters[, basis, ...])

Circular UMAP with metadata tracks.

plot.plot1cell_atlas_meta_rings(adata, *[, ...])

Draw an atlas-style plot1cell figure with original plot1cell-like inner metadata rings.

plot.simulate_atlas_anndata([n_cells, ...])

Generate a simulated atlas-like AnnData object for testing the plotting function.

Dotplots (marsilea)#

These attributes are loaded lazily. Install cellfish[plot] first.

plot.dotplot(adata, var_names, groupby, *[, ...])

Make a dot plot of the expression values of var_names.

plot.grid_dotplot(adata, var_names, groupby, *)

Grouped dotplot with Marsilea, supporting 2D category splits and colored labels.

plot.CircleLabels(labels[, split_groups, ...])

Draw colored dots with text labels beside them (Marsilea RenderPlan).

plot.rank_genes_groups_dotplot(adata[, ...])

Create a dot plot from rank_genes_groups results.