synergy.utils

synergy.utils.AIC(sum_of_squares_residuals, n_parameters, n_samples)[source]

Calculate the Akaike Information Criterion.

SOURCE: AIC under the Framework of Least Squares Estimation, HT Banks, Michele L Joyner, 2017 Equations (6) and (16) https://projects.ncsu.edu/crsc/reports/ftp/pdf/crsc-tr17-09.pdf

Parameters:
  • sum_of_squares_residuals (float) – The sum of squares of the residuals

  • n_parameters (int) – The number of parameters in the model

  • n_samples (int) – The number of samples

Return float:

The AIC value

Return type:

float

synergy.utils.BIC(sum_of_squares_residuals, n_parameters, n_samples)[source]

Calculate the Bayesian Information Criterion

Parameters:
  • sum_of_squares_residuals (float) – The sum of squares of the residuals

  • n_parameters (int) – The number of parameters in the model

  • n_samples (int) – The number of samples

Return float:

The BIC value

Return type:

float

synergy.utils.format_table(rows, first_row_is_header=True, col_sep='  |  ')[source]

Format a list of rows into a human readable table.

Parameters:
  • rows (Sequence[Sequence[str]]) – A list of rows, where each row is a list of strings

  • first_row_is_header (bool) – Whether the first row should be formatted as a header

  • col_sep (str) – The separator between columns

Return str:

A string representation of the table

Return type:

str

synergy.utils.r_squared(E, sum_of_squares_residuals)[source]

Calculate the R^2 value.

Parameters:
  • E (ArrayLike) – The observed values

  • sum_of_squares_residuals (float) – The sum of squares of the residuals

Return float:

The R^2 value

Return type:

float

synergy.utils.residual_ss(d1, d2, E, function)[source]

Calculate the sum of squares of the residuals for a 2D dose response model.

Parameters:
  • d1 (ArrayLike) – The doses of drug 1

  • d2 (ArrayLike) – The doses of drug 2

  • E (ArrayLike) – The observed values

  • function (Callable) – The model to use

synergy.utils.residual_ss_1d(d, E, function)[source]

Calculate the sum of squares of the residuals for a 1D dose response model.

Parameters:
  • d (ArrayLike) – The doses

  • E (ArrayLike) – The observed values

  • function (Callable) – The model to use

synergy.utils.sanitize_initial_guess(p0, bounds)[source]

Ensure sure p0 is within the bounds.

Parameters:
Returns:

The sanitized initial guess

synergy.utils.sanitize_single_drug_model(model, default_type, required_type, **kwargs)[source]

Ensure the given single drug model is a class or object of a class that is permitted for the given synergy model.

Parameters:
  • model (DoseResponseModel1D) – The single drug model

  • default_type (type) – The type of model to return if the given model is None

  • required_type (type) – The class the model is expected to be an instance of

  • kwargs – Additional arguments to pass to the model constructor

Return DoseResponseModel1D:

An object that is an instance of required_type