Command reference

ititer.inverse_logit(x, a, b, c, d)

Inverse logit function.

Parameters
  • x (Union[Iterable[numbers.Real], numbers.Real]) –

  • a (numbers.Real) – Location of inflection point on x-axis.

  • b (numbers.Real) – Gradient of slope.

  • c (numbers.Real) – Bottom y-asymptote.

  • d (numbers.Real) – Distance to top y-asymptote from bottom.

Return type

Union[Iterable, numbers.Real]

ititer.index_to_titer(index, start, fold)

Transform a position in a dilution series to a titer.

Titers are referred to by their reciprocal, so a titer/dilution of ‘1/10’ is referred to as simply ‘10’.

A starting dilution of 10 and a fold change of 2 will generate a dilution series of: (10, 20, 40, 80, 160, …). This function takes a position in this dilution series and returns the dilution.

Parameters
  • index (Union[Iterable[numbers.Real], numbers.Real]) – Indices(s) to transform.

  • start (numbers.Real) – Starting dilution of the series.

  • fold (numbers.Real) – Fold change of the series.

Return type

Union[Iterable[numbers.Real], numbers.Real]

ititer.load_example_data()

Load an example pandas DataFrame to illustrate fitting sigmoid curves.

Return type

pandas.core.frame.DataFrame

class ititer.Sigmoid(a='partial', b='full', c='full', d='full')

Sigmoid model for a dose response curve. The model fits a response, \(y\), as a function of log dilution, \(x\):

\(y = c + d / (1 + e^{b(x - a)})\)

Posterior distributions of each parameter can be inferred by either fully or partially pooling inference across samples (partial vs full). Parameters can also be fixed a priori, by providing a float.

Response values are standardised to have a range of 0-1 prior to inference. Log dilution values are standardised to have a mean of 0 and standard deviation of 1 prior to inference.

Parameters
  • a'partial', 'full' or float.

  • b'partial', 'full' or float.

  • c'partial', 'full' or float.

  • d'partial', 'full' or float.

fit(log_dilution, response, sample_labels, data=None, draws=10000, prior_predictive=False, **kwds)

Fit parameters of the sigmoid curve to data.

Parameters
  • log_dilution (Union[Iterable[numbers.Real], Hashable]) – Log dilution values.

  • response (Union[Iterable[numbers.Real], Hashable]) – Response values.

  • sample_labels (Union[Iterable[Hashable], Hashable]) – Sample labels.

  • data (Optional[pandas.core.frame.DataFrame]) – Optional DataFrame. If supplied then log_dilutions, response, and sample_labels should be columns in the DataFrame.

  • draws (int) – Number of samples to draw from the posterior distribution.

  • kwds – Passed to pymc3.sample().

  • prior_predictive (bool) – Sample from the prior predictive distribution. The returned Sigmoid object has a prior_predictive attribute.

Returns

Sigmoid object with posterior attribute.

plot_sample(sample, points=True, mean=False, scatter_kwds=None, line_kwds=None, step=1000, match_point_color_to_line_color=False, xmin=None, xmax=None)

Plot sigmoid curves from the posterior distribution of a sample.

Parameters
  • sample (Hashable) – The sample to plot.

  • points (bool) – Whether to plot the data as well.

  • mean (bool) – Show the mean of the posterior distribution, rather than samples from the posterior.

  • scatter_kwds (Optional[dict]) – Passed to matplotlib.pyplot.scatter(). Used to control the appearance of the data points.

  • line_kwds (Optional[dict]) – Passed to matplotlib.pyplot.plot(). Used to control the appearance of the lines.

  • step (int) – Show every step’th sample from the posterior. Only has an effect if mean is False.

  • match_point_color_to_line_color (bool) – Match the color of the data points to the lines. This is useful when you want different samples on a single plot to have distinct colors, but for the lines and points of one sample to match.

  • xmin (Optional[numbers.Real]) – Lowest value on the x-axis to plot. Log dilution units. If None, the lowest log dilution in the data is used.

  • xmax (Optional[numbers.Real]) – Highest value on the x-axis to plot. Log dilution units. If None, the highest log dilution in the data is used.

Return type

None

plot_samples(samples, **kwds)

Plot sigmoid curves of samples using the mean value of the posterior distribution.

Parameters
Return type

None

plot_all_samples(samples_per_ax=9, n_cols=4, ax_width=7, ax_height=4)

Plot sigmoid curves for all samples using the mean posterior value of each parameter.

Parameters
  • samples_per_ax (int) – Number of samples to put on a single ax.

  • n_cols (int) – Number of columns of axes. The number of rows is computed based on this and samples_per_ax.

  • ax_width (numbers.Real) – Width of a single ax.

  • ax_height (numbers.Real) – Height of a single ax.

Return type

None

inflections(hdi_prob=0.95)

Summarise the posterior distribution of inflection points for each sample.

The returned DataFrame has these columns:

  • mean: Mean value.

  • median: Median value.

  • hdi low: Lower boundary of the highest density interval (HDI).

  • hdi high: Upper boundary of the HDI.

Parameters

hdi_prob (float) – The width of the HDI to calculate.

Return type

pandas.core.frame.DataFrame

endpoints(cutoff_proportion=None, cutoff_absolute=None, hdi_prob=0.95)

Compute endpoints for each sample, given some response. An endpoint is the dilution at which a particular value of the response is obtained, known as the cut-off. The cut-off is either in absolute units, or given as a proportion of d.

Must supply exactly one of either cutoff_proportion or cutoff_absolute.

The returned DataFrame contains endpoints on the log-transformed scale.

Parameters
  • cutoff_proportion (Optional[numbers.Real]) – Proportion of d. Must be in interval (0, 1).

  • cutoff_absolute (Optional[numbers.Real]) – Absolute value of d.

  • hdi_prob (numbers.Real) –

Return type

pandas.core.frame.DataFrame

scale(x)

Log dilutions are scaled to have mean of 0 and standard deviation of 1 for efficient inference. Apply the same scaling to x, i.e. from the log dilution scale to the standardised log dilution scale.

Parameters

x (Union[numbers.Real, numpy.ndarray]) – Value(s) to scale.

Return type

Union[numbers.Real, numpy.ndarray]

inverse_scale(x)

Log dilutions are scaled to have mean of 0 and standard deviation of 1 for efficient inference. Apply the inverse scaling to x, i.e. from the standardised log dilution scale back to the log dilution scale.

Parameters

x (Union[numbers.Real, numpy.ndarray]) – Value(s) to scale.

Return type

Union[numbers.Real, numpy.ndarray]

property log_dilutions

Sorted array of unique log dilutions in the data.

property log_dilutions_std

Sorted array of unique standardised log dilutions in the data.

ititer.titer_to_index(titer, start, fold)

Log transform a titer / dilution to its position in a dilution series.

Titers are referred to by their reciprocal, so a titer/dilution of ‘1/10’ is referred to as simply ‘10’.

A starting dilution of 10 and a fold change of 2 will generate a dilution series of: (10, 20, 40, 80, 160, …). This function takes a dilution, and returns its index in the dilution series.

Parameters
  • titer (Union[Iterable[numbers.Real], numbers.Real]) – Titer(s) to transform.

  • start (numbers.Real) – Starting dilution of the series.

  • fold (numbers.Real) – Fold change of the series.

Return type

Union[Iterable[numbers.Real], numbers.Real]