dose_utils
- synergy.utils.dose_utils.aggregate_replicates(d, E, aggfunc=<function median>)[source]
Aggregate rows of d and E with repeated combination doses.
- Parameters:
d – Doses, shape (n_samples, n_drugs)
E – Responses, shape (n_samples,)
aggfunc (Callable, optional) – Function to aggregate replicate values of E, default is np.median
- Returns:
d – Unique doses, shape (n_unique_samples, n_drugs)
E – Aggregated responses, shape (n_unique_samples,)
- synergy.utils.dose_utils.get_drug_alone_mask_ND(d, drug_idx)[source]
Return a mask of rows where only the requested drug is present.
Note: other drugs are considered to be absent as long as they are at their minimum dose.
- synergy.utils.dose_utils.get_drug_subset_mask_ND(d, drug_indices)[source]
Return a mask of rows where only the requested drugs are present.
Note: other drugs are considered to be absent as long as they are at their minimum dose.
- synergy.utils.dose_utils.get_monotherapy_mask_ND(d)[source]
Return a mask of rows where no more than 1 drug is present in the given N-drug dose array.
This helps to set synergy to the default value for monotherapy combinations.
- Parameters:
d (ArrayLike) – Dose array, shape (n_samples, n_drugs)
- Return Tuple[np.ndarray]:
Mask of rows where no more than 1 drug is present
- Return type:
Tuple[ndarray]
- synergy.utils.dose_utils.is_monotherapy_ND(d)[source]
Return True if no more than 1 drug is present in the given N-drug dose array.
This should only be applied to a single row (i.e., a single dose combination).
Note, this still returns True if no drugs are present.
- Parameters:
d (ArrayLike) – Dose array, shape (n_samples, n_drugs)
- Return bool:
True if no more than 1 drug is present in the given N-drug dose array
- Return type:
- synergy.utils.dose_utils.is_on_grid(d)[source]
Return True if the doses are on a grid.
Doses are on a grid if all possible combinations of unique doses are present.
- Return type:
Parameters:
- d
Doses, shape (n_samples, n_drugs)
- synergy.utils.dose_utils.make_dose_grid(d1min, d1max, d2min, d2max, n_points1, n_points2, replicates=1, logscale=True, include_zero=False)[source]
Create a grid of doses.
If
`logscale`is True, use`include_zero=True`instead of setting the min dose to 0.
- Parameters:
d1min (float) – Minimum dose for drug 1
d1max (float) – Maximum dose for drug 1
d2min (float) – Minimum dose for drug 2
d2max (float) – Maximum dose for drug 2
n_points1 (int) – Number of distinct doses to include for drug 1
n_points2 (int) – Number of distinct doses to include for drug 2
replicates (int) – The number of replicates to include for each dose combination
logscale (bool) – If True, doses will be uniform in log space. If False, doses will be uniform in linear space.
include_zero (bool) – If True, will include a dose of 0. (Only used if
`logscale`is True)- Returns:
(d1, d2)
- Return type:
- synergy.utils.dose_utils.make_dose_grid_multi(dmin, dmax, npoints, logscale=True, include_zero=False, replicates=1)[source]
Create a grid of doses for N drugs.
- Parameters:
dmin (Sequence[float]) – Sequence of minimum doses for each drug
dmax (Sequence[float]) – Sequence of maximum doses for each drug
npoints (Sequence[int]) – Sequence of number of distinct doses to include for each drug
logscale (bool) – If True, doses will be uniform in log space. If False, doses will be uniform in linear space.
include_zero (bool) – If True, will include a dose of 0
replicates (int) – The number of replicates to include for each dose combination
- Return np.ndarray:
Dose grid
- Return type:
ndarray
- synergy.utils.dose_utils.remove_zeros(d, min_buffer=0.2, num_dilutions=1)[source]
Replace zeros with a small value based on the dilution factor between the smallest non-zero doses.
When plotting on a log scale, 0 doses can cause problems. This replaces all 0’s using the dilution factor between the smallest non-zero, and second-smallest non-zero doses. If that dilution factor is too close to 1, it will replace 0’s doses with a dose that is min_buffer*(max(d)-min(d[d>0])) less than min(d[d>0]) on a log scale.
- Parameters:
d – Doses to remove zeros from. Original array will not be changed.
min_buffer (float , default=0.2) – For high resolution dose arrays with very small step sizes (useful for getting smooth plots), replacing 0’s based on the dilution factor may lead to a value too close to the smallest non-zero dose. min_buffer is the minimum buffer (in log scale, relative to the full dose range) that 0’s will be replaced with.