biotapy.pl.richness#
- biotapy.pl.richness(adata, metric, *, x=None, color=None, ax=None)#
One point per sample for a stored alpha diversity metric.
- Parameters:
adata (
AnnData) – Samples x features withobs['alpha_<metric>'], written bybiotapy.tl.alpha()withinplace=True.metric (
str) – The metric to plot, such as"shannon".x (
str|None(default:None)) – Anobscolumn whose values place the points. By default one position per sample.color (
str|None(default:None)) – Anobscolumn that colours the points, with a legend.ax (
Axes|None(default:None)) – Axes to draw on; by default a new figure’s.
- Return type:
- Returns:
matplotlib.axes.Axes The points, one per sample with a finite value.
- Raises:
Notes
R equivalent:
phyloseq::plot_richnessGuide: Plottingphyloseq computes
estimate_richnessand draws every measure in its own facet; biotapy reads whatbiotapy.tl.alpha()stored and draws one metric per axes. Samples with a NaN value, such as Shannon of an all-zero sample, are left out, asgeom_point(na.rm = TRUE)does; acolorgroup left with no point gets no legend entry. There are no standard-error bars:tl.alphastores none.obs['alpha_*']columns survive feature changes (biotapy.pp.filter_features(),biotapy.pp.rarefy(),biotapy.pp.tax_glom()), but they still describe the old table: recompute withbt.tl.alpha(adata, metrics=[metric], inplace=True)before plotting.Examples
>>> import biotapy as bt >>> tdata = bt.datasets.toy() >>> bt.tl.alpha(tdata, metrics=["shannon"], inplace=True) >>> ax = bt.pl.richness(tdata, "shannon", x="group") >>> ax.collections[0].get_offsets().shape (6, 2)