gneiss.sort.mean_niche_estimator¶
-
gneiss.sort.
mean_niche_estimator
(abundances, gradient)[source]¶ Estimates the mean niche along a gradient of an organism.
Calculates the mean niche of an organism along a gradient. This is done by calculating the mean gradient values that an organism is observed in.
Specifically, this module calculates the following
f(g,x)=N∑i=1gixiN∑j=1xjWhere N is the number of samples, xi is the proportion of species x in sample i, gi is the gradient value at sample i.
Parameters: - abundances (pd.DataFrame or pd.Series, np.float) – Vector of fraction abundances of an organism over a list of samples.
- gradient (pd.Series, np.float) – Vector of numerical gradient values.
Returns: The mean gradient that the feature is observed in. If abundances is a pd.DataFrame containing the mean gradient values for each feature. Otherwise a float is returned.
Return type: pd.Series or np.float
Raises: - ValueError: – If the length of abundances is not the same length as gradient.
- ValueError: – If the length of gradient contains nans.