gneiss.sort.niche_sort

gneiss.sort.niche_sort(table, gradient, niche_estimator=<function mean_niche_estimator>)[source]

Sort the table according to estimated niches.

Sorts the table by samples along the gradient and otus by their estimated niche along the gradient.

Parameters:
  • table (pd.DataFrame) – Contingency table where samples are rows and features (i.e. OTUs) are columns.
  • gradient (pd.Series) – Vector of numerical gradient values.
  • niche_estimator (function, optional) – A function that takes in two pandas series and returns an ordered object. The ability for the object to be ordered is critical, since this will allow the table to be sorted according to this ordering. By default, mean_niche_estimator will be used.
Returns:

Sorted table according to the gradient of the samples, and the niches of the organisms along that gradient.

Return type:

pd.DataFrame

Raises:

ValueError : – Raised if niche_estimator is not a function.