Skip to content

Instantly share code, notes, and snippets.

@yannabraham
Last active February 26, 2025 14:29
Show Gist options
  • Save yannabraham/5f210fed773785d8b638 to your computer and use it in GitHub Desktop.
Save yannabraham/5f210fed773785d8b638 to your computer and use it in GitHub Desktop.
How to do Dose/Response curve fitting in Python for Drug Discovery
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amnfar
Copy link

amnfar commented Sep 29, 2022

Nice attempt. May be code should be more explanatory and have more comments,

@resminer
Copy link

resminer commented May 14, 2024

Copied as-is into a new jupyter session, I get the following after assigning fitCompound:

[/var/folders/2s/9l3t4cfj0c5g1s4_7shzc5900000gp/T/ipykernel_19131/1118045928.py:7](http://localhost:8888/var/folders/2s/9l3t4cfj0c5g1s4_7shzc5900000gp/T/ipykernel_19131/1118045928.py#line=6): RuntimeWarning: invalid value encountered in log
  return(c+(d-c)[/](http://localhost:8888/)(1+np.exp(b*(np.log(x)-np.log(e)))))

Then a type error making the lmplot:

TypeError                                 Traceback (most recent call last)
Cell In[81], line 3
      1 refDose = np.linspace(min(drData.logDose)*0.9,max(drData.logDose)*1.1,256)
      2 refDose = (10**-refDose)*1e6
----> 3 sns.lmplot('logDose','response',data=drData,hue='compound',fit_reg=False)
      4 for fit in fitData:
      5     plt.plot([pDose(i) for i in refDose],[ll4(i,*[fit[i] for i in ['b','c','d','e']]) for i in refDose])

TypeError: lmplot() got multiple values for argument 'data'

@meeuosh
Copy link

meeuosh commented Dec 10, 2024

Copied as-is into a new jupyter session, I get the following after assigning fitCompound:

[/var/folders/2s/9l3t4cfj0c5g1s4_7shzc5900000gp/T/ipykernel_19131/1118045928.py:7](http://localhost:8888/var/folders/2s/9l3t4cfj0c5g1s4_7shzc5900000gp/T/ipykernel_19131/1118045928.py#line=6): RuntimeWarning: invalid value encountered in log
  return(c+(d-c)[/](http://localhost:8888/)(1+np.exp(b*(np.log(x)-np.log(e)))))

Then a type error making the lmplot:

TypeError                                 Traceback (most recent call last)
Cell In[81], line 3
      1 refDose = np.linspace(min(drData.logDose)*0.9,max(drData.logDose)*1.1,256)
      2 refDose = (10**-refDose)*1e6
----> 3 sns.lmplot('logDose','response',data=drData,hue='compound',fit_reg=False)
      4 for fit in fitData:
      5     plt.plot([pDose(i) for i in refDose],[ll4(i,*[fit[i] for i in ['b','c','d','e']]) for i in refDose])

TypeError: lmplot() got multiple values for argument 'data'

I have the same problem, anyone found a solution?

@yannabraham
Copy link
Author

@resminer @meeuosh thanks for your patience, the last commit should solve the issue (mixing positional and named arguments is never a good idea!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment