qdiv.model.ntiq

qdiv.model.ntiq(obj, distmat, *, q=1.0, iterations=999, randomization='features', use_tqdm=True, random_state=None, **kwargs)[source]

Nearest Taxon Index (NTI) with q-weighting of relative abundances. Computes MNTD_q (mean nearest-taxon distance with q-weighted abundances), then compares to a null obtained by either permuting feature labels (“features”) or shuffling abundances within each sample (“abundances”).

Parameters:
  • obj (MicrobiomeData, dict, or compatible object) – Input data. Must provide at least an abundance table (‘tab’).

  • distmat (pd.DataFrame) – Square distance matrix indexed/columned by feature ids.

  • q (float, default=1.0) – Order of diversity weighting applied to relative abundances.

  • iterations (int, default=999) – Number of random permutations of distmat.

  • randomization ({'features', 'abundances'}, default='features') – Randomization strategy. Shuffle features in the phylogenetic tree or relative abundance values in each sample.

  • use_tqdm (bool, default=True) – Use tqdm for progress bars.

  • random_state (int or np.random.Generator, optional) – Random seed or generator for reproducibility.

Returns:

Indexed by sample names with columns: - ‘MNTDq’ - ‘null_mean’ - ‘null_std’ - ‘p’ (Pr[ null < observed ] + 0.5*ties) / iterations - ‘ses’ (null_mean - observed) / null_std

Return type:

pandas.DataFrame

Notes

  • A p value close to zero means that the observed MPNTD is lower than the null expectation

  • A p value close to one means that the observed MNTD is higher than the null expectation

  • A positive ses means that the observed MNTD is lower than the null expectation

  • A negative ses means that the observed MNTD is higher than the null expectation