pytexmex package¶
Submodules¶
pytexmex.core module¶
This submodule focuses on computing the Poisson-lognormal probability mass function. It’s a moderately complicated integral that requires some finesse. More on the math page.
-
pytexmex.core.
poilog_cdf
(ns, mu, sigma, trunc=True)¶ Cumulative distribution function
- ns: sequence of integers
- number of counts for each sequence
- mu, sigma: float
- poilog distribution parameters
- trunc: bool
- poilog distribution parameter
returns: list of floats
-
pytexmex.core.
poilog_exp_integrand
(x, n, mu, sigma)¶ The part of the poilog integral that is inside the exponent.
-
pytexmex.core.
poilog_exp_integrand_max
(n, mu, sigma)¶ Find the maximum value and position of the exponential part of the integrand.
- Returns: (float, float)
- The position and value of the maximum
-
pytexmex.core.
poilog_fit
(ns, trunc=True, x0=None, full_output=False)¶ Maximum likelihood estimation fit
- x0: (float, float)
- The starting mu and sigma for the MLE optimization. If None, then a guess will be supplied.
- full_output: bool
- If True, then also return the OptimizeResult object
- Returns: (float, float) or (float, float, OptimizeResult)
- Optimal mu and sigma (and optionally the rest of the data)
-
pytexmex.core.
poilog_ll
(ns, mu, sigma, trunc=True, threshold=1e-120)¶ Log likelihood of a list of counts
-
pytexmex.core.
poilog_pmf
(n, mu, sigma, trunc=True)¶ Probability mass function (with optional zero truncation)
-
pytexmex.core.
poilog_pmf_notrunc
(n, mu, sigma)¶ Probability mass function without truncation
-
pytexmex.core.
poilog_upper_bound
(n, mu, sigma, fold=1e-09, guess=1.0, guess_multiplier=2.0)¶ Pick a reasonable upper bound for the poilog integral. Start at the place where the integrand is maximized, then go out until the integrand falls to some fold of its maximum value.
returns: float
pytexmex.helpers module¶
This submodule focuses on front-end user functions.
-
pytexmex.helpers.
f_transform_sample
(ns, trunc=True)¶ Transform a list of counts into their F values
Returns: list of floats
-
pytexmex.helpers.
f_transform_table
(table, trunc=True)¶ Transform an OTU table in a table of F values. OTU tables have samples on the columns and OTUs on the rows.
table: pandas.DataFrame
returns: pandas.DataFrame
-
pytexmex.helpers.
pp_plot_data
(ns, trunc=True)¶ Generate data for visualizing the quality of the poilog fit. One day I should use scipy’s scipy.stats.probplot for this (which would require writing a poilog distribution).
ns : list of floats
- returns: (list of floats, list of floats)
- the empirical and theoretical cdf values, going from 0 up to the maximum of the input ns
-
pytexmex.helpers.
read_otu_table
(fn, transpose=False)¶ Read an OTU table from a filename (or filehandle). It expects to have OTUs on the rows and samples on the columns (i.e., QIIME style). If the table is wider than long, a warning will be issued.
- transpose: bool
- transpose the table
returns: pandas.DataFrame
-
pytexmex.helpers.
z_transform_sample
(ns, trunc=True)¶ Transform a list of counts into their z values
Returns: np.array
-
pytexmex.helpers.
z_transform_table
(table, trunc=True)¶ Transform an OTU table in a table of z values. OTU tables have samples on the columns and OTUs on the rows.
table: pandas.DataFrame
returns: pandas.DataFrame