biotapy.pp.relative

Contents

biotapy.pp.relative#

biotapy.pp.relative(adata)#

Add per-sample relative abundance as layers['relative'].

Parameters:

adata (AnnData) – Samples x features; X holds counts or another non-negative abundance.

Return type:

AnnData

Returns:

AnnData A copy of adata (a TreeData stays a TreeData) with layers['relative']; X is unchanged.

Notes

R equivalent: phyloseq::transform_sample_counts, mia::transformAssay Guide: Transforms

All-zero samples stay all-zero, where phyloseq returns NaN.

Examples

>>> import biotapy as bt
>>> out = bt.pp.relative(bt.datasets.toy())
>>> round(float(out.layers["relative"][0].sum()), 6)
1.0