biotapy.tl.beta#
- biotapy.tl.beta(adata, *, metric='braycurtis', inplace=False)#
Distances between every pair of samples.
- Parameters:
- Return type:
- Returns:
pandas.DataFrame or None Symmetric samples x samples distances with a zero diagonal, indexed by
obs_names. Two all-zero samples are NaN apart under Bray-Curtis and 0 apart under Jaccard (scikit-bio’s convention; vegan’s binary Jaccard gives NaN).- Raises:
ValueError –
metricis not"braycurtis"or"jaccard".
Notes
R equivalent:
phyloseq::distanceGuide: Diversity"jaccard"matchesphyloseq::distance(physeq, "jaccard", binary = TRUE): withoutbinary = TRUE, vegan computes a quantitative Jaccard instead. scikit-bio needs dense input, soXis densified once (8 bytes x samples x features) and the result takes 8 bytes x samples x samples. scikit-bio’s working copies add to that: measured with tracemalloc on scikit-bio 0.7.4, peak memory is the dense copy plus 1.5 results (its condensed and square matrices), or two results while the matrix becomes a DataFrame, whichever is larger, and"jaccard"adds a 1-byte presence/absence copy ofX.References
Bray JR, Curtis JT (1957) An ordination of the upland forest communities of southern Wisconsin. Ecological Monographs 27:325-349.
Jaccard P (1912) The distribution of the flora in the alpine zone. New Phytologist 11:37-50.
Examples
>>> import biotapy as bt >>> round(float(bt.tl.beta(bt.datasets.toy()).loc["s1", "s4"]), 3) 0.708