Skip to content

Swarchal/pydrc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyDRC

Dose response curve fitting in python.

Still a work in progress.

Package aims:

  • Simple scikit-learn like API.
  • Easy to use with pandas DataFrames or numpy arrays.
  • Sensible default parameters, but ability to tweak everything if needed.
  • Easily extendable if customisation is required.
  • Similar results to GraphPad Prism or R's drc package on the same datasets.

examples

Single compound 3-param model.

import pydrc

df = (
    pydrc.data.two_cmpds()
    .dropna()
    .query("drug == 'A'")
)
print(df.head())
        conc  response drug
1.000000e-10       0.0    A
1.000000e-08       1.0    A
3.000000e-08      12.0    A
1.000000e-07      19.0    A
3.000000e-07      28.0    A
drc = pydrc.DRC3()
drc.fit(x=df_a.conc, y=df_a.response)

print(drc.param_store)
Params(
    top=40.50445968423368,
    bottom=0.3224712712407177,
    ec50=1.1004776487262973e-07,
    hillslope=1.0
)

Multi compound 3-param model.

import pydrc

df = pydrc.data.two_cmpds().dropna()

drc = pydrc.DRC3()
drc.fit(x=df.conc, y=df.response, c=df.drug)
drc.plot()

pydrc_3param

print(drc.param_store)
{
    'A': Params(top=40.5, bottom=0.3, ec50=1.1e-07, hillslope=1.0),
    'B': Params(top=34.8, bottom=-0.1, ec50=6.9e-07, hillslope=1.0)
}

Multi compounds 4-parameter model specifying parameter bounds.

import pydrc

df = pydrc.data.two_cmpds().dropna()

# top, bottom, ec50, hillslope
mins = (0, 0, 0, -3)
maxs = (100, 100, 1, 3)

drc = pydrc.DRC4(bounds=(mins, maxs))

drc.fit(df.conc, df.response, df.drug)
drc.plot()

pydrc_4param

print(drc.param_store)
{
    'A': Params(top=41.9, bottom=2.3, ec50=2.9e-06, hillslope=0.8),
    'B': Params(top=34.7, bottom=8.9e-16, ec50=4.7e-07, hillslope=1.0)
}

Multi compounds, parameter bounds and rescaling values to min-max.

import pydrc

df = pydrc.data.two_cmpds().dropna()

# top, bottom, ec50, hillslope
mins = (0, 0, 0, 0.5)
maxs = (100, 0, 1, 1.6)

drc = pydrc.DRC4(rescale=True, bounds=(mins, maxs))

drc.fit(df.conc, df.response, df.drug)
drc.plot()

drc_4param_rescaled

print(drc.param_store)
{
    'A': Params(top=99.9, bottom=0.09, ec50=3.99e-06, hillslope=0.77),
    'B': Params(top=99.9, bottom=0.02, ec50=4.7e-07, hillslope=1.02)
}

About

Dose response curve fitting in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages