# Fitting dose response curves

**URL:** <https://discourse.julialang.org/t/fitting-dose-response-curves/12856>\
**Category:** General Usage\
**Created:** [August 3, 2018, 12:29pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856 "2018-08-03T12:29:42Z")\
**Posts on this page:** 16\
**Page:** 2

<div class="post-metadata">

**Author:** ![pkofod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkofod/32/2179_2.png) [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Post date:** [August 6, 2018, 4:39pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/21 "2018-08-06T16:39:16Z")

</div>

What tools do you normally use (outside of Julia) ?

---

<div class="post-metadata">

**Author:** ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)\
**Post date:** [August 6, 2018, 5:08pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/22 "2018-08-06T17:08:08Z")

</div>

I did most of my dissertation work in R, particularly using the DRC package. I also did some simulations estimating LC50 using GLM in R, both in a frequentist and a Bayesian approaches. I only started using Julia after my PhD, when I had time to try and learn something new.

---

<div class="post-metadata">

**Author:** ![Moses](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Moses](https://discourse.julialang.org/u/Moses)\
**Post date:** [August 6, 2018, 5:46pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/23 "2018-08-06T17:46:19Z")

</div>

> [@iewaij](#):
>
> Oh sorry I was experimenting some modifications on `OptimBase` . The 21st line of `curve_fit.jl` should be:
> 
> ```julia
> return LsqFitResult(n, dof, p, ydata, f(p), g(p), wt, summary(results), OptimBase.iterations(results), converged(results))
> 
> ```
> 
> I added the prefix in my repo, maybe try again?

Thanks. I will try it tomorrow.

---

<div class="post-metadata">

**Author:** ![Moses](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Moses](https://discourse.julialang.org/u/Moses)\
**Post date:** [August 6, 2018, 6:13pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/24 "2018-08-06T18:13:45Z")

</div>

@alejandromerchan I think you are right that a dedicated package would make things easier for casual users. On the other hand, as the tools are obviously already existing, it might just be easier to write up some tutorials or extend the present ones.

Especially with Julia v1.0 knocking at the door, this step might help some new users, who have no extensive experience in programming. As I wrote in the beginning, some of the documentation is very technical and somewhat difficult to understand (at least for me). Most of the examples seemed to me rather specialised, but maybe I am just coming from the “wrong” field of work. Altogether, I had the feeling that the documentation was written for other developers or users with long-time experience in R, MatLab or similar statistical/mathematical programming languages.

But then again, there’s this nice community here, that helped me fast. Thank you, all of you!

---

<div class="post-metadata">

**Author:** ![Moses](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Moses](https://discourse.julialang.org/u/Moses)\
**Post date:** [August 6, 2018, 6:18pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/25 "2018-08-06T18:18:38Z")

</div>

> [@pkofod](#):
>
> What tools do you normally use (outside of Julia) ?

Currently, I mainly use Excel (to prepare my data and do simple corrections, like substract background values), and Origin for Curve fitting and statistics.

I have also used GraphPad Prism for a while (mainly for statistics).

---

<div class="post-metadata">

**Author:** ![pkofod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkofod/32/2179_2.png) [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Post date:** [August 6, 2018, 6:19pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/26 "2018-08-06T18:19:57Z")

</div>

Interesting, good to know. This is the one you’re talking about right ? [Curve Fitting](https://www.originlab.com/index.aspx?go=Products/Origin/DataAnalysis/CurveFitting)

---

<div class="post-metadata">

**Author:** ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)\
**Post date:** [August 6, 2018, 6:23pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/27 "2018-08-06T18:23:55Z")

</div>

I don’t have much experience with commercial software for dose response analysis, because I’ve always gravitated towards open source and had a good background in R when I started analyzing that type of data. I guess tutorials could be a good compromise, without the pain of developing a package.

---

<div class="post-metadata">

**Author:** ![Moses](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Moses](https://discourse.julialang.org/u/Moses)\
**Post date:** [August 6, 2018, 6:33pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/28 "2018-08-06T18:33:19Z")

</div>

@pkofod Exactly. Here’s an overview of their sigmoidal fitting algorithms: [Origin for Pharmacologic Analysis](https://www.originlab.com/index.aspx?go=Solutions/Applications/Pharmacology#Dose-Response) Analysis (there’s problem with the link: They put a blank in the URL between “Response” and “Analysis”. One has to append it manually.)

@alejandromerchan The lab where I did my PhD had the commercial software available and used for a long time. I only recently had to start watching out for alternatives.

---

<div class="post-metadata">

**Author:** ![pkofod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkofod/32/2179_2.png) [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Post date:** [August 6, 2018, 6:54pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/29 "2018-08-06T18:54:54Z")

</div>

That is certainly within the realm of LsqFit. There’s a long way to a full GUI interface, but the plotting could certainly be done using recipes.

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [August 6, 2018, 7:20pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/30 "2018-08-06T19:20:34Z")

</div>

The recipe framework for interactive visualizations with Interact.jl is more or less ready.

When you have the Plots recipe ready and know which variables should be included in the GUI, this could be a good interactive recipe example.

---

<div class="post-metadata">

**Author:** ![pkofod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pkofod/32/2179_2.png) [@pkofod](https://discourse.julialang.org/u/pkofod)\
**Post date:** [August 6, 2018, 7:26pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/31 "2018-08-06T19:26:50Z")

</div>

That would be very cool. Should I visit Interact.jl to learn more? Or is discussed elsewhere?

---

<div class="post-metadata">

**Author:** ![alejandromerchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alejandromerchan/32/10500_2.png) [@alejandromerchan](https://discourse.julialang.org/u/alejandromerchan)\
**Post date:** [August 6, 2018, 7:46pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/32 "2018-08-06T19:46:21Z")

</div>

One important thing to note is that this goes beyond dose-response and the analysis of sigmoidal curves is used in a lot of different processes. I know, from my biological background, at least two that I did for my MSc and PhD, one is cline fitting in hybrid zones, where alelles in one gene can go from 0 (absence) to 1 (fixation) in a transect. And fitting those clines can give you information about evolutionary processes in those genes. And second obviously is the whole pharmacological aspect of dose-response, that has a lot of applications in ecology, medicine, etc. That’s why I think is important to have a dedicated package, the key point is to do it with enough abstraction that it can be used with different models in different fields. I’m not capable of leading the development of something like that, but I’m sure some people reading this are. And hopefully this thread can pique their curiosity.

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [August 6, 2018, 10:46pm UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/33 "2018-08-06T22:46:05Z")

</div>

There are some docs [here](https://juliagizmos.github.io/Interact.jl/latest/custom_widgets.html) and if you head over to StatPlots.jl there is the `dataviewer` recipe you can look at. Otherwise [this blog post](https://piever.github.io/simpleblog/post/sputnik4/) may be helpful. If you’re at JuliaCon, interactive recipes could be an interesting topic to discuss during the Hackathon.

---

<div class="post-metadata">

**Author:** ![Moses](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Moses](https://discourse.julialang.org/u/Moses)\
**Post date:** [August 7, 2018, 7:43am UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/34 "2018-08-07T07:43:36Z")

</div>

> [@iewaij](#):
>
> I added the prefix in my repo, maybe try again?

I tried it again. Now it works. Thanks. I am looking forward to seeing that merged into the current LsqFit or another official package.

---

<div class="post-metadata">

**Author:** ![Moses](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Moses](https://discourse.julialang.org/u/Moses)\
**Post date:** [August 7, 2018, 8:00am UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/35 "2018-08-07T08:00:23Z")

</div>

> [@piever](#):
>
> When you have the Plots recipe ready and know which variables should be included in the GUI, this could be a good interactive recipe example.

@piever How should one try to define recipes? With `RecipesBase.jl`?

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [August 7, 2018, 10:34am UTC](https://discourse.julialang.org/t/fitting-dose-response-curves/12856/36 "2018-08-07T10:34:29Z")

</div>

Yes, [here](http://docs.juliaplots.org/latest/recipes/) there are some docs on how to create Plots recipes, again StatPlots has a few examples you can look at.

[Previous page](https://discourse.julialang.org/t/fitting-dose-response-curves/12856.md?page=1)
