cookiecutter_scverse_instance.pp.elaborate_example

cookiecutter_scverse_instance.pp.elaborate_example#

cookiecutter_scverse_instance.pp.elaborate_example(items, transform, *, layer_key=None, mudata_mod='rna', sdata_table_key='table1', max_items=100)#

A method with a more complex docstring.

This is where you add more details. Try to support general container classes such as Sequence, Mapping, or Collection where possible to ensure that your functions can be widely used.

Data science means there’s lots of math too:

x=b±b24ac2ax = \frac{-b \pm \sqrt{b^2-4ac}}{2a}
Parameters:
  • items (Iterable[AnnData | TypeVar(MuData) | TypeVar(SpatialData)]) – AnnData, MuData, or SpatialData objects to process.

  • transform (Callable[[Any], str]) – Function to transform each item to string.

  • layer_key (str | None (default: None)) – Optional layer key to access matrix to apply transformation on.

  • mudata_mod (str | None (default: 'rna')) – Optional MuData modality key to apply transformation on.

  • sdata_table_key (str | None (default: 'table1')) – Optional SpatialData table key to apply transformation on.

Return type:

list[str]

Returns:

List of transformed string items.

Examples

>>> elaborate_example(
...     [adata, mudata, spatial_data],
...     lambda vals: f"Statistics: mean={vals.mean():.2f}, max={vals.max():.2f}",
...     {"var_key": "CD45", "modality": "rna", "min_value": 0.1},
... )
['Statistics: mean=1.24, max=8.75', 'Statistics: mean=0.86, max=5.42']