Lifemap.layer_donuts

Lifemap.layer_donuts(
    data=None,
    *,
    taxid_col='taxid',
    counts_col,
    categories=None,
    radius=50,
    leaves='hide',
    show_totals=True,
    scheme=None,
    opacity=1,
    popup=True,
    popup_col=None,
    label=None,
    declutter=True,
    lazy=True,
    lazy_zoom=4,
)

Add a donuts layer.

This layer displays the distribution of a categorical variable values among each nodes children. Optionally it can also represent leaves values as a point layer.

It should be applied to data computed with aggregate_freq.

Parameters

Name Type Description Default
data pl.DataFrame | pd.DataFrame | None Layer data. If not provided, use the base widget data. None
taxid_col str If data is provided, name of the data column with taxonomy ids, by default "taxid" 'taxid'
counts_col str DataFrame column containing the counts. required
categories list | tuple | None Custom order of categories. Defaults to None. None
radius int | list | tuple Donut charts radius. If an integer, all donut charts will be of the same size. If a list or a tuple of length 2, chart size will depend on the node total count. By default 50 50
leaves Literal["show", "hide"] If "show", add a points layer with individual leaves values, by default “hide” 'hide'
show_totals bool If True, display the total count of the current taxa in the center of the donut chart. Defaults to True True
scheme str | None Color scheme for donut charts ans points. It is the name of a categorical Observable Plot color scale, by default None None
opacity float | None Donut charts and points opacity, by default 1 1
popup bool If True, display informations in a popup when a point is clicked, by default True True
popup_col str | None Name of a data column containing custom popup content. By default None. None
label str | None Legend title for this layer. If None, the value of counts_col is used. None
declutter bool If True, use OpenLayers decluttering option for this layer. Defaults to True. True
lazy bool If True, points are displayed depending on the widget view. If False, all points are displayed. Can be useful when displaying a great number of items. Defaults to True. True
lazy_zoom int If lazy true, only points with a zoom level less than (zoom + lazy_zoom) level will be displayed. Defaults to 4. 4

Returns

Name Type Description
Lifemap A Lifemap visualization object.

Raises

Name Type Description
ValueError If leaves is not one of the allowed values.

Examples

>>> import polars as pl
>>> from pylifemap import Lifemap, aggregate_freq
>>> d = pl.DataFrame(
...     {
...         "taxid": [
...             9685,
...             9615,
...             9994,
...             2467430,
...             2514524,
...             2038938,
...             1021470,
...             1415565,
...             1928562,
...             1397240,
...             230741,
...         ],
...         "category": ["a", "b", "b", "a", "a", "c", "a", "b", "b", "a", "b"],
...     }
... )
>>> d = aggregate_freq(d, column="category")
>>> Lifemap(d).layer_donuts(counts_col="category", leaves="hide").show()

See also

: aggregation of the values counts of a categorical variable.