qdiv.sequences.tree_distance_matrix
- qdiv.sequences.tree_distance_matrix(obj, *, savename='TreeDistMat', path='', save=True, file_format='csv', use_tqdm=True)[source]
Compute pairwise phylogenetic distances between leaf nodes in a tree.
- Parameters:
obj (MicrobiomeData or dict) – Must provide a DataFrame in obj.tree or obj[‘tree’]. The DataFrame must contain at least: [‘nodes’, ‘parent’, ‘dist_to_root’]. Optionally it can have ‘branchL’; ‘dist_to_root’ is assumed correct.
savename (str, optional) – Base filename for outputs. Default ‘TreeDistMat’.
path (str, default "") – Directory path (absolute or relative) where output is saved. Can be “” for CWD.
save (bool, optional) – If True, writes a CSV or compressed npz file.
file_format (str {'csv'|'compressed'|'npz'}) – If ‘csv’, saves a full distance matrix CSV. If ‘compressed’ or ‘npz’, saves a triangular matrix in a compressed npz.
use_tqdm (bool, default=True) – Use tqdm for progress bars.
- Returns:
Symmetric distance matrix with leaf node names as both rows and columns.
- Return type:
pandas.DataFrame