qdiv.plot.phyl_tree

qdiv.plot.phyl_tree(obj, *, width=12, name_internal_nodes=False, abundance_info=None, xlog=False, savename=None)[source]

Plot a phylogram from a tree DataFrame with optional abundance bars.

Parameters:
  • obj (dict or MicrobiomeData) – Input object with required key: - tree (pandas.DataFrame): tree structure with columns [‘nodes’, ‘leaves’, ‘branchL’]. Optional keys: - tab (pandas.DataFrame): abundance table (features x samples). - meta (pandas.DataFrame): metadata table for sample grouping.

  • width (float, default=12) – Width of the plot in centimeters. Height is set automatically based on number of ASVs.

  • name_internal_nodes (bool, default=False) – If True, labels are added to internal nodes.

  • abundance_info ({'index'} or str, optional) – If ‘index’, plot relative abundance bars for each ASV. If a metadata column name, plot grouped abundance bars for each category.

  • xlog (bool, default=False) – If True, abundance bars use a logarithmic x-axis.

  • savename (str, optional) – If provided, save the figure to this path and also as PDF.

Returns:

  • fig (matplotlib.figure.Figure)

  • df_endN (pandas.DataFrame) – DataFrame of end nodes with positions and optional abundance info.

Return type:

Tuple[plt.figure.Figure, pd.DataFrame]

Notes

  • The tree DataFrame must contain columns: ‘nodes’, ‘leaves’, ‘branchL’.

  • If abundance_info is provided, relative abundances are computed per leaf or category.

  • Bars are plotted to the right of the tree when abundance_info is not None.

Examples

>>> phyl_tree(obj, width=15, name_internal_nodes=True, abundance_info='Treatment', xlog=True, savename='phylogram')