# IC50 with curve fit line and value of IC50 appear on the graph using pgfplot

S(mM)   Activity (%)
0.00080 99 %
0.00800 91 %
0.08000 89 %
0.40000 89 %
0.80000 79 %
1.60000 61 %
4.00000 39 %
8.00000 25 %
80.00000    4 %


and also IC50 value appear at 50% inhibition on the graph with curve fit line like EC50.

I give sample (modefied by me) from web site http://bpsbioscience.com/poly-adp-ribose-polymerase/inhibitors/xav-939-27100

-
Most of us are not familiar with IC50 plots: could you link to an example? –  Joseph Wright Oct 16 '12 at 8:26
On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are "too localized". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. –  Andrew Uzzell Oct 16 '12 at 8:32
sorry, actually this question is related with tex.stackexchange.com/questions/29633/… but i really dont know how to play with this latex. I am sorry, but I assure you this IC50 is generally used by biochemist. So this is useful question to help many people related with drug/enzymatic studies. –  limpato Oct 16 '12 at 8:39
Instead of linking to the question why don't you put a MWE such that we can directly copy/paste and see if we can come up something? As @AndrewUzzell commented, it is very likely that this question will be closed as too localized because it is a do-it-for-me question. –  percusse Oct 16 '12 at 9:39
Sorry for my bad manner. Please dont close it if you know the answer, it will help thousands of "totally beginner" like me who need this for their research. –  limpato Oct 16 '12 at 9:50

As stated in the comments to @Habi's answer, pgfplots cannot perform a non-linear regression of your data. That's why you have to rely on an external tool (I used a quick fit routine in gnuplot).

Once you obtained the fitted parameter(s), you can use pgfplots to draw a plot of the fitted curve/function, like so:

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{siunitx}
\DeclareSIUnit\Molar{\textsc{m}} % http://tex.stackexchange.com/a/27618/828
\pgfplotsset{compat=1.6}

\begin{document}
\begin{tikzpicture}
\begin{semilogxaxis}[%
xlabel={S / \si{\milli\Molar}},%
ylabel={\% Activity},%
legend pos=south west,%
legend style={cells={anchor=west}}%
]
( 0.00080, 99)
( 0.00800, 91)
( 0.08000, 89)
( 0.40000, 89)
( 0.80000, 79)
( 1.60000, 61)
( 4.00000, 39)
( 8.00000, 25)
(80.00000, 4)
};
% add plot of fitted curve with IC50=2.62645 mM (obtained via gnuplot)
% %Activity = max * S / (IC50 + S) + min
\addplot[red,smooth,domain=1e-3:100] { 100 * 2.63645 / (2.63645 + x) };
\end{semilogxaxis}
\end{tikzpicture}
\end{document}


-
thank you very much for your answer, i have another request if you dont mind, 1) could you calculate it by calling gnuplot in latex? and 2) if you have idea, how to put value of IC50 as i show in sample IC50 graph above? –  limpato Oct 16 '12 at 16:03
@limpato: Have a look at tex.stackexchange.com/questions/29633/… for one way of doing that. –  Jake Oct 17 '12 at 6:59
@limpato ad 1) While you can do that (see @Jake's comment), I prefer not to. In particular, because I like to keep the data evaluation and the reporting separate. ad 2) You can draw nodes within the plot's coordinate system using the axis cs key for coordinates. –  hakaze Oct 17 '12 at 7:21
@Jake and hakaze Thank you, I have tried to create the graph according your suggestion in that page, I found the blue line shift to left side after print to pdf. my computer, I use Japanese Windows XP SP3, Miktex 2.9, gnuplot 4.6, TexStudio 2.4. Do you know what is wrong? Please check docs.google.com/file/d/0B851Prvsye7yRG1uTXZ3SnhPSEE/edit?pli=1 –  limpato Oct 17 '12 at 7:40
@limpato Your question won't be seen by many people here, so it would be best to repost it as a fresh question including a minimal working example (MWE). Follow-up questions like this are more than welcome! Please use the "Ask Question" link for your new question; there you can link to this question to provide the background. –  hakaze Oct 18 '12 at 13:42

I suppose that's not what you want, is it?

\documentclass{article}
\usepackage{pgf}
\usepackage{pgfplots}
\usepackage[active,tightpage]{preview}
\usepackage{siunitx}
\DeclareSIUnit\Molar{\textsc{m}} % http://tex.stackexchange.com/a/27618/828
\PreviewEnvironment{tikzpicture}

\begin{document}
\begin{tikzpicture}
\begin{semilogxaxis}[%
xlabel={S [\si{\milli\Molar}]},%
ylabel=Activity%
]
( 0.00080, 99)
( 0.00800, 91)
( 0.08000, 89)
( 0.40000, 89)
( 0.80000, 79)
( 1.60000, 61)
( 4.00000, 39)
( 8.00000, 25)
(80.00000, 4)
};
\end{semilogxaxis}
\end{tikzpicture}

\end{document}


which ends up to look like this:

update: code changed to reflect the example posted.

-
thank you for your help, but I need curve fit line sigmoid which called from gnuplot and also IC50 is written in the graph as sample i send. –  limpato Oct 16 '12 at 9:35
@limpato please the pgfplots manual section 4.2.5 "Computing Coordinates with Mathematical Expressions (gnuplot)". AFAIK pgfplots can only perform a linear regression on its own. So you will have to perform the sigmoidal fit externally. –  hakaze Oct 16 '12 at 12:18
As @hakaze said, you cannot calculate the curve fit directly with TikZ, you need to calculate it externally and then bring it back into the plot. You might be able to work with MATLAB or python, which both can export to TikZ with either github.com/nschloe/matlab2tikz or github.com/nschloe/matplotlib2tikz –  Habi Oct 16 '12 at 12:42