himoto / hillfit

Fitting the Hill Equation to Experimental Data
MIT License
11 stars 4 forks source link

How can i save the EC50 value as a variable? #1

Closed ship-of-sisyphus closed 2 years ago

ship-of-sisyphus commented 2 years ago

The EC50 is an attribute of the Params class. I understand i can view it when i say model.fitting(), but I can't seem to be able to save just the EC50 value to a list. Please help! Otherwise this repo is super useful!

himoto commented 2 years ago

Hello @ship-of-sisyphus , thank you for your suggestion.

I pushed extract-EC50 branch that you could try out. You can install it via:

$ git clone -b extract-EC50 https://github.com/himoto/hillfit

After running model.fitting, you can get all estimated parameters including EC50 via:

>>> from hillfit import HillFit
>>> x_data = [
...   9.210, 10.210, 10.580, 10.830, 11.080,
...   11.330, 11.580, 11.830, 12.080, 12.330,
...   12.580, 12.830, 13.080, 13.330, 13.580,
...   13.830, 14.080, 14.330, 14.580, 14.830,
...   15.080, 15.330, 15.580, 15.830, 17.580
... ]
>>> y_data = [
...    0.000, 0.000, 0.000, 1.667, 2.222,
...    5.682, 9.524, 15.315, 16.000, 31.183,
...    39.000, 47.222, 47.475, 63.208, 77.143,
...    75.214, 80.612, 92.784, 94.167, 93.137,
...    95.902, 96.396, 97.872, 98.246, 100.000
... ]
>>> model = HillFit(x_data, y_data)
>>> x_fit, y_fit = model.fitting()
>>> model.params.EC50
12.94410262619117

Is this alright with you?

freiburgermsu commented 2 years ago

Hello @ship-of-sisyphus, The script has been updated. The EC50 parameter value of a fitted equation is now stored with hf.ec50, after executing the following sequence:

from hillfit import HillFit

hf = HillFit(x_data, y_data)
hf.fitting()

# print the EC50 value
print(hf.ec50)

This is elaborated further in the README, and is exemplified in the Notebook example in the "examples" directory of the GitHub. :)

himoto commented 2 years ago

Thanks @freiburgermsu , I think now extract-EC50 branch is no longer needed. I will delete it.

Hello @ship-of-sisyphus , please follow the example above!