Skip to contents

The gDR Hill curve fit: the one fitting path for single-agent, co-dilution, combination and time-course data. By default a 3-parameter model with x_0 fixed at 1; set x_0 to fix it elsewhere (the combination co-treatment fits) or to NA to fit it (4-parameter model). Priors and bounds per normalization type come from inst/extdata/fit_profiles.json. The optimiser is solver, solver_drc by default; any function with its signature can replace it. For use with apply_fit_to_se or apply_fit.

Usage

fit_drug_response_metrics(
  avg_dt,
  x_col = "x",
  capping_fold = 5,
  range_conc = c(0.005, 5),
  pcutoff = 0.05,
  n_point_cutoff = 4L,
  force_fit = FALSE,
  cap = 0.1,
  x_0 = 1,
  solver = solver_drc,
  solver_control = list()
)

Arguments

avg_dt

data.table of averaged data for one (drug x cell line x normalization_type) triplet. Should contain columns Concentration, the response column named by x_col, normalization_type, and optionally x_std (used for x_sd_avg).

x_col

string; name of the response column in avg_dt. Defaults to "x" (the standard Averaged assay column name). Set to e.g. "NormalizedGrowthRate" when fitting time-course growth-rate data.

capping_fold

numeric capping fold passed to cap_xc50

range_conc

numeric vector of length 2 specifying the concentration range used to compute x_AOC_range. Default c(5e-3, 5), matching the fit_SE() default.

pcutoff

numeric p-value cutoff for the fit. Default 0.05.

n_point_cutoff

integer minimum number of concentration points required to attempt fitting. Default 4L.

force_fit

logical; if TRUE, force fitting even when the number of points is below n_point_cutoff. Default FALSE.

cap

numeric; upper cap on xc50 relative to the concentration range. Default 0.1.

x_0

numeric; the upper asymptote, fixed in the fit. Default 1. NA fits it (4-parameter model).

solver

function fitting the Hill parameters, with the signature of solver_drc (the default). See get_solvers.

solver_control

named list passed to solver as its control argument (for solver_drc, drc::drmc() settings).

Value

Named list of fit metrics fully compatible with the standard gDR Metrics assay schema: ec50, xc50, h, x_inf, x_0, r2, rss, p_value, x_mean, x_AOC, x_AOC_range, x_max, x_sd_avg, N_conc, maxlog10Concentration, fit_type, normalization_type. fit_type is one of:

  • "DRC3pHillFitModelFixS0" ("DRC4pHillFitModel" for the 4-parameter variant): the curve was fitted;

  • "DRCConstantFitResult": all responses are equal, or the fit is not significant at pcutoff (its p_value and rss are kept); the curve is flat at the mean response;

  • "DRCTooFewPointsToFit": fewer than n_point_cutoff concentrations with a response; no curve parameters;

  • "DRCInvalidFitResult": the solver failed; no curve parameters.

A constant fit reports the flat curve: x_0 = x_inf = x_mean.

See also

fit_drug_response_metrics_4p for a 4-parameter variant that fits x_0 freely.

Examples

dt <- data.table::data.table(
  Concentration = c(0.001, 0.01, 0.1, 1, 10),
  x = c(0.95, 0.8, 0.5, 0.2, 0.1),
  normalization_type = "RV"
)
fit_drug_response_metrics(dt)
#> $normalization_type
#> [1] "RV"
#> 
#> $x_mean
#> [1] 0.5070152
#> 
#> $x_AOC
#> [1] 0.4929848
#> 
#> $x_AOC_range
#> [1] 0.5471268
#> 
#> $x_max
#> [1] 0.1
#> 
#> $x_sd_avg
#> [1] NaN
#> 
#> $N_conc
#> [1] 5
#> 
#> $maxlog10Concentration
#> [1] 1
#> 
#> $ec50
#> [1] 0.07913255
#> 
#> $xc50
#> [1] 0.09530136
#> 
#> $h
#> [1] 0.6523032
#> 
#> $r2
#> [1] 0.9996676
#> 
#> $rss
#> [1] 0.00018015
#> 
#> $p_value
#> [1] 6.059718e-06
#> 
#> $x_0
#> [1] 1
#> 
#> $x_inf
#> [1] 0.05710528
#> 
#> $fit_type
#> [1] "DRC3pHillFitModelFixS0"
#> 

# Custom response column (e.g. time-course growth rates):
dt2 <- data.table::data.table(
  Concentration = c(0.001, 0.01, 0.1, 1, 10),
  NormalizedGrowthRate = c(0.98, 0.82, 0.55, 0.21, 0.09),
  normalization_type = "GR"
)
fit_drug_response_metrics(dt2, x_col = "NormalizedGrowthRate")
#> $normalization_type
#> [1] "GR"
#> 
#> $x_mean
#> [1] 0.5299304
#> 
#> $x_AOC
#> [1] 0.4700696
#> 
#> $x_AOC_range
#> [1] 0.5198366
#> 
#> $x_max
#> [1] 0.09
#> 
#> $x_sd_avg
#> [1] NaN
#> 
#> $N_conc
#> [1] 5
#> 
#> $maxlog10Concentration
#> [1] 1
#> 
#> $ec50
#> [1] 0.111215
#> 
#> $xc50
#> [1] 0.1259556
#> 
#> $h
#> [1] 0.6665989
#> 
#> $r2
#> [1] 0.9981679
#> 
#> $rss
#> [1] 0.001068109
#> 
#> $p_value
#> [1] 7.841885e-05
#> 
#> $x_0
#> [1] 1
#> 
#> $x_inf
#> [1] 0.03980943
#> 
#> $fit_type
#> [1] "DRC3pHillFitModelFixS0"
#>