diff --git a/.gitignore b/.gitignore index 075c900f1fcb3eab244ca4ac90b26c82f267dd8c..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +0,0 @@ -SSBtoolkit-Tutorial1-DEV.ipynb -SSBtoolkit-Tutorial2-DEV.ipynb -SSBtoolkit-Tutorial3A-DEV.ipynb -SSBtoolkit-Tutorial4-OXTR-DEV.ipynb -src/lib/__pycache__/ -src/lib/autogrid_reference_files/ -src/lib/autogrids/ -src/lib/ssbtoolkit_BK.py -.ipynb_checkpoints/ -debugging.txt diff --git a/SI/Gi_parameters.csv b/Reactions_Parameters/Gi_parameters.csv similarity index 100% rename from SI/Gi_parameters.csv rename to Reactions_Parameters/Gi_parameters.csv diff --git a/SI/Gi_reactions.csv b/Reactions_Parameters/Gi_reactions.csv similarity index 100% rename from SI/Gi_reactions.csv rename to Reactions_Parameters/Gi_reactions.csv diff --git a/SI/Gq_parameters.csv b/Reactions_Parameters/Gq_parameters.csv similarity index 100% rename from SI/Gq_parameters.csv rename to Reactions_Parameters/Gq_parameters.csv diff --git a/SI/Gq_reactions.csv b/Reactions_Parameters/Gq_reactions.csv similarity index 100% rename from SI/Gq_reactions.csv rename to Reactions_Parameters/Gq_reactions.csv diff --git a/SI/Gs_parameters.csv b/Reactions_Parameters/Gs_parameters.csv similarity index 100% rename from SI/Gs_parameters.csv rename to Reactions_Parameters/Gs_parameters.csv diff --git a/SI/Gs_reactions.csv b/Reactions_Parameters/Gs_reactions.csv similarity index 100% rename from SI/Gs_reactions.csv rename to Reactions_Parameters/Gs_reactions.csv diff --git a/SI/OXTR_pathway_parameters.csv b/Reactions_Parameters/OXTR_pathway_parameters.csv similarity index 100% rename from SI/OXTR_pathway_parameters.csv rename to Reactions_Parameters/OXTR_pathway_parameters.csv diff --git a/SI/OXTR_pathway_reactions.csv b/Reactions_Parameters/OXTR_pathway_reactions.csv similarity index 100% rename from SI/OXTR_pathway_reactions.csv rename to Reactions_Parameters/OXTR_pathway_reactions.csv diff --git a/docs/_build/doctrees/apidocs.doctree b/docs/_build/doctrees/apidocs.doctree index 950c7982dccbe876784f1a765790a16807645995..411e468fec93d068e06c10eb2c07fda60af01e46 100644 Binary files a/docs/_build/doctrees/apidocs.doctree and b/docs/_build/doctrees/apidocs.doctree differ diff --git a/docs/_build/doctrees/environment.pickle b/docs/_build/doctrees/environment.pickle index 7e1e4f608ec182198255e6006d6276e30ec742eb..a455faaafa7b458943156ea1b8570c26912d1cd0 100644 Binary files a/docs/_build/doctrees/environment.pickle and b/docs/_build/doctrees/environment.pickle differ diff --git a/docs/_build/doctrees/index.doctree b/docs/_build/doctrees/index.doctree index d31a676d874af6ec0359f144403d1d64915ba005..7eea75adca40d1a3ae7007752dabe9d9b066a9f9 100644 Binary files a/docs/_build/doctrees/index.doctree and b/docs/_build/doctrees/index.doctree differ diff --git a/docs/_build/html/.buildinfo b/docs/_build/html/.buildinfo index 3b43f5e212959cc0b226a29b7420924f18113e39..0aef523bec1c319c2bae145d353231bd3056867e 100644 --- a/docs/_build/html/.buildinfo +++ b/docs/_build/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: b647779c966b74360299afc589cf109b +config: b18c64a1de10b91df8b26059330c35f6 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_build/html/_sources/apidocs.rst.txt b/docs/_build/html/_sources/apidocs.rst.txt index 5e709c6d002ac2907ae02e2a73d007b00af41188..964890776c4dbfe1f1bab037d9d74ff75de599f6 100644 --- a/docs/_build/html/_sources/apidocs.rst.txt +++ b/docs/_build/html/_sources/apidocs.rst.txt @@ -1,5 +1,10 @@ API Documentation ================= +.. automodule:: Binding + :members: + +.. automodule:: Simulation + :members: -.. automodule:: ssbtoolkit +.. automodule:: Utils :members: diff --git a/docs/_build/html/_sources/index.rst.txt b/docs/_build/html/_sources/index.rst.txt index 9efec59d6d65006f18dc1b22bc5fa52da45a805d..e304d48faaa089e104fb7ef79fab308cbcfe5c23 100644 --- a/docs/_build/html/_sources/index.rst.txt +++ b/docs/_build/html/_sources/index.rst.txt @@ -46,6 +46,51 @@ protocols. apidocs faq +\ + +\ + +Availability and License +======================== +The source code is freely available at https://github.com/rribeiro-sci/SSBtoolkit under +the Apache 2.0 license. Tutorial notebooks containing minimal working examples can be found at https://github.com/rribeiro-sci/SSBtoolkit. + +\ + +\ + +Developed by +============ +.. image:: https://res.cloudinary.com/djz27k5hg/image/upload/v1637333672/logos/Juelich_logo_100px_ecv2hy.png + :width: 200 + +\ + +\ + +Funded by +========= +.. image:: https://res.cloudinary.com/djz27k5hg/image/upload/v1637657234/logos/HBP_horizontal_logo_qtcyzn.png + :width: 200 + :alt: Alternative text + +Citation |DOI for Citing ssbtoolkit| +==================================== + +pyGOMoDo is research software. If you make use of pyGOMoDo in scientific +publications, please cite it. The BibTeX reference is + +:: + + @article{ribeiro_ssb_2022, + title={{SSB} toolkit: from molecular structure to subcellular signaling pathways.}, + author={Ribeiro, Rui Pedro and Gossen, Jonas and Rossetti, Giulia and Giorgetti, Alejandro}, + publisher={bioRxiv}, + url={https://www.biorxiv.org/content/10.1101/2022.11.08.515595v1}, + doi={10.1101/2022.11.08.515595}, + year={2022} + } + Indices and tables ================== @@ -53,3 +98,7 @@ Indices and tables * :ref:`genindex` * :ref:`modindex` * :ref:`search` + + +.. |DOI for Citing ssbtoolkit| image:: https://img.shields.io/badge/DOI-10.1016%2Fj.bpj.2015.08.015-blue.svg + :target: https://github.com/rribeiro-sci/SSBtoolkit \ No newline at end of file diff --git a/docs/_build/html/_static/custom.css b/docs/_build/html/_static/custom.css new file mode 100644 index 0000000000000000000000000000000000000000..ff0b629c8cb86ed5f2cfb40dcb672e09526cea00 --- /dev/null +++ b/docs/_build/html/_static/custom.css @@ -0,0 +1,15 @@ +.wy-side-nav-search, .wy-nav-top { + background: #EFEFEF; + +} +/* Text inside search */ +.wy-side-nav-search input[type=text] { + color: #000000; +} + + +/* Home button */ +.wy-side-nav-search > a { + color: #555753; + font-size: 25px; +} \ No newline at end of file diff --git a/docs/_build/html/_static/documentation_options.js b/docs/_build/html/_static/documentation_options.js index 742ecad370105b0e8eaff114b937dd24e5f0e549..f933e821895d20c34ae4a4cbbbbdfe52ebc5a0b4 100644 --- a/docs/_build/html/_static/documentation_options.js +++ b/docs/_build/html/_static/documentation_options.js @@ -1,6 +1,6 @@ var DOCUMENTATION_OPTIONS = { URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), - VERSION: 'v1', + VERSION: 'v1.0.1', LANGUAGE: 'None', COLLAPSE_INDEX: false, BUILDER: 'html', diff --git a/docs/_build/html/about.html b/docs/_build/html/about.html index cbf3f0b79cc0e2d1b0c502c269d47ac9d8013d13..a20dae48b0227b277435eda64a16a50d981d401e 100644 --- a/docs/_build/html/about.html +++ b/docs/_build/html/about.html @@ -4,7 +4,7 @@ <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title>What is the SSBtoolkit? — SSBtoolkit v1 documentation</title> + <title>What is the SSBtoolkit? — SSBtoolkit v1.0.1 documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <!--[if lt IE 9]> diff --git a/docs/_build/html/apidocs.html b/docs/_build/html/apidocs.html index 068c98cb71f319f26af6fda83ce877cc022c3412..a4eecd1be8798b160b490687764a458d19336ece 100644 --- a/docs/_build/html/apidocs.html +++ b/docs/_build/html/apidocs.html @@ -4,7 +4,7 @@ <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title>API Documentation — SSBtoolkit v1 documentation</title> + <title>API Documentation — SSBtoolkit v1.0.1 documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <!--[if lt IE 9]> @@ -70,15 +70,11 @@ <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> - <section id="module-ssbtoolkit"> -<span id="api-documentation"></span><h1>API Documentation<a class="headerlink" href="#module-ssbtoolkit" title="Permalink to this headline">ïƒ</a></h1> -<dl class="py class"> -<dt class="sig sig-object py" id="ssbtoolkit.binding"> -<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">ssbtoolkit.</span></span><span class="sig-name descname"><span class="pre">binding</span></span><a class="headerlink" href="#ssbtoolkit.binding" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>This class simulate ligand-target binding curves.</p> -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.binding.bind"> -<span class="sig-name descname"><span class="pre">bind</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.binding.bind" title="Permalink to this definition">ïƒ</a></dt> + <section id="module-Binding"> +<span id="api-documentation"></span><h1>API Documentation<a class="headerlink" href="#module-Binding" title="Permalink to this headline">ïƒ</a></h1> +<dl class="py function"> +<dt class="sig sig-object py" id="Binding.Bind"> +<span class="sig-prename descclassname"><span class="pre">Binding.</span></span><span class="sig-name descname"><span class="pre">Bind</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Binding.Bind" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Applies an function to calculate the fraction of occupited receptors at equilibrium.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -91,9 +87,15 @@ </dl> </dd></dl> -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.binding.maxbend"> -<span class="sig-name descname"><span class="pre">maxbend</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.binding.maxbend" title="Permalink to this definition">ïƒ</a></dt> +<dl class="py function"> +<dt class="sig sig-object py" id="Binding.ShowCurve"> +<span class="sig-prename descclassname"><span class="pre">Binding.</span></span><span class="sig-name descname"><span class="pre">ShowCurve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Binding.ShowCurve" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Plots ligand-target binding curve</p> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="Binding.SubMaxConcentration"> +<span class="sig-prename descclassname"><span class="pre">Binding.</span></span><span class="sig-name descname"><span class="pre">SubMaxConcentration</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">self</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Binding.SubMaxConcentration" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Calculates the maximum bending point of a sigmoid-shaped curve according to the mathod of Sebaugh et al., 2003.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -112,150 +114,13 @@ </div> </dd></dl> -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.binding.show_curve"> -<span class="sig-name descname"><span class="pre">show_curve</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.binding.show_curve" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Plots ligand-target binding curve</p> -</dd></dl> - -</dd></dl> - -<dl class="py class"> -<dt class="sig sig-object py" id="ssbtoolkit.convert"> -<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">ssbtoolkit.</span></span><span class="sig-name descname"><span class="pre">convert</span></span><a class="headerlink" href="#ssbtoolkit.convert" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Helper functions</p> -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.convert.KineticTempScale"> -<span class="sig-name descname"><span class="pre">KineticTempScale</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">koff</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Tu</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'K'</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.convert.KineticTempScale" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>This function rescales the kinetics constants to a specific temperature.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>kon</strong> – Required (flt): foward kinetic constant</p></li> -<li><p><strong>koff</strong> – Required (flt): reverse kinetic constant</p></li> -<li><p><strong>T1</strong> – Required (flt): Initial temperature</p></li> -<li><p><strong>T2</strong> – Required (flt): Final temperature</p></li> -</ul> -</dd> -<dt class="field-even">Paramter Tu</dt> -<dd class="field-even"><p>Optional (kwarg str): Temperature Units (kelvin=’K’, celsius=’C’)</p> -</dd> -<dt class="field-odd">Returns</dt> -<dd class="field-odd"><p>(flt, flt)</p> -</dd> -</dl> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.convert.microgr2nanomolar"> -<span class="sig-name descname"><span class="pre">microgr2nanomolar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">concentration</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.convert.microgr2nanomolar" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>This function converts micrograms of protein in nanomolar.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>uniprotID</strong> – Required (str)</p></li> -<li><p><strong>concentration</strong> – Required (int): concentration od protein in micrograms</p></li> -</ul> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>(flt) concentration of protein in nM</p> -</dd> -</dl> -<div class="admonition note"> -<p class="admonition-title">Note</p> -<p>This function will obtain the sequence of the protein from UNIPROT and calculate automatically its molecular mass</p> -</div> -</dd></dl> - -</dd></dl> - -<dl class="py class"> -<dt class="sig sig-object py" id="ssbtoolkit.get"> -<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">ssbtoolkit.</span></span><span class="sig-name descname"><span class="pre">get</span></span><a class="headerlink" href="#ssbtoolkit.get" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Tools to retrive protein information</p> -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.get.gprotein"> -<span class="sig-name descname"><span class="pre">gprotein</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.get.gprotein" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>This function query the SSBtoolkit internal database to extract the G protein associated to GPCR.</p> -<div class="admonition warning"> -<p class="admonition-title">Warning</p> -<p>it just works for Human GPCRS!</p> -</div> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>uniprotID</strong> – Required (str)</p> -</dd> -<dt class="field-even">Returns</dt> -<dd class="field-even"><p>(str)</p> -</dd> -</dl> -</dd></dl> - -<dl class="py class"> -<dt class="sig sig-object py" id="ssbtoolkit.get.tauRAMD"> -<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">tauRAMD</span></span><a class="headerlink" href="#ssbtoolkit.get.tauRAMD" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Implementation of the tRAMD method by Kokh et al., 2018.</p> -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.get.tauRAMD.Run"> -<span class="sig-name descname"><span class="pre">Run</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.get.tauRAMD.Run" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Calulates the residence time of a ligand from RAMD simualtions.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>prefix</strong> – Required (kwarg str): directory path of .dat files</p></li> -<li><p><strong>dt</strong> – Optional (kwarg flt): MD simulations time step in ns (defaul is 2E-6)</p></li> -<li><p><strong>softwr</strong> – Optional (kwarg str): software used to perform RAMD simulations: NAMD, GROMACS (default)</p></li> -</ul> -</dd> -<dt class="field-even">Return (str)</dt> -<dd class="field-even"><p>residence time</p> -</dd> -</dl> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.get.tauRAMD.plotRTdistribuitons"> -<span class="sig-name descname"><span class="pre">plotRTdistribuitons</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.get.tauRAMD.plotRTdistribuitons" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Plots the residence time distributions</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>save</strong> – Optional (kwarg boolean): default False</p></li> -<li><p><strong>filename</strong> – Optional (kwarg str)</p></li> -</ul> -</dd> -</dl> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.get.tauRAMD.plotRTstats"> -<span class="sig-name descname"><span class="pre">plotRTstats</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.get.tauRAMD.plotRTstats" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Plots the residence time statistics</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><ul class="simple"> -<li><p><strong>save</strong> – Optional (kwarg boolean): default False</p></li> -<li><p><strong>filename</strong> – Optional (kwarg str)</p></li> -</ul> -</dd> -</dl> -</dd></dl> - -</dd></dl> - -</dd></dl> - -<dl class="py class"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation"> -<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">ssbtoolkit.</span></span><span class="sig-name descname"><span class="pre">simulation</span></span><a class="headerlink" href="#ssbtoolkit.simulation" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>This class simulates the mathematical models of the signaling pathways.</p> -<dl class="py class"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation"> -<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">activation</span></span><a class="headerlink" href="#ssbtoolkit.simulation.activation" title="Permalink to this definition">ïƒ</a></dt> +<span class="target" id="module-Simulation"></span><dl class="py class"> +<dt class="sig sig-object py" id="Simulation.Activation"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">Simulation.</span></span><span class="sig-name descname"><span class="pre">Activation</span></span><a class="headerlink" href="#Simulation.Activation" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Simulation of the activation of signaling pathways (i.e. activation by agonists)</p> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.Analysis"> -<span class="sig-name descname"><span class="pre">Analysis</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.Analysis" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Activation.Analysis"> +<span class="sig-name descname"><span class="pre">Analysis</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.Analysis" title="Permalink to this definition">ïƒ</a></dt> <dd><p>This function calculates the dose-response effect.</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> @@ -265,14 +130,8 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.Curve"> -<span class="sig-name descname"><span class="pre">Curve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.Curve" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Plots the dose-response curve.</p> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.PathwayParameters"> -<span class="sig-name descname"><span class="pre">PathwayParameters</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.PathwayParameters" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Activation.PathwayParameters"> +<span class="sig-name descname"><span class="pre">PathwayParameters</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.PathwayParameters" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Display table with default pathway parameters.</p> <div class="admonition warning"> <p class="admonition-title">Warning</p> @@ -281,8 +140,8 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.PathwayParametersToCSV"> -<span class="sig-name descname"><span class="pre">PathwayParametersToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.PathwayParametersToCSV" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Activation.PathwayParametersToCSV"> +<span class="sig-name descname"><span class="pre">PathwayParametersToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.PathwayParametersToCSV" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Export pathway parameters into CSV format.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -292,14 +151,8 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.Potency"> -<span class="sig-name descname"><span class="pre">Potency</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.Potency" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Return the potency values as a pandas DataFrame.</p> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.PotencyToCSV"> -<span class="sig-name descname"><span class="pre">PotencyToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.PotencyToCSV" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Activation.PotencyToCSV"> +<span class="sig-name descname"><span class="pre">PotencyToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.PotencyToCSV" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Exports the potency values into csv format.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -309,26 +162,26 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.PotencyToDict"> -<span class="sig-name descname"><span class="pre">PotencyToDict</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.PotencyToDict" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Activation.PotencyToDict"> +<span class="sig-name descname"><span class="pre">PotencyToDict</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.PotencyToDict" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Convert potencies into a dictionary.</p> </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.Reactions"> -<span class="sig-name descname"><span class="pre">Reactions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.Reactions" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Activation.Reactions"> +<span class="sig-name descname"><span class="pre">Reactions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.Reactions" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Display pathway reactions.</p> </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.Run"> -<span class="sig-name descname"><span class="pre">Run</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.Run" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Activation.Run"> +<span class="sig-name descname"><span class="pre">Run</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.Run" title="Permalink to this definition">ïƒ</a></dt> <dd><p>This function runs the pathway simulation and returns the raw simulation data.</p> </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.SetSimulationParameters"> -<span class="sig-name descname"><span class="pre">SetSimulationParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.SetSimulationParameters" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Activation.SetSimulationParameters"> +<span class="sig-name descname"><span class="pre">SetSimulationParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.SetSimulationParameters" title="Permalink to this definition">ïƒ</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> @@ -350,8 +203,20 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.activation.UserPathwayParameters"> -<span class="sig-name descname"><span class="pre">UserPathwayParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.activation.UserPathwayParameters" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Activation.ShowCurve"> +<span class="sig-name descname"><span class="pre">ShowCurve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.ShowCurve" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Plots the dose-response curve.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="Simulation.Activation.ShowPotency"> +<span class="sig-name descname"><span class="pre">ShowPotency</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.ShowPotency" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return the potency values as a pandas DataFrame.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="Simulation.Activation.UserPathwayParameters"> +<span class="sig-name descname"><span class="pre">UserPathwayParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Activation.UserPathwayParameters" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Import user pathway parameters.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -363,16 +228,16 @@ </dd></dl> <dl class="py class"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.fitModel"> -<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">fitModel</span></span><a class="headerlink" href="#ssbtoolkit.simulation.fitModel" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.FitModel"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">Simulation.</span></span><span class="sig-name descname"><span class="pre">FitModel</span></span><a class="headerlink" href="#Simulation.FitModel" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Fit a model to experimental data.</p> <div class="admonition note"> <p class="admonition-title">Note</p> <p>This class was developed to reproduce data from a specific experimental setup. Please see tutorial 4 (OXTR pathay). Use carefully!</p> </div> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.fitModel.PathwayParameters"> -<span class="sig-name descname"><span class="pre">PathwayParameters</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.fitModel.PathwayParameters" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.FitModel.PathwayParameters"> +<span class="sig-name descname"><span class="pre">PathwayParameters</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.FitModel.PathwayParameters" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Display table with default pathway parameters.</p> <div class="admonition warning"> <p class="admonition-title">Warning</p> @@ -381,8 +246,8 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.fitModel.PathwayParametersToCSV"> -<span class="sig-name descname"><span class="pre">PathwayParametersToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.fitModel.PathwayParametersToCSV" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.FitModel.PathwayParametersToCSV"> +<span class="sig-name descname"><span class="pre">PathwayParametersToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.FitModel.PathwayParametersToCSV" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Export pathway parameters into CSV format.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -392,14 +257,20 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.fitModel.Reactions"> -<span class="sig-name descname"><span class="pre">Reactions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.fitModel.Reactions" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.FitModel.PlotIterations"> +<span class="sig-name descname"><span class="pre">PlotIterations</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.FitModel.PlotIterations" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Plot iterations.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="Simulation.FitModel.Reactions"> +<span class="sig-name descname"><span class="pre">Reactions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.FitModel.Reactions" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Display pathway reactions.</p> </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.fitModel.Run"> -<span class="sig-name descname"><span class="pre">Run</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.fitModel.Run" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.FitModel.Run"> +<span class="sig-name descname"><span class="pre">Run</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.FitModel.Run" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Fits of the model to experimental data.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -416,8 +287,8 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.fitModel.SetSimulationParameters"> -<span class="sig-name descname"><span class="pre">SetSimulationParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.fitModel.SetSimulationParameters" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.FitModel.SetSimulationParameters"> +<span class="sig-name descname"><span class="pre">SetSimulationParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.FitModel.SetSimulationParameters" title="Permalink to this definition">ïƒ</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> @@ -435,19 +306,8 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.fitModel.UserPathwayParameters"> -<span class="sig-name descname"><span class="pre">UserPathwayParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.fitModel.UserPathwayParameters" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Import user pathway parameters.</p> -<dl class="field-list simple"> -<dt class="field-odd">Parameters</dt> -<dd class="field-odd"><p><strong>path</strong> – Required (kwarg str): directory path</p> -</dd> -</dl> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.fitModel.plotCurves"> -<span class="sig-name descname"><span class="pre">plotCurves</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.fitModel.plotCurves" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.FitModel.ShowGraphs"> +<span class="sig-name descname"><span class="pre">ShowGraphs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.FitModel.ShowGraphs" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Plot the amount of obeservable in function of time, Amplitude, Area Under the Curve, and Full Width at Half Maximum.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -460,20 +320,25 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.fitModel.plotIterations"> -<span class="sig-name descname"><span class="pre">plotIterations</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.fitModel.plotIterations" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Plot iterations.</p> +<dt class="sig sig-object py" id="Simulation.FitModel.UserPathwayParameters"> +<span class="sig-name descname"><span class="pre">UserPathwayParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.FitModel.UserPathwayParameters" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Import user pathway parameters.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>path</strong> – Required (kwarg str): directory path</p> +</dd> +</dl> </dd></dl> </dd></dl> <dl class="py class"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition"> -<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">inhibition</span></span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">Simulation.</span></span><span class="sig-name descname"><span class="pre">Inhibition</span></span><a class="headerlink" href="#Simulation.Inhibition" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Simulation of the inhibition of signaling pathways (i.e. inhibition by antagonists).</p> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.Analysis"> -<span class="sig-name descname"><span class="pre">Analysis</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.Analysis" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition.Analysis"> +<span class="sig-name descname"><span class="pre">Analysis</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.Analysis" title="Permalink to this definition">ïƒ</a></dt> <dd><p>This function calculates the dose-response effect.</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> @@ -483,14 +348,8 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.Curve"> -<span class="sig-name descname"><span class="pre">Curve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.Curve" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Plot the dose-response curve.</p> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.PathwayParameters"> -<span class="sig-name descname"><span class="pre">PathwayParameters</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.PathwayParameters" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition.PathwayParameters"> +<span class="sig-name descname"><span class="pre">PathwayParameters</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.PathwayParameters" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Display table with default pathway parameters.</p> <div class="admonition warning"> <p class="admonition-title">Warning</p> @@ -499,8 +358,8 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.PathwayParametersToCSV"> -<span class="sig-name descname"><span class="pre">PathwayParametersToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.PathwayParametersToCSV" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition.PathwayParametersToCSV"> +<span class="sig-name descname"><span class="pre">PathwayParametersToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.PathwayParametersToCSV" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Export pathway parameters into CSV format.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -510,14 +369,8 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.Potency"> -<span class="sig-name descname"><span class="pre">Potency</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.Potency" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Return the potency values as a pandas DataFrame.</p> -</dd></dl> - -<dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.PotencyToCSV"> -<span class="sig-name descname"><span class="pre">PotencyToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.PotencyToCSV" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition.PotencyToCSV"> +<span class="sig-name descname"><span class="pre">PotencyToCSV</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.PotencyToCSV" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Exports the potency values into csv format.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -527,26 +380,26 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.PotencyToDict"> -<span class="sig-name descname"><span class="pre">PotencyToDict</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.PotencyToDict" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition.PotencyToDict"> +<span class="sig-name descname"><span class="pre">PotencyToDict</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.PotencyToDict" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Convert potencies into a dictionary.</p> </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.Reactions"> -<span class="sig-name descname"><span class="pre">Reactions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.Reactions" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition.Reactions"> +<span class="sig-name descname"><span class="pre">Reactions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.Reactions" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Display pathway reactions.</p> </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.Run"> -<span class="sig-name descname"><span class="pre">Run</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.Run" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition.Run"> +<span class="sig-name descname"><span class="pre">Run</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.Run" title="Permalink to this definition">ïƒ</a></dt> <dd><p>This function runs the pathway simulation and returns the raw simulation data.</p> </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.SetSimulationParameters"> -<span class="sig-name descname"><span class="pre">SetSimulationParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.SetSimulationParameters" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition.SetSimulationParameters"> +<span class="sig-name descname"><span class="pre">SetSimulationParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.SetSimulationParameters" title="Permalink to this definition">ïƒ</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> @@ -574,8 +427,20 @@ </dd></dl> <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.UserPathwayParameters"> -<span class="sig-name descname"><span class="pre">UserPathwayParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.UserPathwayParameters" title="Permalink to this definition">ïƒ</a></dt> +<dt class="sig sig-object py" id="Simulation.Inhibition.ShowCurve"> +<span class="sig-name descname"><span class="pre">ShowCurve</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.ShowCurve" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Plot the dose-response curve.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="Simulation.Inhibition.ShowPotency"> +<span class="sig-name descname"><span class="pre">ShowPotency</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.ShowPotency" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Return the potency values as a pandas DataFrame.</p> +</dd></dl> + +<dl class="py method"> +<dt class="sig sig-object py" id="Simulation.Inhibition.UserPathwayParameters"> +<span class="sig-name descname"><span class="pre">UserPathwayParameters</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Simulation.Inhibition.UserPathwayParameters" title="Permalink to this definition">ïƒ</a></dt> <dd><p>Import user pathway parameters.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> @@ -584,12 +449,163 @@ </dl> </dd></dl> +</dd></dl> + +<dl class="py data"> +<dt class="sig sig-object py" id="Simulation.pathways_path"> +<span class="sig-prename descclassname"><span class="pre">Simulation.</span></span><span class="sig-name descname"><span class="pre">pathways_path</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'/home/rribeiro/Projects/SSBtoolkit/ssbtoolkit/pathways'</span></em><a class="headerlink" href="#Simulation.pathways_path" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Module to simulate the mathematical models of the signaling pathways.</p> +</dd></dl> + +<span class="target" id="module-Utils"></span><dl class="py function"> +<dt class="sig sig-object py" id="Utils.CalcOccupancy"> +<span class="sig-prename descclassname"><span class="pre">Utils.</span></span><span class="sig-name descname"><span class="pre">CalcOccupancy</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">receptor_conc</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">agonist_conc</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">antagonist_conc</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pkd_agonist</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pkd_antagonist</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Utils.CalcOccupancy" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>This function calculates the fraction of occupited receptors at equilibrium.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>receptor_conc</strong> – Required (int): concentration of the receptor</p></li> +<li><p><strong>agonists_conc</strong> – Required (int): concentration of the agonist</p></li> +<li><p><strong>antagonists_conc</strong> – Required (int): concentration of the antagonists (0 if antagonist shoul not be considered)</p></li> +<li><p><strong>pkd_agonist</strong> – Required (int): pKd of agonist</p></li> +<li><p><strong>pkd_antagonist</strong> – Required (int): pKd of antagonists (if antagonist shoul not be considered)</p></li> +</ul> +</dd> +<dt class="field-even">Return int</dt> +<dd class="field-even"><p>fraction of occupied receptors in the equilibrium</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="Utils.GetGProtein"> +<span class="sig-prename descclassname"><span class="pre">Utils.</span></span><span class="sig-name descname"><span class="pre">GetGProtein</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">uniprotID</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Utils.GetGProtein" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>This function query the SSBtoolkit internal database to extract the G protein associated to GPCR.</p> +<div class="admonition warning"> +<p class="admonition-title">Warning</p> +<p>it just works for Human GPCRS!</p> +</div> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><p><strong>uniprotID</strong> – Required (str)</p> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>(str)</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="Utils.KineticTempScale"> +<span class="sig-prename descclassname"><span class="pre">Utils.</span></span><span class="sig-name descname"><span class="pre">KineticTempScale</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">kon</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">koff</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">T2</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">Tu</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'K'</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Utils.KineticTempScale" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>This function rescales the kinetics constants to a specific temperature.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>kon</strong> – Required (flt): foward kinetic constant</p></li> +<li><p><strong>koff</strong> – Required (flt): reverse kinetic constant</p></li> +<li><p><strong>T1</strong> – Required (flt): Initial temperature</p></li> +<li><p><strong>T2</strong> – Required (flt): Final temperature</p></li> +</ul> +</dd> +<dt class="field-even">Paramter Tu</dt> +<dd class="field-even"><p>Optional (kwarg str): Temperature Units (kelvin=’K’, celsius=’C’)</p> +</dd> +<dt class="field-odd">Returns</dt> +<dd class="field-odd"><p>(flt, flt)</p> +</dd> +</dl> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="Utils.MicrogramsToNanomolar"> +<span class="sig-prename descclassname"><span class="pre">Utils.</span></span><span class="sig-name descname"><span class="pre">MicrogramsToNanomolar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">uniprotID</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">concentration</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Utils.MicrogramsToNanomolar" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>This function converts micrograms of protein in nanomolar.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>uniprotID</strong> – Required (str)</p></li> +<li><p><strong>concentration</strong> – Required (int): concentration od protein in micrograms</p></li> +</ul> +</dd> +<dt class="field-even">Returns</dt> +<dd class="field-even"><p>(flt) concentration of protein in nM</p> +</dd> +</dl> +<div class="admonition note"> +<p class="admonition-title">Note</p> +<p>This function will obtain the sequence of the protein from UNIPROT and calculate automatically its molecular mass</p> +</div> +</dd></dl> + +<dl class="py function"> +<dt class="sig sig-object py" id="Utils.PrintProgressBar"> +<span class="sig-prename descclassname"><span class="pre">Utils.</span></span><span class="sig-name descname"><span class="pre">PrintProgressBar</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">iteration</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">total</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prefix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">suffix</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">decimals</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">length</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fill</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'â–ˆ'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">printEnd</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'\r'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Utils.PrintProgressBar" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Call in a loop to create terminal progress bar</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>iteration:Required</strong> – current iteration (Int)</p></li> +<li><p><strong>total</strong> – Required: total iterations (Int)</p></li> +<li><p><strong>prefix</strong> – Optional: prefix string (Str)</p></li> +<li><p><strong>suffix</strong> – Optional: suffix string (Str)</p></li> +<li><p><strong>decimals</strong> – Optional: positive number of decimals in percent complete (Int)</p></li> +<li><p><strong>length</strong> – Optional: character length of bar (Int)</p></li> +<li><p><strong>fill</strong> – Optional: bar fill character (Str)</p></li> +<li><p><strong>printEnd</strong> – Optional: end character (Str)</p></li> +</ul> +</dd> +</dl> +</dd></dl> + +<dl class="py class"> +<dt class="sig sig-object py" id="Utils.tauRAMD"> +<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">Utils.</span></span><span class="sig-name descname"><span class="pre">tauRAMD</span></span><a class="headerlink" href="#Utils.tauRAMD" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Implementation of the tRAMD method by Kokh et al., 2018.</p> +<dl class="py method"> +<dt class="sig sig-object py" id="Utils.tauRAMD.PlotRTDistribuitons"> +<span class="sig-name descname"><span class="pre">PlotRTDistribuitons</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Utils.tauRAMD.PlotRTDistribuitons" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Plots the residence time distributions</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>save</strong> – Optional (kwarg boolean): default False</p></li> +<li><p><strong>filename</strong> – Optional (kwarg str)</p></li> +</ul> +</dd> +</dl> +</dd></dl> + <dl class="py method"> -<dt class="sig sig-object py" id="ssbtoolkit.simulation.inhibition.constants"> -<span class="sig-name descname"><span class="pre">constants</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#ssbtoolkit.simulation.inhibition.constants" title="Permalink to this definition">ïƒ</a></dt> -<dd><p>Returns the potency values.</p> +<dt class="sig sig-object py" id="Utils.tauRAMD.PlotRTStats"> +<span class="sig-name descname"><span class="pre">PlotRTStats</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">save</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Utils.tauRAMD.PlotRTStats" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Plots the residence time statistics</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>save</strong> – Optional (kwarg boolean): default False</p></li> +<li><p><strong>filename</strong> – Optional (kwarg str)</p></li> +</ul> +</dd> +</dl> </dd></dl> +<dl class="py method"> +<dt class="sig sig-object py" id="Utils.tauRAMD.Run"> +<span class="sig-name descname"><span class="pre">Run</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Utils.tauRAMD.Run" title="Permalink to this definition">ïƒ</a></dt> +<dd><p>Calulates the residence time of a ligand from RAMD simualtions.</p> +<dl class="field-list simple"> +<dt class="field-odd">Parameters</dt> +<dd class="field-odd"><ul class="simple"> +<li><p><strong>prefix</strong> – Required (kwarg str): directory path of .dat files</p></li> +<li><p><strong>dt</strong> – Optional (kwarg flt): MD simulations time step in ns (defaul is 2E-6)</p></li> +<li><p><strong>softwr</strong> – Optional (kwarg str): software used to perform RAMD simulations: NAMD, GROMACS (default)</p></li> +</ul> +</dd> +<dt class="field-even">Return (str)</dt> +<dd class="field-even"><p>residence time</p> +</dd> +</dl> </dd></dl> </dd></dl> diff --git a/docs/_build/html/faq.html b/docs/_build/html/faq.html index 45eff2f9af8b610123fcbf6ae748dae8f4e57bd0..33356e4cb4b7a11d013078c86d8a08abf8f72f64 100644 --- a/docs/_build/html/faq.html +++ b/docs/_build/html/faq.html @@ -4,7 +4,7 @@ <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title>Frequently Asked Questions — SSBtoolkit v1 documentation</title> + <title>Frequently Asked Questions — SSBtoolkit v1.0.1 documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <!--[if lt IE 9]> diff --git a/docs/_build/html/genindex.html b/docs/_build/html/genindex.html index dc0e12dda4e4725f10a617afcccc4c8832a89373..e3142a3c2f7d69458f732a5e7b9e4d1d59e5a24b 100644 --- a/docs/_build/html/genindex.html +++ b/docs/_build/html/genindex.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title>Index — SSBtoolkit v1 documentation</title> + <title>Index — SSBtoolkit v1.0.1 documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <!--[if lt IE 9]> @@ -73,22 +73,29 @@ <a href="#A"><strong>A</strong></a> | <a href="#B"><strong>B</strong></a> | <a href="#C"><strong>C</strong></a> + | <a href="#F"><strong>F</strong></a> | <a href="#G"><strong>G</strong></a> + | <a href="#I"><strong>I</strong></a> | <a href="#K"><strong>K</strong></a> | <a href="#M"><strong>M</strong></a> | <a href="#P"><strong>P</strong></a> | <a href="#R"><strong>R</strong></a> | <a href="#S"><strong>S</strong></a> + | <a href="#T"><strong>T</strong></a> | <a href="#U"><strong>U</strong></a> </div> <h2 id="A">A</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.Analysis">Analysis() (ssbtoolkit.simulation.activation method)</a> + <li><a href="apidocs.html#Simulation.Activation">Activation (class in Simulation)</a> +</li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="apidocs.html#Simulation.Activation.Analysis">Analysis() (Simulation.Activation method)</a> <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.Analysis">(ssbtoolkit.simulation.inhibition method)</a> + <li><a href="apidocs.html#Simulation.Inhibition.Analysis">(Simulation.Inhibition method)</a> </li> </ul></li> </ul></td> @@ -97,43 +104,48 @@ <h2 id="B">B</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.binding.bind">bind() (ssbtoolkit.binding method)</a> + <li><a href="apidocs.html#Binding.Bind">Bind() (in module Binding)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.binding">binding (class in ssbtoolkit)</a> + <li> + Binding + + <ul> + <li><a href="apidocs.html#module-Binding">module</a> </li> + </ul></li> </ul></td> </tr></table> <h2 id="C">C</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.constants">constants() (ssbtoolkit.simulation.inhibition method)</a> -</li> - <li><a href="apidocs.html#ssbtoolkit.convert">convert (class in ssbtoolkit)</a> + <li><a href="apidocs.html#Utils.CalcOccupancy">CalcOccupancy() (in module Utils)</a> </li> </ul></td> - <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.Curve">Curve() (ssbtoolkit.simulation.activation method)</a> +</tr></table> - <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.Curve">(ssbtoolkit.simulation.inhibition method)</a> +<h2 id="F">F</h2> +<table style="width: 100%" class="indextable genindextable"><tr> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="apidocs.html#Simulation.FitModel">FitModel (class in Simulation)</a> </li> - </ul></li> </ul></td> </tr></table> <h2 id="G">G</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.get">get (class in ssbtoolkit)</a> + <li><a href="apidocs.html#Utils.GetGProtein">GetGProtein() (in module Utils)</a> </li> </ul></td> +</tr></table> + +<h2 id="I">I</h2> +<table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.get.tauRAMD">get.tauRAMD (class in ssbtoolkit)</a> -</li> - <li><a href="apidocs.html#ssbtoolkit.get.gprotein">gprotein() (ssbtoolkit.get method)</a> + <li><a href="apidocs.html#Simulation.Inhibition">Inhibition (class in Simulation)</a> </li> </ul></td> </tr></table> @@ -141,7 +153,7 @@ <h2 id="K">K</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.convert.KineticTempScale">KineticTempScale() (ssbtoolkit.convert method)</a> + <li><a href="apidocs.html#Utils.KineticTempScale">KineticTempScale() (in module Utils)</a> </li> </ul></td> </tr></table> @@ -149,17 +161,17 @@ <h2 id="M">M</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.binding.maxbend">maxbend() (ssbtoolkit.binding method)</a> -</li> - <li><a href="apidocs.html#ssbtoolkit.convert.microgr2nanomolar">microgr2nanomolar() (ssbtoolkit.convert method)</a> + <li><a href="apidocs.html#Utils.MicrogramsToNanomolar">MicrogramsToNanomolar() (in module Utils)</a> </li> - </ul></td> - <td style="width: 33%; vertical-align: top;"><ul> <li> module <ul> - <li><a href="apidocs.html#module-ssbtoolkit">ssbtoolkit</a> + <li><a href="apidocs.html#module-Binding">Binding</a> +</li> + <li><a href="apidocs.html#module-Simulation">Simulation</a> +</li> + <li><a href="apidocs.html#module-Utils">Utils</a> </li> </ul></li> </ul></td> @@ -168,74 +180,70 @@ <h2 id="P">P</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.PathwayParameters">PathwayParameters() (ssbtoolkit.simulation.activation method)</a> + <li><a href="apidocs.html#Simulation.Activation.PathwayParameters">PathwayParameters() (Simulation.Activation method)</a> <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.fitModel.PathwayParameters">(ssbtoolkit.simulation.fitModel method)</a> + <li><a href="apidocs.html#Simulation.FitModel.PathwayParameters">(Simulation.FitModel method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.PathwayParameters">(ssbtoolkit.simulation.inhibition method)</a> + <li><a href="apidocs.html#Simulation.Inhibition.PathwayParameters">(Simulation.Inhibition method)</a> </li> </ul></li> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.PathwayParametersToCSV">PathwayParametersToCSV() (ssbtoolkit.simulation.activation method)</a> + <li><a href="apidocs.html#Simulation.Activation.PathwayParametersToCSV">PathwayParametersToCSV() (Simulation.Activation method)</a> <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.fitModel.PathwayParametersToCSV">(ssbtoolkit.simulation.fitModel method)</a> + <li><a href="apidocs.html#Simulation.FitModel.PathwayParametersToCSV">(Simulation.FitModel method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.PathwayParametersToCSV">(ssbtoolkit.simulation.inhibition method)</a> + <li><a href="apidocs.html#Simulation.Inhibition.PathwayParametersToCSV">(Simulation.Inhibition method)</a> </li> </ul></li> - <li><a href="apidocs.html#ssbtoolkit.simulation.fitModel.plotCurves">plotCurves() (ssbtoolkit.simulation.fitModel method)</a> -</li> - <li><a href="apidocs.html#ssbtoolkit.simulation.fitModel.plotIterations">plotIterations() (ssbtoolkit.simulation.fitModel method)</a> + <li><a href="apidocs.html#Simulation.pathways_path">pathways_path (in module Simulation)</a> </li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.get.tauRAMD.plotRTdistribuitons">plotRTdistribuitons() (ssbtoolkit.get.tauRAMD method)</a> + <li><a href="apidocs.html#Simulation.FitModel.PlotIterations">PlotIterations() (Simulation.FitModel method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.get.tauRAMD.plotRTstats">plotRTstats() (ssbtoolkit.get.tauRAMD method)</a> + <li><a href="apidocs.html#Utils.tauRAMD.PlotRTDistribuitons">PlotRTDistribuitons() (Utils.tauRAMD method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.Potency">Potency() (ssbtoolkit.simulation.activation method)</a> - - <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.Potency">(ssbtoolkit.simulation.inhibition method)</a> + <li><a href="apidocs.html#Utils.tauRAMD.PlotRTStats">PlotRTStats() (Utils.tauRAMD method)</a> </li> - </ul></li> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.PotencyToCSV">PotencyToCSV() (ssbtoolkit.simulation.activation method)</a> + <li><a href="apidocs.html#Simulation.Activation.PotencyToCSV">PotencyToCSV() (Simulation.Activation method)</a> <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.PotencyToCSV">(ssbtoolkit.simulation.inhibition method)</a> + <li><a href="apidocs.html#Simulation.Inhibition.PotencyToCSV">(Simulation.Inhibition method)</a> </li> </ul></li> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.PotencyToDict">PotencyToDict() (ssbtoolkit.simulation.activation method)</a> + <li><a href="apidocs.html#Simulation.Activation.PotencyToDict">PotencyToDict() (Simulation.Activation method)</a> <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.PotencyToDict">(ssbtoolkit.simulation.inhibition method)</a> + <li><a href="apidocs.html#Simulation.Inhibition.PotencyToDict">(Simulation.Inhibition method)</a> </li> </ul></li> + <li><a href="apidocs.html#Utils.PrintProgressBar">PrintProgressBar() (in module Utils)</a> +</li> </ul></td> </tr></table> <h2 id="R">R</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.Reactions">Reactions() (ssbtoolkit.simulation.activation method)</a> + <li><a href="apidocs.html#Simulation.Activation.Reactions">Reactions() (Simulation.Activation method)</a> <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.fitModel.Reactions">(ssbtoolkit.simulation.fitModel method)</a> + <li><a href="apidocs.html#Simulation.FitModel.Reactions">(Simulation.FitModel method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.Reactions">(ssbtoolkit.simulation.inhibition method)</a> + <li><a href="apidocs.html#Simulation.Inhibition.Reactions">(Simulation.Inhibition method)</a> </li> </ul></li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.get.tauRAMD.Run">Run() (ssbtoolkit.get.tauRAMD method)</a> + <li><a href="apidocs.html#Simulation.Activation.Run">Run() (Simulation.Activation method)</a> <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.Run">(ssbtoolkit.simulation.activation method)</a> + <li><a href="apidocs.html#Simulation.FitModel.Run">(Simulation.FitModel method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation.fitModel.Run">(ssbtoolkit.simulation.fitModel method)</a> + <li><a href="apidocs.html#Simulation.Inhibition.Run">(Simulation.Inhibition method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.Run">(ssbtoolkit.simulation.inhibition method)</a> + <li><a href="apidocs.html#Utils.tauRAMD.Run">(Utils.tauRAMD method)</a> </li> </ul></li> </ul></td> @@ -244,45 +252,70 @@ <h2 id="S">S</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.SetSimulationParameters">SetSimulationParameters() (ssbtoolkit.simulation.activation method)</a> + <li><a href="apidocs.html#Simulation.Activation.SetSimulationParameters">SetSimulationParameters() (Simulation.Activation method)</a> <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.fitModel.SetSimulationParameters">(ssbtoolkit.simulation.fitModel method)</a> + <li><a href="apidocs.html#Simulation.FitModel.SetSimulationParameters">(Simulation.FitModel method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.SetSimulationParameters">(ssbtoolkit.simulation.inhibition method)</a> + <li><a href="apidocs.html#Simulation.Inhibition.SetSimulationParameters">(Simulation.Inhibition method)</a> </li> </ul></li> - <li><a href="apidocs.html#ssbtoolkit.binding.show_curve">show_curve() (ssbtoolkit.binding method)</a> + <li><a href="apidocs.html#Binding.ShowCurve">ShowCurve() (in module Binding)</a> + + <ul> + <li><a href="apidocs.html#Simulation.Activation.ShowCurve">(Simulation.Activation method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation">simulation (class in ssbtoolkit)</a> + <li><a href="apidocs.html#Simulation.Inhibition.ShowCurve">(Simulation.Inhibition method)</a> </li> + </ul></li> </ul></td> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation">simulation.activation (class in ssbtoolkit)</a> + <li><a href="apidocs.html#Simulation.FitModel.ShowGraphs">ShowGraphs() (Simulation.FitModel method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation.fitModel">simulation.fitModel (class in ssbtoolkit)</a> -</li> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition">simulation.inhibition (class in ssbtoolkit)</a> + <li><a href="apidocs.html#Simulation.Activation.ShowPotency">ShowPotency() (Simulation.Activation method)</a> + + <ul> + <li><a href="apidocs.html#Simulation.Inhibition.ShowPotency">(Simulation.Inhibition method)</a> </li> + </ul></li> <li> - ssbtoolkit + Simulation <ul> - <li><a href="apidocs.html#module-ssbtoolkit">module</a> + <li><a href="apidocs.html#module-Simulation">module</a> </li> </ul></li> + <li><a href="apidocs.html#Binding.SubMaxConcentration">SubMaxConcentration() (in module Binding)</a> +</li> + </ul></td> +</tr></table> + +<h2 id="T">T</h2> +<table style="width: 100%" class="indextable genindextable"><tr> + <td style="width: 33%; vertical-align: top;"><ul> + <li><a href="apidocs.html#Utils.tauRAMD">tauRAMD (class in Utils)</a> +</li> </ul></td> </tr></table> <h2 id="U">U</h2> <table style="width: 100%" class="indextable genindextable"><tr> <td style="width: 33%; vertical-align: top;"><ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.activation.UserPathwayParameters">UserPathwayParameters() (ssbtoolkit.simulation.activation method)</a> + <li><a href="apidocs.html#Simulation.Activation.UserPathwayParameters">UserPathwayParameters() (Simulation.Activation method)</a> <ul> - <li><a href="apidocs.html#ssbtoolkit.simulation.fitModel.UserPathwayParameters">(ssbtoolkit.simulation.fitModel method)</a> + <li><a href="apidocs.html#Simulation.FitModel.UserPathwayParameters">(Simulation.FitModel method)</a> +</li> + <li><a href="apidocs.html#Simulation.Inhibition.UserPathwayParameters">(Simulation.Inhibition method)</a> </li> - <li><a href="apidocs.html#ssbtoolkit.simulation.inhibition.UserPathwayParameters">(ssbtoolkit.simulation.inhibition method)</a> + </ul></li> + </ul></td> + <td style="width: 33%; vertical-align: top;"><ul> + <li> + Utils + + <ul> + <li><a href="apidocs.html#module-Utils">module</a> </li> </ul></li> </ul></td> diff --git a/docs/_build/html/index.html b/docs/_build/html/index.html index 1f903ed555184c7a5b4c22956a29bacf2b574b03..fc6512e9967866b24e8c31d00d9b98e944d29478 100644 --- a/docs/_build/html/index.html +++ b/docs/_build/html/index.html @@ -4,7 +4,7 @@ <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title>Welcome to SSBtoolkit’s documentation! — SSBtoolkit v1 documentation</title> + <title>Welcome to SSBtoolkit’s documentation! — SSBtoolkit v1.0.1 documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <!--[if lt IE 9]> @@ -102,6 +102,40 @@ protocols.</p> </li> </ul> </div> +<p></p> +<p></p> +</section> +<section id="availability-and-license"> +<h1>Availability and License<a class="headerlink" href="#availability-and-license" title="Permalink to this headline">ïƒ</a></h1> +<p>The source code is freely available at <a class="reference external" href="https://github.com/rribeiro-sci/SSBtoolkit">https://github.com/rribeiro-sci/SSBtoolkit</a> under +the Apache 2.0 license. Tutorial notebooks containing minimal working examples can be found at <a class="reference external" href="https://github.com/rribeiro-sci/SSBtoolkit">https://github.com/rribeiro-sci/SSBtoolkit</a>.</p> +<p></p> +<p></p> +</section> +<section id="developed-by"> +<h1>Developed by<a class="headerlink" href="#developed-by" title="Permalink to this headline">ïƒ</a></h1> +<a class="reference internal image-reference" href="https://res.cloudinary.com/djz27k5hg/image/upload/v1637333672/logos/Juelich_logo_100px_ecv2hy.png"><img alt="https://res.cloudinary.com/djz27k5hg/image/upload/v1637333672/logos/Juelich_logo_100px_ecv2hy.png" src="https://res.cloudinary.com/djz27k5hg/image/upload/v1637333672/logos/Juelich_logo_100px_ecv2hy.png" style="width: 200px;" /></a> +<p></p> +<p></p> +</section> +<section id="funded-by"> +<h1>Funded by<a class="headerlink" href="#funded-by" title="Permalink to this headline">ïƒ</a></h1> +<a class="reference internal image-reference" href="https://res.cloudinary.com/djz27k5hg/image/upload/v1637657234/logos/HBP_horizontal_logo_qtcyzn.png"><img alt="Alternative text" src="https://res.cloudinary.com/djz27k5hg/image/upload/v1637657234/logos/HBP_horizontal_logo_qtcyzn.png" style="width: 200px;" /></a> +</section> +<section id="citation-doi-for-citing-ssbtoolkit"> +<h1>Citation <a class="reference external" href="https://github.com/rribeiro-sci/SSBtoolkit"><img alt="DOI for Citing ssbtoolkit" src="https://img.shields.io/badge/DOI-10.1016%2Fj.bpj.2015.08.015-blue.svg" /></a><a class="headerlink" href="#citation-doi-for-citing-ssbtoolkit" title="Permalink to this headline">ïƒ</a></h1> +<p>pyGOMoDo is research software. If you make use of pyGOMoDo in scientific +publications, please cite it. The BibTeX reference is</p> +<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@article</span><span class="p">{</span><span class="n">ribeiro_ssb_2022</span><span class="p">,</span> + <span class="n">title</span><span class="o">=</span><span class="p">{{</span><span class="n">SSB</span><span class="p">}</span> <span class="n">toolkit</span><span class="p">:</span> <span class="kn">from</span> <span class="nn">molecular</span> <span class="n">structure</span> <span class="n">to</span> <span class="n">subcellular</span> <span class="n">signaling</span> <span class="n">pathways</span><span class="o">.</span><span class="p">},</span> + <span class="n">author</span><span class="o">=</span><span class="p">{</span><span class="n">Ribeiro</span><span class="p">,</span> <span class="n">Rui</span> <span class="n">Pedro</span> <span class="ow">and</span> <span class="n">Gossen</span><span class="p">,</span> <span class="n">Jonas</span> <span class="ow">and</span> <span class="n">Rossetti</span><span class="p">,</span> <span class="n">Giulia</span> <span class="ow">and</span> <span class="n">Giorgetti</span><span class="p">,</span> <span class="n">Alejandro</span><span class="p">},</span> + <span class="n">publisher</span><span class="o">=</span><span class="p">{</span><span class="n">bioRxiv</span><span class="p">},</span> + <span class="n">url</span><span class="o">=</span><span class="p">{</span><span class="n">https</span><span class="p">:</span><span class="o">//</span><span class="n">www</span><span class="o">.</span><span class="n">biorxiv</span><span class="o">.</span><span class="n">org</span><span class="o">/</span><span class="n">content</span><span class="o">/</span><span class="mf">10.1101</span><span class="o">/</span><span class="mf">2022.11.08.515595</span><span class="n">v1</span><span class="p">},</span> + <span class="n">doi</span><span class="o">=</span><span class="p">{</span><span class="mf">10.1101</span><span class="o">/</span><span class="mf">2022.11.08.515595</span><span class="p">},</span> + <span class="n">year</span><span class="o">=</span><span class="p">{</span><span class="mi">2022</span><span class="p">}</span> +<span class="p">}</span> +</pre></div> +</div> </section> <section id="indices-and-tables"> <h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline">ïƒ</a></h1> diff --git a/docs/_build/html/introduction.html b/docs/_build/html/introduction.html index b11de8e8c2a933606d0f0c8cfe406cadc76a3f5f..64f5e97b4859229190ac7d6d562e2e63923012c2 100644 --- a/docs/_build/html/introduction.html +++ b/docs/_build/html/introduction.html @@ -4,7 +4,7 @@ <meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title>Introduction to Structure Systems Biology — SSBtoolkit v1 documentation</title> + <title>Introduction to Structure Systems Biology — SSBtoolkit v1.0.1 documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <!--[if lt IE 9]> diff --git a/docs/_build/html/objects.inv b/docs/_build/html/objects.inv index 0c21759fdd3c5c2c947181620ffc433818551dc0..a3b541ea75cebc5e5b3e2462f8982f9693db5817 100644 Binary files a/docs/_build/html/objects.inv and b/docs/_build/html/objects.inv differ diff --git a/docs/_build/html/py-modindex.html b/docs/_build/html/py-modindex.html index 782ba597fb1f69fdb647ab84fe6f96ae1470028d..2b5427b9ba12bf68917bb296e6d086a6421054b3 100644 --- a/docs/_build/html/py-modindex.html +++ b/docs/_build/html/py-modindex.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title>Python Module Index — SSBtoolkit v1 documentation</title> + <title>Python Module Index — SSBtoolkit v1.0.1 documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <!--[if lt IE 9]> @@ -77,17 +77,35 @@ <h1>Python Module Index</h1> <div class="modindex-jumpbox"> - <a href="#cap-s"><strong>s</strong></a> + <a href="#cap-b"><strong>b</strong></a> | + <a href="#cap-s"><strong>s</strong></a> | + <a href="#cap-u"><strong>u</strong></a> </div> <table class="indextable modindextable"> <tr class="pcap"><td></td><td> </td><td></td></tr> + <tr class="cap" id="cap-b"><td></td><td> + <strong>b</strong></td><td></td></tr> + <tr> + <td></td> + <td> + <a href="apidocs.html#module-Binding"><code class="xref">Binding</code></a></td><td> + <em></em></td></tr> + <tr class="pcap"><td></td><td> </td><td></td></tr> <tr class="cap" id="cap-s"><td></td><td> <strong>s</strong></td><td></td></tr> <tr> <td></td> <td> - <a href="apidocs.html#module-ssbtoolkit"><code class="xref">ssbtoolkit</code></a></td><td> + <a href="apidocs.html#module-Simulation"><code class="xref">Simulation</code></a></td><td> + <em></em></td></tr> + <tr class="pcap"><td></td><td> </td><td></td></tr> + <tr class="cap" id="cap-u"><td></td><td> + <strong>u</strong></td><td></td></tr> + <tr> + <td></td> + <td> + <a href="apidocs.html#module-Utils"><code class="xref">Utils</code></a></td><td> <em></em></td></tr> </table> diff --git a/docs/_build/html/search.html b/docs/_build/html/search.html index 311d523a65ba0b2cc6fc69f8e18462ea9826fcee..29084b609027c6335c6bf56c869141a047c44e4b 100644 --- a/docs/_build/html/search.html +++ b/docs/_build/html/search.html @@ -3,7 +3,7 @@ <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <title>Search — SSBtoolkit v1 documentation</title> + <title>Search — SSBtoolkit v1.0.1 documentation</title> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> diff --git a/docs/_build/html/searchindex.js b/docs/_build/html/searchindex.js index 95ef7fdd0dd657dedc9053e4c08ee58d0ae2775b..32767895958dc42663711f1e8f5d8e938ea9fe6e 100644 --- a/docs/_build/html/searchindex.js +++ b/docs/_build/html/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["about","apidocs","faq","index","introduction"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,sphinx:56},filenames:["about.rst","apidocs.rst","faq.rst","index.rst","introduction.rst"],objects:{"":[[1,0,0,"-","ssbtoolkit"]],"ssbtoolkit.binding":[[1,2,1,"","bind"],[1,2,1,"","maxbend"],[1,2,1,"","show_curve"]],"ssbtoolkit.convert":[[1,2,1,"","KineticTempScale"],[1,2,1,"","microgr2nanomolar"]],"ssbtoolkit.get":[[1,2,1,"","gprotein"],[1,1,1,"","tauRAMD"]],"ssbtoolkit.get.tauRAMD":[[1,2,1,"","Run"],[1,2,1,"","plotRTdistribuitons"],[1,2,1,"","plotRTstats"]],"ssbtoolkit.simulation":[[1,1,1,"","activation"],[1,1,1,"","fitModel"],[1,1,1,"","inhibition"]],"ssbtoolkit.simulation.activation":[[1,2,1,"","Analysis"],[1,2,1,"","Curve"],[1,2,1,"","PathwayParameters"],[1,2,1,"","PathwayParametersToCSV"],[1,2,1,"","Potency"],[1,2,1,"","PotencyToCSV"],[1,2,1,"","PotencyToDict"],[1,2,1,"","Reactions"],[1,2,1,"","Run"],[1,2,1,"","SetSimulationParameters"],[1,2,1,"","UserPathwayParameters"]],"ssbtoolkit.simulation.fitModel":[[1,2,1,"","PathwayParameters"],[1,2,1,"","PathwayParametersToCSV"],[1,2,1,"","Reactions"],[1,2,1,"","Run"],[1,2,1,"","SetSimulationParameters"],[1,2,1,"","UserPathwayParameters"],[1,2,1,"","plotCurves"],[1,2,1,"","plotIterations"]],"ssbtoolkit.simulation.inhibition":[[1,2,1,"","Analysis"],[1,2,1,"","Curve"],[1,2,1,"","PathwayParameters"],[1,2,1,"","PathwayParametersToCSV"],[1,2,1,"","Potency"],[1,2,1,"","PotencyToCSV"],[1,2,1,"","PotencyToDict"],[1,2,1,"","Reactions"],[1,2,1,"","Run"],[1,2,1,"","SetSimulationParameters"],[1,2,1,"","UserPathwayParameters"],[1,2,1,"","constants"]],ssbtoolkit:[[1,1,1,"","binding"],[1,1,1,"","convert"],[1,1,1,"","get"],[1,1,1,"","simulation"]]},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method"},terms:{"0":0,"1":0,"100":0,"11":0,"12":0,"13":0,"1978":0,"1999":4,"2":0,"20":0,"2002":0,"2003":[0,1],"2007":[0,4],"2009":[0,4],"2010":4,"2011":0,"2012":0,"2013":[0,4],"2014":4,"2015":[0,4],"2016":4,"2017":4,"2018":[1,4],"2019":[0,4],"2020":[0,4],"2e":1,"3":0,"3rd":0,"4":[0,1],"5":0,"50":0,"5th":0,"6":[0,1],"7":0,"80":0,"\u03b1":0,"boolean":1,"class":[0,1,3],"default":[0,1,2],"export":1,"final":[0,1],"function":[0,1,4],"import":[1,4],"int":1,"new":4,"return":1,"short":4,"while":[0,4],A:[0,3,4],And:4,As:[0,4],By:0,For:[0,4],If:[0,2],In:[0,4],It:1,No:2,Such:[0,4],That:0,The:[0,1,3,4],Then:0,To:0,about:4,abov:0,absenc:0,access:0,accord:[0,1],accur:4,accuraci:0,achiev:0,across:4,act:0,action:[0,4],activ:[0,1,4],actual:4,ad:0,adapt:0,adjac:0,advoc:4,affect:4,affin:[1,3,4],after:0,against:0,agonist:[0,1],agonist_affin:1,agonist_submaximal_conc:1,al:[0,1,4],all:[0,1,4],allow:[0,4],alreadi:4,also:[0,4],altern:4,although:0,alv:4,am:2,amount:[0,1],amplitud:1,an:[0,1,3,4],analysi:[0,1,3],androulaki:4,ani:[0,3],anoth:4,antagonist:[0,1],antagonists_affin:1,antagonists_conc_rang:1,api:3,appli:[0,1,4],approach:[0,4],ar:[0,3,4],area:1,arithmet:0,arrai:[0,1],ask:3,assai:0,assess:0,assist:4,associ:[0,1,4],assum:[0,4],assumpt:[0,4],automat:1,avail:[0,4],b:0,basal:0,base:[0,4],baselin:0,becaus:[0,4],becom:[0,4],been:[0,4],being:[0,3,4],bend:[0,1],better:4,between:[0,4],bind:[1,2,3,4],binding_kinet:[1,2],biochem:[0,4],bioinformat:[0,3],biolog:[0,4],biologi:[0,3],biomed:4,biomodel:4,biopython:0,birch:4,bound:0,bridg:4,bring:[0,3,4],bruce:4,built:[0,3],c:[0,1],calcul:[0,1,2,4],call:0,calul:1,camp:0,campaign:0,can:[0,4],capelli:4,carefulli:1,cascad:4,cat:4,catalysi:4,catalyz:[0,4],cell:[0,4],cellular:[0,4],celsiu:1,central:4,certain:0,chang:[0,2,4],character:[0,4],chemic:0,choic:[0,3],chose:0,chosen:0,claim:4,clark:4,classic:[0,3],classif:0,classifi:0,close:0,code:[0,3],colab:1,come:0,commonli:[0,4],commun:[0,3],compar:0,comparison:[0,4],compet:0,competit:0,complementari:0,complex:[0,4],comput:[0,3],computation:[0,4],concentr:[0,1,4],concept:[0,4],conceptu:0,concurr:4,condit:[0,4],conform:0,consid:[0,2],consist:4,constant:[0,1,4],constitut:[0,4],contain:0,contribut:4,convert:1,convolut:4,core:0,correspond:0,corrrespond:0,coupl:0,critic:4,csv:1,curv:[0,1],d:0,d_:0,dat:1,data:[0,1,4],databas:[0,1,4],datafram:1,de:4,deal:0,decad:4,decemb:0,decreas:0,decrement:1,decrementor:1,deduc:0,deep:4,defaul:1,defin:0,definit:0,delean:0,dell:4,demonstr:0,depend:[0,4],deploy:0,deriv:[0,4],describ:[0,4],descript:0,design:0,despit:4,detail:0,determin:4,develop:[0,1,3,4],deward:4,dict:1,dictionari:1,didn:0,differ:[0,4],differenti:[0,4],dilut:0,dimens:4,dimension:4,directli:2,directori:1,disciplin:4,discoveri:4,discret:0,diseas:4,displac:0,displai:1,dissoci:[0,4],distribut:[1,4],divid:0,doe:2,doen:1,doesn:[0,3],dopaminerg:4,dose:[0,1],downstream:4,drug:[3,4],drug_receptor:1,drugreceptor:4,dt:1,due:0,duran:4,dure:0,dynam:4,e:[0,1],each:[0,1,4],easi:0,easier:0,easili:[0,3,4],ec_:0,ed:0,effect:[0,1,4],effector:0,efficaci:0,either:0,element:4,encod:4,end:0,endogen:0,enough:4,environ:[0,3],enzym:4,epiderm:4,eq:0,equal:0,equat:[0,4],equilibrium:[0,1,4],error:4,essenti:0,estim:[0,4],et:[0,1,4],evalu:4,even:4,event:[0,4],exist:[0,4],experi:0,experiment:[0,1,4],expert:[0,3],explicit:4,explor:[0,3],expratio:1,express:0,extens:[0,3],extract:1,fact:[0,4],factor:[0,4],fals:[1,2],famili:0,fast:4,feed:4,field:4,fig:0,figur:0,file:[0,1],filenam:1,find:0,first:[0,3,4],fit:[0,1],fitmodel:1,fix:0,flt:1,focu:4,follow:0,format:1,found:4,four:0,foward:1,fraction:[0,1],framework:4,free:[0,3],frequent:3,friendli:[0,3],frigola:4,from:[0,1,4],full:1,fundament:4,g:[0,1,4],g_:0,gener:[3,4],geometr:0,get:1,gi:1,give:0,given:[0,3],glont:4,goe:0,golan:0,googl:1,govern:4,gpcr:[0,1,3],gpcrdb:0,gprotein:1,gq:[0,1],grant:0,grcr:0,green:0,gromac:1,grow:4,growth:4,gs:1,ha:[0,4],half:1,halfwai:0,hallucinogen:4,hamper:4,have:[0,4],help:0,helper:1,henc:0,high:4,higher:0,hormon:0,how:[0,4],howev:[0,4],human:[0,1],hyperbol:0,i:[0,1,2],ic_:0,idea:4,ideal:4,identif:4,impact:0,implement:[0,1],impli:0,includ:[0,4],incomplet:4,incorpor:0,increas:0,increment:1,incrementor:1,index:3,indic:4,individu:0,infer:0,inform:[0,1,3,4],inhibit:[0,1],initi:[0,1,4],input:[0,3],insid:4,instanc:[0,1,3,4],instead:[0,3],integr:[0,4],intens:4,interact:[0,3,4],intern:1,internet:4,interplai:4,intric:[0,4],introduct:3,invergo:4,ip_3:0,iter:1,its:[0,1,4],j:[0,4],jupyt:[0,3],just:[0,1,3],k:1,k_:[0,4],k_d:0,k_m:4,kd:[0,2],kelvin:1,kholodenko:4,kinas:[0,4],kinet:[1,4],kinetictempscal:1,known:0,koff:1,kokh:1,kon:1,krzyzanski:4,kwarg:1,l2:0,l:0,l_init:2,label:0,lack:4,last:0,latter:0,law:0,learn:[0,4],less:0,librari:[0,1],lig_conc_rang:1,ligand:[0,1,2,3,4],light:4,like:[0,4],line:0,linear:0,list:1,literatur:[0,4],liu:4,logarithm:0,logist:0,lowest:0,lr:[0,2],m:0,machin:4,macromolecular:4,made:0,magnitud:0,mai:[0,4],mainli:0,make:[0,3,4],malik:4,mani:[0,4],mass:[0,1],mathemat:[0,1,4],mathod:1,matplotlib:0,matter:[0,4],max:4,maxbend:1,maxim:0,maximum:[0,1],maxit:1,mccrai:0,md:[1,4],me:1,mead:1,mean:4,measur:[0,1,4],mechan:4,mediat:4,medicin:4,messeng:0,metabol:0,metabolit:0,metadynam:4,method:[0,1,3,4],microgr2nanomolar:1,microgram:1,might:0,mimic:0,minim:1,minimum:0,miss:4,model:[0,1,3,4],modifi:[0,1],modul:[0,3],modular:0,molar:0,molecular:[0,1,4],more:[0,4],moreov:0,most:4,must:[0,1],myriad:0,n:4,nair:[0,4],namd:1,name:1,nanomolar:1,natur:0,need:[0,4],nelder:1,network:4,neubig:0,neural:4,neurotransmitt:0,neve:0,next:4,nm:1,non:[0,3],none:1,normal:[0,4],notebook:[0,3],novel:[0,3],nowadai:[0,3],ns:1,nstep:1,number:[1,4],numer:[0,4],numpi:0,nune:4,o:0,obeserv:1,observ:[0,1],obtain:[0,1,2],occup:[0,4],occupi:0,occupit:1,occur:[0,4],od:[1,4],off:4,one:[0,4],onli:[0,4],open:[0,3],option:1,orco:4,order:[0,1,4],ordinari:4,other:[0,2,4],out:0,over:[0,4],overcom:4,oxtr:1,page:3,panda:[0,1],paradigm:4,paramet:[0,1,2,4],paramt:1,part:[0,4],past:4,path:1,pathai:1,pathophysiolog:4,pathwai:[1,2,3,4],pathway_paramet:1,pathwayparamet:1,pathwayparameterstocsv:1,patrick:0,percentag:0,perform:[0,1],person:4,pfleger:0,pharmacodynam:[0,3],pharmacolog:4,phosphoryl:[0,4],phototransduct:4,physic:4,pipelin:[0,3,4],pkd:1,plai:[0,4],plateau:0,pleas:1,plot:[0,1],plotcurv:1,plotiter:1,plotrtdistribuiton:1,plotrtstat:1,point:[0,1],portion:0,possibl:0,potenc:[0,1],potencytocsv:1,potencytodict:1,potent:0,power:[0,4],pre:0,predict:[0,3,4],prefer:[0,3],prefix:1,presenc:0,present:0,previou:0,process:4,processed_data:1,produc:0,progress:0,promis:4,prone:4,proof:4,proport:[0,2],propos:[0,4],protein:[0,1,4],protocol:[0,3],provid:4,pujol:4,pysb:0,python:0,q:0,qgrid:1,quantif:4,quantit:[0,4],quantiti:4,queri:1,question:3,r:0,r_:0,radioact:0,radioligand:0,ragoza:4,ramd:1,ramdom:1,rang:[0,1],ratio:1,raw:1,reach:0,reaction:[0,1,2,4],reactom:0,readabl:0,reason:[0,4],recent:4,receptor:[1,2,3,4],receptor_conc:1,red:0,reduc:0,refer:0,regress:0,rel:4,relat:4,relationship:[0,4],relev:4,reli:4,render:0,rendit:4,replic:[0,3],repositori:4,repres:0,reproduc:1,repsons:0,requir:1,rerun:[0,3],rescal:1,research:4,resid:1,resolut:4,resolv:0,respect:0,respons:[0,1,4],result:[0,2,4],retriv:1,reusabl:0,revers:1,reward:4,rhodopsin:4,right:0,rise:4,role:4,rule:[0,2],run:1,s:0,sai:0,same:[0,1,2,4],satur:0,save:1,scale:[1,4],scenario:0,scheme:0,scientif:[0,3],scikit:0,scipi:0,screen:0,search:3,sebaugh:[0,1],second:[0,1,4],see:[0,1],seed:1,seed_decrementor:1,seed_incrementor:1,select:0,semi:0,sens:4,sequenc:1,seri:[0,4],serotonin:4,serv:0,set:4,setsimulationparamet:1,setup:1,sever:0,shape:[0,1],share:[0,3],sheriff:4,shift:0,should:[0,4],show_curv:1,sigmoid:[0,1],signal:[1,3,4],signaltransduct:0,similar:4,simualt:1,simul:[1,2,3,4],sinc:[0,4],site:0,slope:0,so:[0,2,4],softwar:1,softwr:1,solv:4,sourc:[0,3],space:0,spare:0,spatial:4,speci:[0,1,4],special:4,specif:[0,1,4],ssb:[0,3],ssbtoolkit:1,start:0,state:4,statement:0,statist:1,steadi:4,steep:0,stein:[0,4],step:[1,4],still:4,store:4,str:1,straight:0,strength:4,strong:0,stronger:0,structur:[0,3],studi:[0,4],subcellular:4,subfamili:0,submax_concentr:1,submaxim:[0,1],subsequ:4,subunit:0,sue:2,suitabl:0,system:[0,3],systemat:0,t1:1,t2:1,t:[0,1,3],tabl:1,taken:[0,4],target:[0,1,4],target_paramet:1,tauramd:1,temperatur:1,tempor:4,term:0,than:0,thank:4,thei:4,them:[0,3,4],theori:[0,4],therebi:4,therefor:[0,4],thesi:0,thi:[0,1,4],think:4,those:4,though:0,three:[0,4],through:0,time:[0,1,4],tissu:0,todai:4,togeth:[0,3],tool:[0,1,3],toolkit:[0,3],total:0,toward:4,tramd:1,transduct:4,transfer:4,tremend:4,truth:4,ttotal:1,tu:1,tumor:4,tutori:1,typic:[0,4],umbrella:0,unbound:0,under:[0,1,4],underneath:4,understand:4,undoubtedli:4,uniprot:1,uniprotid:1,uniqu:0,unit:1,unk:0,unknown:0,unlabel:0,unpreced:4,unquestion:4,untest:[0,3],up:[0,4],upper:0,us:[0,1,2,3,4],user:[0,1,3],userpathwayparamet:1,v_:4,valid:0,valu:[0,1,2,4],variabl:4,variat:0,varieti:4,vein:0,version:0,versu:0,virtual:0,vivo:4,wa:[0,1,3],wai:[0,4],wang:4,wash:0,we:0,well:0,were:0,what:3,when:[0,2],where:[0,4],wherea:0,which:0,whole:4,why:[0,2],wide:0,width:1,without:0,word:[0,4],work:1,x:0,xie:4,y:0,year:4,zero:0},titles:["What is the SSBtoolkit?","API Documentation","Frequently Asked Questions","Welcome to SSBtoolkit\u2019s documentation!","Introduction to Structure Systems Biology"],titleterms:{affin:0,api:1,ask:2,bind:0,biologi:4,content:3,document:[1,3],drug:0,frequent:2,gener:2,indic:3,introduct:4,pathwai:0,question:2,receptor:0,s:3,signal:0,simul:0,ssbtoolkit:[0,3],structur:4,system:4,tabl:3,welcom:3,what:0}}) \ No newline at end of file +Search.setIndex({docnames:["about","apidocs","faq","index","introduction"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":4,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":3,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,sphinx:56},filenames:["about.rst","apidocs.rst","faq.rst","index.rst","introduction.rst"],objects:{"":[[1,0,0,"-","Binding"],[1,0,0,"-","Simulation"],[1,0,0,"-","Utils"]],"Simulation.Activation":[[1,3,1,"","Analysis"],[1,3,1,"","PathwayParameters"],[1,3,1,"","PathwayParametersToCSV"],[1,3,1,"","PotencyToCSV"],[1,3,1,"","PotencyToDict"],[1,3,1,"","Reactions"],[1,3,1,"","Run"],[1,3,1,"","SetSimulationParameters"],[1,3,1,"","ShowCurve"],[1,3,1,"","ShowPotency"],[1,3,1,"","UserPathwayParameters"]],"Simulation.FitModel":[[1,3,1,"","PathwayParameters"],[1,3,1,"","PathwayParametersToCSV"],[1,3,1,"","PlotIterations"],[1,3,1,"","Reactions"],[1,3,1,"","Run"],[1,3,1,"","SetSimulationParameters"],[1,3,1,"","ShowGraphs"],[1,3,1,"","UserPathwayParameters"]],"Simulation.Inhibition":[[1,3,1,"","Analysis"],[1,3,1,"","PathwayParameters"],[1,3,1,"","PathwayParametersToCSV"],[1,3,1,"","PotencyToCSV"],[1,3,1,"","PotencyToDict"],[1,3,1,"","Reactions"],[1,3,1,"","Run"],[1,3,1,"","SetSimulationParameters"],[1,3,1,"","ShowCurve"],[1,3,1,"","ShowPotency"],[1,3,1,"","UserPathwayParameters"]],"Utils.tauRAMD":[[1,3,1,"","PlotRTDistribuitons"],[1,3,1,"","PlotRTStats"],[1,3,1,"","Run"]],Binding:[[1,1,1,"","Bind"],[1,1,1,"","ShowCurve"],[1,1,1,"","SubMaxConcentration"]],Simulation:[[1,2,1,"","Activation"],[1,2,1,"","FitModel"],[1,2,1,"","Inhibition"],[1,4,1,"","pathways_path"]],Utils:[[1,1,1,"","CalcOccupancy"],[1,1,1,"","GetGProtein"],[1,1,1,"","KineticTempScale"],[1,1,1,"","MicrogramsToNanomolar"],[1,1,1,"","PrintProgressBar"],[1,2,1,"","tauRAMD"]]},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"],"4":["py","data","Python data"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method","4":"py:data"},terms:{"0":[0,1,3],"08":3,"1":[0,1],"10":3,"100":[0,1],"11":[0,3],"1101":3,"12":0,"13":0,"1978":0,"1999":4,"2":[0,3],"20":0,"2002":0,"2003":[0,1],"2007":[0,4],"2009":[0,4],"2010":4,"2011":0,"2012":0,"2013":[0,4],"2014":4,"2015":[0,4],"2016":4,"2017":4,"2018":[1,4],"2019":[0,4],"2020":[0,4],"2022":3,"2e":1,"3":0,"3rd":0,"4":[0,1],"5":0,"50":0,"515595":3,"515595v1":3,"5th":0,"6":[0,1],"7":0,"80":0,"\u03b1":0,"boolean":1,"class":[0,1,3],"default":[0,1,2],"export":1,"final":[0,1],"function":[0,1,4],"import":[1,4],"int":1,"new":4,"public":3,"return":1,"short":4,"while":[0,4],A:[0,3,4],And:4,As:[0,4],By:0,For:[0,4],If:[0,2,3],In:[0,4],It:1,No:2,Such:[0,4],That:0,The:[0,1,3,4],Then:0,To:0,__init__:[],about:4,abov:0,absenc:0,access:0,accord:[0,1],accur:4,accuraci:0,achiev:0,across:4,act:0,action:[0,4],activ:[0,1,4],actual:4,ad:0,adapt:0,adjac:0,advoc:4,affect:4,affin:[1,3,4],after:0,against:0,agonist:[0,1],agonist_affin:1,agonist_conc:1,agonist_submaximal_conc:1,agonists_conc:1,al:[0,1,4],alejandro:3,all:[0,1,4],allow:[0,4],alreadi:4,also:[0,4],altern:4,although:0,alv:4,am:2,amount:[0,1],amplitud:1,an:[0,1,3,4],analysi:[0,1,3],androulaki:4,ani:[0,3],anoth:4,antagonist:[0,1],antagonist_conc:1,antagonists_affin:1,antagonists_conc:1,antagonists_conc_rang:1,apach:3,api:3,appli:[0,1,4],approach:[0,4],ar:[0,3,4],area:1,arithmet:0,arrai:[0,1],articl:3,ask:3,assai:0,assess:0,assist:4,associ:[0,1,4],assum:[0,4],assumpt:[0,4],author:3,automat:1,avail:[0,4],b:0,bar:1,basal:0,base:[0,4],baselin:0,becaus:[0,4],becom:[0,4],been:[0,4],being:[0,3,4],bend:[0,1],better:4,between:[0,4],bibtex:3,bind:[1,2,3,4],binding_kinet:[1,2],biochem:[0,4],bioinformat:[0,3],biolog:[0,4],biologi:[0,3],biomed:4,biomodel:4,biopython:0,biorxiv:3,birch:4,bound:0,bridg:4,bring:[0,3,4],bruce:4,built:[0,3],c:[0,1],calcoccup:1,calcul:[0,1,2,4],call:[0,1],calul:1,camp:0,campaign:0,can:[0,3,4],capelli:4,carefulli:1,cascad:4,cat:4,catalysi:4,catalyz:[0,4],cell:[0,4],cellular:[0,4],celsiu:1,central:4,certain:0,chang:[0,2,4],charact:1,character:[0,4],chemic:0,choic:[0,3],chose:0,chosen:0,claim:4,clark:4,classic:[0,3],classif:0,classifi:0,close:0,code:[0,3],colab:1,com:3,come:0,commonli:[0,4],commun:[0,3],compar:0,comparison:[0,4],compet:0,competit:0,complementari:0,complet:1,complex:[0,4],comput:[0,3],computation:[0,4],concentr:[0,1,4],concept:[0,4],conceptu:0,concurr:4,condit:[0,4],conform:0,consid:[0,1,2],consist:4,constant:[0,1,4],constitut:[0,4],contain:[0,3],contribut:4,convert:1,convolut:4,core:0,correspond:0,corrrespond:0,coupl:0,creat:1,critic:4,csv:1,current:1,curv:[0,1],d:0,d_:0,dat:1,data:[0,1,4],databas:[0,1,4],datafram:1,de:4,deal:0,decad:4,decemb:0,decim:1,decreas:0,decrement:1,decrementor:1,deduc:0,deep:4,defaul:1,defin:0,definit:0,delean:0,dell:4,demonstr:0,depend:[0,4],deploy:0,deriv:[0,4],describ:[0,4],descript:0,design:0,despit:4,detail:0,determin:4,develop:[0,1,4],deward:4,dict:1,dictionari:1,didn:0,differ:[0,4],differenti:[0,4],dilut:0,dimens:4,dimension:4,directli:2,directori:1,disciplin:4,discoveri:4,discret:0,diseas:4,displac:0,displai:1,dissoci:[0,4],distribut:[1,4],divid:0,doe:2,doen:1,doesn:[0,3],dopaminerg:4,dose:[0,1],downstream:4,drug:[3,4],drug_receptor:1,drugreceptor:4,dt:1,due:0,duran:4,dure:0,dynam:4,e:[0,1],each:[0,1,4],easi:0,easier:0,easili:[0,3,4],ec_:0,ed:0,effect:[0,1,4],effector:0,efficaci:0,either:0,element:4,encod:4,end:[0,1],endogen:0,enough:4,environ:[0,3],enzym:4,epiderm:4,eq:0,equal:0,equat:[0,4],equilibrium:[0,1,4],error:4,essenti:0,estim:[0,4],et:[0,1,4],evalu:4,even:4,event:[0,4],exampl:3,exist:[0,4],experi:0,experiment:[0,1,4],expert:[0,3],explicit:4,explor:[0,3],expratio:1,express:0,extens:[0,3],extract:1,fact:[0,4],factor:[0,4],fals:[1,2],famili:0,fast:4,fastasequ:[],feed:4,field:4,fig:0,figur:0,file:[0,1],filenam:1,fill:1,find:0,first:[0,3,4],fit:[0,1],fitmodel:1,fix:0,flt:1,focu:4,follow:0,format:1,found:[3,4],four:0,foward:1,fraction:[0,1],framework:4,free:[0,3],freeli:3,frequent:3,friendli:[0,3],frigola:4,from:[0,1,3,4],full:1,fundament:4,g:[0,1,4],g_:0,gener:[3,4],geometr:0,get:[],getgprotein:1,gi:1,giorgetti:3,github:3,giulia:3,give:0,given:[0,3],glont:4,goe:0,golan:0,googl:1,gossen:3,govern:4,gpcr:[0,1,3],gpcrdb:0,gprotein:[],gq:[0,1],grant:0,grcr:0,green:0,gromac:1,grow:4,growth:4,gs:1,ha:[0,4],half:1,halfwai:0,hallucinogen:4,hamper:4,have:[0,4],help:0,helper:[],henc:0,high:4,higher:0,home:1,hormon:0,how:[0,4],howev:[0,4],http:3,human:[0,1],hyperbol:0,i:[0,1,2],ic_:0,idea:4,ideal:4,identif:4,impact:0,implement:[0,1],impli:0,includ:[0,4],incomplet:4,incorpor:0,increas:0,increment:1,incrementor:1,index:3,indic:4,individu:0,infer:0,inform:[0,3,4],inhibit:[0,1],initi:[0,1,4],input:[0,3],insid:4,instanc:[0,1,3,4],instead:[0,3],integr:[0,4],intens:4,interact:[0,3,4],intern:1,internet:4,interplai:4,intric:[0,4],introduct:3,invergo:4,ip_3:0,iter:1,its:[0,1,4],j:[0,4],jona:3,jupyt:[0,3],just:[0,1,3],k:1,k_:[0,4],k_d:0,k_m:4,kd:[0,2],kelvin:1,kholodenko:4,kinas:[0,4],kinet:[1,4],kinetictempscal:1,known:0,koff:1,kokh:1,kon:1,krzyzanski:4,kwarg:1,l2:0,l:0,l_init:2,label:0,lack:4,last:0,latter:0,law:0,learn:[0,4],length:1,less:0,librari:[0,1],lig_conc_rang:1,ligand:[0,1,2,3,4],light:4,like:[0,4],line:0,linear:0,list:1,literatur:[0,4],liu:4,logarithm:0,logist:0,loop:1,lowest:0,lr:[0,2],m:0,machin:4,macromolecular:4,made:0,magnitud:0,mai:[0,4],mainli:0,make:[0,3,4],malik:4,mani:[0,4],mass:[0,1],mathemat:[0,1,4],mathod:1,matplotlib:0,matter:[0,4],max:4,maxbend:[],maxim:0,maximum:[0,1],maxit:1,mccrai:0,md:[1,4],me:1,mead:1,mean:4,measur:[0,1,4],mechan:4,mediat:4,medicin:4,messeng:0,metabol:0,metabolit:0,metadynam:4,method:[0,1,3,4],microgr2nanomolar:[],microgram:1,microgramstonanomolar:1,might:0,mimic:0,minim:[1,3],minimum:0,miss:4,model:[0,1,3,4],modifi:[0,1],modul:[0,1,3],modular:0,molar:0,molecular:[0,1,3,4],more:[0,4],moreov:0,most:4,must:[0,1],myriad:0,n:4,nair:[0,4],namd:1,name:1,nanomolar:1,natur:0,need:[0,4],nelder:1,network:4,neubig:0,neural:4,neurotransmitt:0,neve:0,next:4,nm:1,non:[0,3],none:1,normal:[0,4],notebook:[0,3],novel:[0,3],nowadai:[0,3],ns:1,nstep:1,number:[1,4],numer:[0,4],numpi:0,nune:4,o:0,obeserv:1,observ:[0,1],obtain:[0,1,2],occup:[0,4],occupi:[0,1],occupit:1,occur:[0,4],od:[1,4],off:4,one:[0,4],onli:[0,4],open:[0,3],option:1,orco:4,order:[0,1,4],ordinari:4,org:3,other:[0,2,4],out:0,over:[0,4],overcom:4,oxtr:1,page:3,panda:[0,1],paradigm:4,paramet:[0,1,2,4],paramt:1,part:[0,4],past:4,path:1,pathai:1,pathophysiolog:4,pathwai:[1,2,3,4],pathway_paramet:1,pathwayparamet:1,pathwayparameterstocsv:1,pathways_path:1,patrick:0,pedro:3,percent:1,percentag:0,perform:[0,1],person:4,pfleger:0,pharmacodynam:[0,3],pharmacolog:4,phosphoryl:[0,4],phototransduct:4,physic:4,pipelin:[0,3,4],pkd:1,pkd_agonist:1,pkd_antagonist:1,plai:[0,4],plateau:0,pleas:[1,3],plot:[0,1],plotcurv:[],plotiter:1,plotrtdistribuiton:1,plotrtstat:1,point:[0,1],portion:0,posit:1,possibl:0,potenc:[0,1],potencytocsv:1,potencytodict:1,potent:0,power:[0,4],pre:0,predict:[0,3,4],prefer:[0,3],prefix:1,presenc:0,present:0,previou:0,printend:1,printprogressbar:1,process:4,processed_data:1,produc:0,progress:[0,1],project:1,promis:4,prone:4,proof:4,proport:[0,2],propos:[0,4],protein:[0,1,4],protocol:[0,3],provid:4,publish:3,pujol:4,pygomodo:3,pysb:0,python:0,q:0,qgrid:1,quantif:4,quantit:[0,4],quantiti:4,queri:1,question:3,r:[0,1],r_:0,radioact:0,radioligand:0,ragoza:4,ramd:1,ramdom:1,rang:[0,1],ratio:1,raw:1,reach:0,reaction:[0,1,2,4],reactom:0,readabl:0,reason:[0,4],recent:4,receptor:[1,2,3,4],receptor_conc:1,red:0,reduc:0,refer:[0,3],regress:0,rel:4,relat:4,relationship:[0,4],relev:4,reli:4,render:0,rendit:4,replic:[0,3],repositori:4,repres:0,reproduc:1,repsons:0,requir:1,rerun:[0,3],rescal:1,research:[3,4],resid:1,resolut:4,resolv:0,respect:0,respons:[0,1,4],result:[0,2,4],retriv:[],reusabl:0,revers:1,reward:4,rhodopsin:4,ribeiro:3,ribeiro_ssb_2022:3,right:0,rise:4,role:4,rossetti:3,rribeiro:[1,3],rui:3,rule:[0,2],run:1,s:0,sai:0,same:[0,1,2,4],satur:0,save:1,scale:[1,4],scenario:0,scheme:0,sci:3,scientif:[0,3],scikit:0,scipi:0,screen:0,search:3,sebaugh:[0,1],second:[0,1,4],see:[0,1],seed:1,seed_decrementor:1,seed_incrementor:1,select:0,self:1,semi:0,sens:4,sequenc:1,seri:[0,4],serotonin:4,serv:0,set:4,setsimulationparamet:1,setup:1,sever:0,shape:[0,1],share:[0,3],sheriff:4,shift:0,shoul:1,should:[0,4],show_curv:[],showcurv:1,showgraph:1,showpot:1,sigmoid:[0,1],signal:[1,3,4],signaltransduct:0,similar:4,simualt:1,simul:[1,2,3,4],sinc:[0,4],site:0,slope:0,so:[0,2,4],softwar:[1,3],softwr:1,solv:4,sourc:[0,3],space:0,spare:0,spatial:4,speci:[0,1,4],special:4,specif:[0,1,4],ssb:[0,3],ssbtoolkit:1,start:0,state:4,statement:0,statist:1,steadi:4,steep:0,stein:[0,4],step:[1,4],still:4,store:4,str:1,straight:0,strength:4,string:1,strong:0,stronger:0,structur:[0,3],studi:[0,4],subcellular:[3,4],subfamili:0,submax_concentr:1,submaxconcentr:1,submaxim:[0,1],subsequ:4,subunit:0,sue:2,suffix:1,suitabl:0,system:[0,3],systemat:0,t1:1,t2:1,t:[0,1,3],tabl:1,taken:[0,4],target:[0,1,4],target_paramet:1,tauramd:1,temperatur:1,tempor:4,term:0,termin:1,than:0,thank:4,thei:4,them:[0,3,4],theori:[0,4],therebi:4,therefor:[0,4],thesi:0,thi:[0,1,4],think:4,those:4,though:0,three:[0,4],through:0,time:[0,1,4],tissu:0,titl:3,todai:4,togeth:[0,3],tool:[0,3],toolkit:[0,3],total:[0,1],toward:4,tramd:1,transduct:4,transfer:4,tremend:4,truth:4,ttotal:1,tu:1,tumor:4,tutori:[1,3],typic:[0,4],umbrella:0,unbound:0,under:[0,1,3,4],underneath:4,understand:4,undoubtedli:4,uniprot:1,uniprotid:1,uniqu:0,unit:1,unk:0,unknown:0,unlabel:0,unpreced:4,unquestion:4,untest:[0,3],up:[0,4],upper:0,url:3,us:[0,1,2,3,4],user:[0,1,3],userpathwayparamet:1,util:1,v_:4,valid:0,valu:[0,1,2,4],variabl:4,variat:0,varieti:4,vein:0,version:0,versu:0,virtual:0,vivo:4,wa:[0,1,3],wai:[0,4],wang:4,wash:0,we:0,well:0,were:0,what:3,when:[0,2],where:[0,4],wherea:0,which:0,whole:4,why:[0,2],wide:0,width:1,without:0,word:[0,4],work:[1,3],www:3,x:0,xie:4,y:0,year:[3,4],you:3,zero:0},titles:["What is the SSBtoolkit?","API Documentation","Frequently Asked Questions","Welcome to SSBtoolkit\u2019s documentation!","Introduction to Structure Systems Biology"],titleterms:{affin:0,api:1,ask:2,avail:3,bind:0,biologi:4,citat:3,cite:3,content:3,develop:3,document:[1,3],doi:3,drug:0,frequent:2,fund:3,gener:2,indic:3,introduct:4,licens:3,pathwai:0,question:2,receptor:0,s:3,signal:0,simul:0,ssbtoolkit:[0,3],structur:4,system:4,tabl:3,welcom:3,what:0}}) \ No newline at end of file diff --git a/docs/apidocs.rst b/docs/apidocs.rst index 388a749ea45655f44708593abc3a5b2fca83d223..964890776c4dbfe1f1bab037d9d74ff75de599f6 100644 --- a/docs/apidocs.rst +++ b/docs/apidocs.rst @@ -1,7 +1,10 @@ API Documentation ================= -.. automodule:: ssbtoolkit +.. automodule:: Binding :members: - + +.. automodule:: Simulation + :members: + .. automodule:: Utils :members: diff --git a/docs/conf.py b/docs/conf.py index 8571d44591a9d380035d246dbbf653fc22c95eed..d51c86fa91c130c7d46e830715449a6c95090222 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,8 @@ # import os import sys -sys.path.insert(0, os.path.abspath('../src/lib')) +sys.path.insert(0, os.path.abspath('../ssbtoolkit')) +sys.path.insert(0, os.path.abspath('../')) # -- Project information ----------------------------------------------------- @@ -22,7 +23,7 @@ copyright = '2022, Rui Pedro Ribeiro' author = 'Rui Pedro Ribeiro' # The full version, including alpha/beta/rc tags -release = 'v1' +release = 'v1.0.1' # -- General configuration --------------------------------------------------- diff --git a/ssbtoolkit/Binding.py b/ssbtoolkit/Binding.py new file mode 100644 index 0000000000000000000000000000000000000000..e68ef4f0cd5f2c63507311557b00d1366cadb3a5 --- /dev/null +++ b/ssbtoolkit/Binding.py @@ -0,0 +1,126 @@ +#LIBRARIES +import numpy as np +import ssbtoolkit.Utils as utils + +"""Module to simulate ligand-target binding curves.""" +def __init__(self): + self.receptor_conc = None + self.lig_conc_range = None + self.pKd = None + self.submax_concentration = None + +def Bind(self, **kwargs): + """ + Applies an function to calculate the fraction of occupited receptors at equilibrium. + + :parameter receptor_conc: Required (kwarg flt): concentration of receptor + :parameter lig_conc_range: Required (kwarg array): array of range of ligand concentration + :parameter pKd: Required (kwarg flt): pKd value of the ligand + """ + + if 'receptor_conc' not in kwargs: raise TypeError("ERROR: receptor_conc is missing") + if 'lig_conc_range' not in kwargs: raise TypeError("ERROR: lig_conc_range is missing") + if 'pKd' not in kwargs: raise TypeError("ERROR: pKd is missing") + + self._receptor_conc = kwargs.pop('receptor_conc') + self._lig_conc_range = kwargs.pop('lig_conc_range') + self._pKd = kwargs.pop('pKd') + + binding_data=[] + for conc in self._lig_conc_range: + binding_data.append(utils.CalcOccupancy(self._receptor_conc, conc, 0, self._pKd, 0)) + self.binding_data=binding_data + return self.binding_data + +def SubMaxConcentration(self): + """ + Calculates the maximum bending point of a sigmoid-shaped curve according to the mathod of Sebaugh et al., 2003. + + :parameter drug_receptor: Required (int): concentration of the receptor + :parameter lig_conc_range: Required (array): array of a range of ligand concentration + :return: instance .submax_concentration (flt) + + .. note:: The minimization uses the Nelder-Mead method. + """ + + from scipy.optimize import curve_fit, minimize + + + def sigmoid(X, Bottom, Top, Kd, p): + return Bottom + (Top-Bottom)/(1+np.power((Kd/X),p)) + + xfit = np.geomspace(np.min(self._lig_conc_range), np.max(self._lig_conc_range), 50000) #warning: shoud this be the minimum and maximum of concentration + popt, pcov = curve_fit(sigmoid, self._lig_conc_range, self.binding_data, bounds=([np.min(self.binding_data),-np.inf,-np.inf, 0.5],[np.inf,np.max(self.binding_data),np.inf, 2.5])) + + + def sigmoid_deriv_b(x, a,d,c,b): + return (x/c)**b*(a - d)*np.log(x/c)/((x/c)**b + 1)**2 + + min_value = minimize(sigmoid_deriv_b, np.max(xfit), args=(popt[0],popt[1],popt[2],popt[3]), method = 'Nelder-Mead') + + self.submax_concentration = round(min_value.x[0],3) + return self.submax_concentration + +def ShowCurve(self): + """ + Plots ligand-target binding curve + """ + + #import plotly + import plotly.graph_objs as go + from scipy.optimize import curve_fit + from sklearn.preprocessing import minmax_scale + + ##Fitting curve to the data + + yy = minmax_scale(self.binding_data)*100 + + def equation_dose(X, Bottom, Top, EC50, p): + return Bottom + (Top-Bottom)/(1+np.power((EC50/X),p)) + + popt, pcov = curve_fit(equation_dose, self._lig_conc_range, yy, bounds=([np.min(yy),-np.inf,-np.inf, 0.5],[np.inf,np.max(yy),np.inf, 2.5])) + + xfit = np.geomspace(np.min(self._lig_conc_range), np.max(self._lig_conc_range), 50000) # These values are the same as the values for the simulation time and not ligand concentration + yfit = minmax_scale(equation_dose(xfit, *popt))*100 + + + + trace1 = go.Line(x=xfit, y=yfit, showlegend=False, name='radioligand') + if self.submax_concentration: + xsubmaximal = np.array(self.submax_concentration) + ysubmaximal = np.array(equation_dose(xsubmaximal, *popt)) + trace2 = go.Scatter(x=xsubmaximal, y=ysubmaximal, showlegend=True, mode='markers', name='submaximal ({} μM)'.format(xsubmaximal), + marker=dict(size=14)) + else: trace2=[] + + + layout = dict(title = '', + xaxis = dict( + title = '[ligand] μM', + type ='log', + exponentformat='e', + titlefont=dict( + size=20 + ), + tickfont=dict( + size=20 + )), + yaxis = dict( + title = '% occupied receptors', + + titlefont=dict( + size=20), + tickfont=dict( + size=20) + + ), + legend=dict(font=dict(size=15)), + autosize=False, + width=850, + height=650, + ) + if self.submax_concentration: + fig = go.Figure(data=[trace1, trace2], layout=layout) + else: + fig = go.Figure(data=[trace1], layout=layout) + return fig diff --git a/ssbtoolkit/Simulation.py b/ssbtoolkit/Simulation.py new file mode 100644 index 0000000000000000000000000000000000000000..263ff9ae4e019555929dae7933a0f9730753edc9 --- /dev/null +++ b/ssbtoolkit/Simulation.py @@ -0,0 +1,1277 @@ +#LIBRARIES + +import sys, os, warnings, platform, site, importlib +import pylab as pl +from pysb.simulator import ScipyOdeSimulator +from scipy.optimize import curve_fit +from sklearn.preprocessing import minmax_scale +import plotly.graph_objs as go +import pandas as pd +import numpy as np +import ssbtoolkit.Utils as utils + +sys.path.insert(0, os.path.abspath(os.path.split(os.path.realpath(__file__))[0])) +warnings.simplefilter(action='ignore') + +distpath = site.getsitepackages()[0] +if platform.system() == 'Linux': + BioNetGen=os.path.join(distpath, 'bionetgen/bng-linux:') +elif platform.system() == 'Darwin': + BioNetGen=os.path.join(distpath, 'bionetgen/bng-mac:') +elif platform.system()=='Windows': + BioNetGen=os.path.join(distpath, 'bionetgen/bng-win:') +else: + raise ValueError('BioNetGen error. Platform unknown! The pygomodo was tested in Linux and Darwin (Mac) platforms.') +os.environ['PATH']=BioNetGen+os.environ['PATH'] + +pathways_path=(os.path.join(os.path.split(os.path.realpath(__file__))[0], 'pathways')) + + +""" +Module to simulate the mathematical models of the signaling pathways. +""" +class Activation: + """ + Simulation of the activation of signaling pathways (i.e. activation by agonists) + """ + def __init__(self): + self._ligands=None + self._affinities=None + self._pathway=None + self._receptor_conc=None + self._lig_conc_range=None + self._ttotal=None + self._nsteps=None + self._binding_kinetics=True + self._binding_kinetic_parameters=None + self.simulation_data=None + self.processed_data=None + + def SetSimulationParameters(self, **kwargs): + """ + :parameter ligands: Required (kwargs list): list of ligands' names (str) + :parameter affinities: Required (kwargs list): list of pKd values (flt) + :parameter pathway: Required (kwargs str): name of the pathway ('Gs', 'Gi', 'Gq') + :parameter receptor_conc: Required (kwargs flt): receptors concentration (nM) + :parameter lig_conc_range: Required (kwargs array): range of ligands' concentration + :parameter ttotal: Required (kwargs int): simulation time (seconds) + :parameter nsteps: Required (kwargs int): simulation time step + :parameter binding_kinetics: Optional (kwargs boolean): default (False) + + + .. warning:: the order of the lists of ligands names and affinities list must be the same. + + """ + self._ligands= kwargs.pop('ligands') + if 'affinities' in kwargs: + self._affinities=kwargs.pop('affinities') + self._pathway=kwargs.pop('pathway') + self._receptor_conc=kwargs.pop('receptor_conc') + self._lig_conc_range=kwargs.pop('lig_conc_range') + self._ttotal=kwargs.pop('ttotal') + self._nsteps=kwargs.pop('nsteps') + self._binding_kinetics=kwargs.pop('binding_kinetics') + if 'binding_kinetic_parameters' in kwargs:self._binding_kinetic_parameters=kwargs.pop('binding_kinetic_parameters') + self._DefaultPathwayParametersDataFrame=pd.DataFrame() + + return + + def PathwayParameters(self): + """ + Display table with default pathway parameters. + + .. warning:: this functions requires the qgrid library. It doens't work on Google Colab. + """ + import qgrid + self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) + + col_opts = { 'editable': False, 'sortable':False} + col_defs = {'Value': { 'editable': True, 'width': 150 }} + self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) + return self._DefaultPathwayParametersTable + + def UserPathwayParameters(self, path): + """ + Import user pathway parameters. + + :parameter path: Required (kwarg str): directory path + """ + import qgrid + self._DefaultPathwayParametersDataFrame = pd.read_csv(path) + col_opts = { 'editable': False, 'sortable':False} + col_defs = {'Value': { 'editable': True, 'width': 150 }} + self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) + return self._DefaultPathwayParametersTable + + def PathwayParametersToCSV(self, path): + """ + Export pathway parameters into CSV format. + + :parameter path: Required (kwarg str): directory path + """ + self._DefaultPathwayParametersTable.get_changed_df().to_csv(path, index=False) + print('saved in:', path) + return + + def Reactions(self): + """ + Display pathway reactions. + """ + from IPython.display import display, HTML + display(HTML("<style>.container {width:90% !important}</style>")) + return pd.read_csv(pathways_path+'/{}_reactions.csv'.format(self._pathway)) + + def Run(self): + ''' + This function runs the pathway simulation and returns the raw simulation data. + ''' + + #Check inputs + if self._ligands==None: raise TypeError("ligands list undefined.") + elif self._pathway==None: raise TypeError("pathway name undefined.") + elif self._binding_kinetics==False and self._affinities==None: raise TypeError("affinity_values_dict undefined.") + elif self._binding_kinetics==True and self._affinities==None: pass + elif self._lig_conc_range.any() == False: raise TypeError("lig_conc_range undefined.") + elif self._ttotal==None: raise TypeError("ttotal undefined.") + elif self._nsteps==None: raise TypeError("nsteps undefined.") + elif self._receptor_conc==None: raise TypeError("receptor_conc undefined.") + else: pass + + + #Check Pathway availability and import it + available_pathways = ['Gs', 'Gi', 'Gq'] + if self._pathway == 'Gz(Gi)': self._pathway = 'Gi' + if self._pathway not in available_pathways: raise Exception('Unvailable Pathway. Please, introduce it manually. Pathways available: "Gs", "Gi", "Gq".') + mypathway = importlib.import_module('.'+self._pathway, package='ssbtoolkit.pathways') + + #Get default pathway parameters + if self._DefaultPathwayParametersDataFrame.empty and self._binding_kinetic_parameters==None: + self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) + self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() + + elif self._DefaultPathwayParametersDataFrame.empty is False and self._binding_kinetic_parameters is None: + try: + #extract data from qgrid + newparameters = self._DefaultPathwayParametersTable.get_changed_df() + self._PathwayParameters = newparameters.set_index('Parameter').iloc[:,0].to_dict() + except: + self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() + + elif self._DefaultPathwayParametersDataFrame.empty and self._binding_kinetic_parameters is not None: + self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) + + elif self._DefaultPathwayParametersDataFrame.empty is False and self._binding_kinetic_parameters is not None: + try: + #extract data from qgrid + newparameters = self._DefaultPathwayParametersTable.get_changed_df() + self._PathwayParameters = {**newparameters.set_index('Parameter').iloc[:,0].to_dict(), **self._binding_kinetic_parameters} + except: + self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self._binding_kinetic_parameters} + + #Input + t = pl.geomspace(0.00001, self._ttotal, num=self._nsteps) # (a,b,c); a is the starting time ; b is the total time simulated ; c is the number of points + + + #Output + simulation_data={} + + #Function + for ligand in self._ligands: + ligand_name = os.path.splitext(str(ligand))[0] + data=[] + utils.PrintProgressBar(0, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) + + ###DANGER ZONE### + if self._binding_kinetic_parameters is not None: + self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self._binding_kinetic_parameters[self._ligands.index(ligand)]} + ###################### + + for idx in range(len(self._lig_conc_range)): + + ligand_conc = self._lig_conc_range[idx] + if self._binding_kinetics == False: + #get LR conc + parameters = {**self._PathwayParameters, 'R_init':self._receptor_conc} + LR_conc_init = utils.CalcOccupancy(self._receptor_conc, ligand_conc, 0, self._affinities[self._ligands.index(ligand)], 0) + mymodel = mypathway.network(LR=LR_conc_init, kinetics=False, **parameters) + simres = ScipyOdeSimulator(mymodel, tspan=t, compiler='cython').run() + yout = simres.all + + elif self._binding_kinetics == True: + parameters={**self._PathwayParameters,'R_init':self._receptor_conc, 'L_init':self._lig_conc_range[idx] } + mymodel = mypathway.network(kinetics=True, **parameters) + simres = ScipyOdeSimulator(mymodel, tspan=t, compiler='cython').run() + yout = simres.all + + d1={'ligand_conc':ligand_conc, 'time':t } + + for idx2 in range(len(mypathway.list_of_observables)): + d2={mypathway.list_of_observables[idx2]:yout[mypathway.list_of_observables[idx2]]} + d1.update(d2) + data.append(d1) + utils.PrintProgressBar(idx + 1, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) + + + simulation_data[ligand_name] = {'sim_data':data, + 'label':ligand_name,} + self.simulation_data = simulation_data + return + + def Analysis(self): + ''' + This function calculates the dose-response effect. + + :return: instance of processed_data + ''' + + if self.simulation_data == None: raise TypeError('There is no simulation data. simulation.activation.run() must be run first.') + + # Define all the lists and dictionaries used in this function + raw_data=[] + normalized_data=[] + dose={} + + #defining concentration range + lig_conc_min = self._lig_conc_range.min() + lig_conc_max = self._lig_conc_range.max() + + #Main function + for ligand in self.simulation_data: + + #definig and dictionaries used in this loop: + raw_data_dict={} + normalized_data_dict={} + + # Calculate dose-response curve + #get metabolite concentration, rescale, and transform data if pathway/metabolite decrease + # metabolite_raw is not normalized + if self._pathway == 'Gi' or self._pathway == 'Gz(Gi)': + metabolite='cAMP' + metabolite_conc_raw=[] + for i in range(len(self._lig_conc_range)): + n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad + metabolite_conc_raw.append(n) + metabolite_conc_norm = minmax_scale(1-np.array(metabolite_conc_raw)) + elif self._pathway == 'Gs': + metabolite='cAMP' + metabolite_conc_raw=[] + for i in range(len(self._lig_conc_range)): + n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad + metabolite_conc_raw.append(n) + metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) + elif self._pathway == 'Gq': + metabolite='IP3' + metabolite_conc_raw=[] + for i in range(len(self._lig_conc_range)): + n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad + metabolite_conc_raw.append(n) + metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) + else: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') + + + ## save results + raw_data_dict['x']=self._lig_conc_range + raw_data_dict['y']=metabolite_conc_raw + raw_data_dict['label']=self.simulation_data[ligand]['label'] + + normalized_data_dict['x']=self._lig_conc_range + normalized_data_dict['y']=metabolite_conc_norm + normalized_data_dict['label']=self.simulation_data[ligand]['label'] + + ## create a list of all data + raw_data.append(raw_data_dict) + normalized_data.append(normalized_data_dict) + + ##Fitting curve to the data + + def equation_dose(X, Bottom, Top, EC50, p): + return Bottom + (Top-Bottom)/(1+np.power((EC50/X),p)) + + popt_EC50, pcov = curve_fit(equation_dose, self._lig_conc_range, metabolite_conc_norm, bounds=([np.min(metabolite_conc_norm),-np.inf,-np.inf, 0.5],[np.inf,np.max(metabolite_conc_norm),np.inf, 2.5])) + + xfit_EC50 = np.geomspace(lig_conc_min, lig_conc_max, 50000) # These values are the same as the values for the simulation time and not ligand concentration + yfit_EC50 = equation_dose(xfit_EC50, *popt_EC50) + + fit_EC50={'x':xfit_EC50, 'y':yfit_EC50, 'label':self.simulation_data[ligand]['label']} + + dose[ligand] = {'raw_data': raw_data_dict, + 'normalized_data':normalized_data_dict , + 'fitted_data': fit_EC50, + 'EC50 (μM)': round(popt_EC50[2],5), + 'pEC50': round(-np.log10(popt_EC50[2]*1E-6),2)} + + self.processed_data=dose + return + + def ShowCurve(self, save=False, filename=None): + ''' + Plots the dose-response curve. + ''' + + if self.simulation_data == None: raise TypeError('There is no simulation data. simulation.activation.run() must be run first.') + + import plotly + import plotly.graph_objs as go + import plotly.offline as pyoff + + colors = plotly.colors.DEFAULT_PLOTLY_COLORS + + plot_data=[] + + color_id=0 + for ligand in self.processed_data: + trace_norm = go.Scatter(x=self.processed_data[ligand]['normalized_data']['x'], + y=minmax_scale(self.processed_data[ligand]['normalized_data']['y'])*100 , + mode='markers', + showlegend=True, + name=self.processed_data[ligand]['normalized_data']['label'], + marker=dict(color=colors[color_id])) + plot_data.append(trace_norm) + + trace_fitted = go.Scatter(x=self.processed_data[ligand]['fitted_data']['x'], + y=minmax_scale(self.processed_data[ligand]['fitted_data']['y'])*100, + mode='lines', + showlegend=False, + name=self.processed_data[ligand]['fitted_data']['label'], + line=dict(color=colors[color_id])) + plot_data.append(trace_fitted) + color_id +=1 + + layout = dict(title = '', + xaxis = dict( + title = '[ligand] μM', + type ='log', + #range = [-3, 2], + exponentformat='e', + titlefont=dict( + size=20 + ), + tickfont=dict( + size=20 + )), + yaxis = dict( + title = '% Response', + #range = [0, 100], + titlefont=dict( + size=20), + tickfont=dict( + size=20) + + ), + legend=dict(font=dict(size=15)), + autosize=False, + width=850, + height=650, + ) + + fig = go.Figure(data=plot_data, layout=layout) + #fig['layout']['yaxis'].update(autorange = True) + + if save==True: + if filename==None: + filename='plot.html' + return pyoff.plot(fig, filename=filename) + else: + ext = os.path.splitext(filename)[-1] + if ext == '.png': fig.write_image(filename, scale=3) + elif ext == '.html': pyoff.plot(fig, filename=filename) + else: raise TypeError("extension not valid. Use png or html.") + elif save ==False: return fig + return + + def ShowPotency(self): + ''' + Return the potency values as a pandas DataFrame. + ''' + import pandas as pd + data = Simulation.Activation.PotencyToDict(self) + df = pd.DataFrame.from_dict(data, orient='index') + return df + + def PotencyToDict(self): + ''' + Convert potencies into a dictionary. + ''' + + #dependencies + if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.activation.analysis() must be run first.') + + kvalues={} + for ligand in self.processed_data: + IC50 = list(self.processed_data[ligand].keys())[-2] + IC50_value = self.processed_data[ligand][IC50] + pIC50 = list(self.processed_data[ligand].keys())[-1] + pIC50_value = self.processed_data[ligand][pIC50] + kvalues[ligand]={IC50:IC50_value, pIC50:pIC50_value} + return kvalues + + def PotencyToCSV(self, path): + ''' + Exports the potency values into csv format. + + :parameter path: Required (kwarg str): directory path to save the csv file + ''' + + data = Simulation.Activation.PotencyToDict(self) + df = pd.DataFrame.from_dict(data, orient='index') + df.to_csv(path, index=False) + return + +class Inhibition: + """ + Simulation of the inhibition of signaling pathways (i.e. inhibition by antagonists). + """ + def __init__(self): + self._agonist=None + self._agonist_affinity=None + self._agonist_submaximal_conc=None + self._antagonists=None + self._antagonists_affinities=None + self._pathway=None + self._receptor_conc=None + self._lig_conc_range=None + self._ttotal=None + self._nsteps=None + self._binding_kinetics=False + self._binding_kinetic_parameters=None + self.simulation_data=None + self.processed_data=None + + def SetSimulationParameters(self, **kwargs): + """ + :parameter agonist: Required (kwargs str): agonist name + :parameter agonist_affinity: Required (kwargs flt): agonist pKd value + :parameter agonist_submaximal_conc: Required (kwargs flt): agonist submaximal concentration + :parameter antagonists: Required (kwargs list):list of antagonists names (str) + :parameter antagonists_affinities: Required (kwargs list): list of antagonists affinity values (flt) + :parameter antagonists_conc_range: Required (kwargs array): range of ligands' concentration (nM) + :parameter pathway: Required (kwargs str): name of the pathway ('Gs', 'Gi', 'Gq') + :parameter receptor_conc: Required (kwargs flt): receptors concentration (nM) + :parameter ttotal: Required (kwargs int): simulation time (seconds) + :parameter nsteps: Required (kwargs int): simulation time step + :parameter kinetics: Optional (kwargs boolean): default (False) + + + :return: instances of all parameters + + .. warning:: the order of the lists of the antagonists names and affinities list must be the same. + + """ + self._agonist= kwargs.pop('agonist') + self._agonist_affinity=kwargs.pop('agonist_affinity') + self._agonist_submaximal_conc=kwargs.pop('agonist_submaximal_conc') + self._antagonists=kwargs.pop('antagonists') + self._antagonists_affinities=kwargs.pop('antagonists_affinities') + self._pathway=kwargs.pop('pathway') + self._receptor_conc=kwargs.pop('receptor_conc') + self._lig_conc_range=kwargs.pop('lig_conc_range') + self._ttotal=kwargs.pop('ttotal') + self._nsteps=kwargs.pop('nsteps') + if 'kinetics' in kwargs: + self._binding_kinetics=kwargs.pop('kinetics') + if self._binding_kinetics==True: raise TypeError("The of Kinetic parameters during an inhibition simulation it is not supported yet.") + else: self._binding_kinetics=False + if 'binding_kinetic_parameters' in kwargs: + self._binding_kinetic_parameters=kwargs.pop('binding_kinetic_parameters') + self._DefaultPathwayParametersDataFrame=pd.DataFrame() + + return + + def PathwayParameters(self): + """ + Display table with default pathway parameters. + + .. warning:: this functions requires the qgrid library. It doens't work on Google Colab. + """ + import qgrid + self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) + + col_opts = { 'editable': False, 'sortable':False} + col_defs = {'Value': { 'editable': True, 'width': 150 }} + self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) + return self._DefaultPathwayParametersTable + + def UserPathwayParameters(self, path): + """ + Import user pathway parameters. + + :parameter path: Required (kwarg str): directory path + """ + import qgrid + self._DefaultPathwayParametersDataFrame = pd.read_csv(path) + col_opts = { 'editable': False, 'sortable':False} + col_defs = {'Value': { 'editable': True, 'width': 150 }} + self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) + return self._DefaultPathwayParametersTable + + def PathwayParametersToCSV(self, path): + """ + Export pathway parameters into CSV format. + + :parameter path: Required (kwarg str): directory path + """ + self._DefaultPathwayParametersTable.get_changed_df().to_csv(path, index=False) + print('saved in:', path) + return + + def Reactions(self): + """ + Display pathway reactions. + """ + from IPython.display import display, HTML + display(HTML("<style>.container {width:90% !important}</style>")) + return pd.read_csv(pathways_path+'/{}_reactions.csv'.format(self._pathway)) + + def Run(self): + ''' + This function runs the pathway simulation and returns the raw simulation data. + ''' + + #Check inputs + if self._agonist==None: raise TypeError("agonist undefined.") + elif self._agonist_affinity==None: raise TypeError("agonist_affinity undifined.") + elif self._antagonists==None: raise TypeError("antagonists list undefined.") + elif self._antagonists_affinities==None: raise TypeError("antagonists affinity values undefined.") + elif self._pathway==None: raise TypeError("pathway undefined.") + elif self._lig_conc_range.any() == False: raise TypeError("lig_conc_range undefined.") + elif self._agonist_submaximal_conc == None: raise TypeError("agonist_submaximal_conc undifined.") + elif self._ttotal==None: raise TypeError("ttotal undefined.") + elif self._nsteps==None: raise TypeError("nsteps undefined.") + elif self._receptor_conc==None: raise TypeError("receptor_conc undefined.") + elif self._binding_kinetics==True: raise TypeError("The of Kinetic parameters during an inhibition simulation it is not supported yet.") + else: pass + + #check pathway + available_pathways = ['Gs', 'Gi', 'Gq'] + if self._pathway == 'Gz(Gi)': self._pathway = 'Gi' + if self._pathway not in available_pathways: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') + mypathway = importlib.import_module('.'+self._pathway, package='ssbtoolkit.pathways') + + #Get default pathway parameters + if self._DefaultPathwayParametersDataFrame.empty: + self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) + self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() + + elif self._DefaultPathwayParametersDataFrame.empty is False: + try: + #extract data from qgrid + newparameters = self._DefaultPathwayParametersTable.get_changed_df() + self._PathwayParameters = newparameters.set_index('Parameter').iloc[:,0].to_dict() + except: + self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() + + #Input + t = pl.geomspace(0.00001, self._ttotal, num=self._nsteps) # (a,b,c); a is the starting time ; b is the total time simulated ; c is the number of points + + #Output + simulation_data={} + + #Function + for ligand in self._antagonists: + ligand_name = os.path.splitext(ligand)[0] + data=[] + utils.PrintProgressBar(0, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) + + for idx in range(len(self._lig_conc_range)): + + ligand_conc = self._lig_conc_range[idx] + + #get LR conc + parameters = {**self._PathwayParameters, 'R_init':self._receptor_conc} + LR_conc_init = utils.CalcOccupancy(self._receptor_conc, self._agonist_submaximal_conc, ligand_conc, self._agonist_affinity, self._antagonists_affinities[self._antagonists.index(ligand)]) + mymodel = mypathway.network(LR=LR_conc_init, kinetics=False, **parameters) + simres = ScipyOdeSimulator(mymodel, tspan=t, compiler='cython').run() + yout = simres.all + + d1={'ligand_conc':ligand_conc, 'time':t } + + for idx2 in range(len(mypathway.list_of_observables)): + d2={mypathway.list_of_observables[idx2]:yout[mypathway.list_of_observables[idx2]]} + d1.update(d2) + data.append(d1) + utils.PrintProgressBar(idx + 1, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) + + simulation_data[ligand_name] = {'sim_data':data, + 'label':self._agonist+' + ' + ligand_name} + + self.simulation_data=simulation_data + return + + def Analysis(self): + ''' + This function calculates the dose-response effect. + + :return: instance processed_data + ''' + #dependencies + if self.simulation_data == None: raise TypeError('There is no simulation data. simulation.inhibition.run() must be run first.') + + # Define all the lists and dictionaries used in this function + raw_data=[] + normalized_data=[] + dose={} + + #defining concentration range + #defining concentration range + lig_conc_min = self._lig_conc_range.min() + lig_conc_max = self._lig_conc_range.max() + + #Main function + for ligand in self.simulation_data: + + #definig and dictionaries used in this loop: + raw_data_dict={} + normalized_data_dict={} + + # Calculate dose-response curve + #get metabolite concentration, rescale, and transform data if pathway/metabolite decrease + # metabolite_raw is not normalized + if self._pathway == 'Gi' or self._pathway == 'Gz(Gi)': + metabolite='cAMP' + metabolite_conc_raw=[] + for i in range(len(self._lig_conc_range)): + n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad + metabolite_conc_raw.append(n) + metabolite_conc_norm = minmax_scale(1-np.array(metabolite_conc_raw)) + elif self._pathway == 'Gs': + metabolite='cAMP' + metabolite_conc_raw=[] + for i in range(len(self._lig_conc_range)): + n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad + metabolite_conc_raw.append(n) + metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) + elif self._pathway == 'Gq': + metabolite='IP3' + metabolite_conc_raw=[] + for i in range(len(self._lig_conc_range)): + n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad + metabolite_conc_raw.append(n) + metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) + else: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') + + + ## save results + raw_data_dict['x']=self._lig_conc_range + raw_data_dict['y']=metabolite_conc_raw + raw_data_dict['label']=self.simulation_data[ligand]['label'] + + normalized_data_dict['x']=self._lig_conc_range + normalized_data_dict['y']=metabolite_conc_norm + normalized_data_dict['label']=self.simulation_data[ligand]['label'] + + ## create a list of all data + raw_data.append(raw_data_dict) + normalized_data.append(normalized_data_dict) + + ##Fitting curve to the data + + def equation_dose(X, Bottom, Top, EC50, p): + return Bottom + (Top-Bottom)/(1+np.power((EC50/X),p)) + + popt_IC50, pcov = curve_fit(equation_dose, self._lig_conc_range, metabolite_conc_norm, bounds=([np.min(metabolite_conc_norm),-np.inf,-np.inf, 0.5],[np.inf,np.max(metabolite_conc_norm),np.inf, 2.5])) + + xfit_IC50 = np.geomspace(lig_conc_min, lig_conc_max, 50000) # These values are the same as the values for the simulation time and not ligand concentration + yfit_IC50 = equation_dose(xfit_IC50, *popt_IC50) + + fit_IC50={'x':xfit_IC50, 'y':yfit_IC50, 'label':self.simulation_data[ligand]['label']} + + dose[ligand] = {'raw_data': raw_data_dict, + 'normalized_data':normalized_data_dict , + 'fitted_data': fit_IC50, + 'IC50 (μM)': round(popt_IC50[2],5), + 'pIC50': round(-np.log10(popt_IC50[2]*1E-6),2)} + + self.processed_data=dose + return + + def ShowCurve(self, save=False, filename=None): + ''' + Plot the dose-response curve. + ''' + #dependencies + if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.inhibition.analysis() must be run first.') + + import plotly + import plotly.graph_objs as go + import plotly.offline as pyoff + + colors = plotly.colors.DEFAULT_PLOTLY_COLORS + + plot_data=[] + + color_id=0 + for ligand in self.processed_data: + trace_norm = go.Scatter(x=self.processed_data[ligand]['normalized_data']['x'], + y=minmax_scale(self.processed_data[ligand]['normalized_data']['y'])*100 , + mode='markers', + showlegend=True, + name=self.processed_data[ligand]['normalized_data']['label'], + marker=dict(color=colors[color_id])) + plot_data.append(trace_norm) + + trace_fitted = go.Scatter(x=self.processed_data[ligand]['fitted_data']['x'], + y=minmax_scale(self.processed_data[ligand]['fitted_data']['y'])*100, + mode='lines', + showlegend=False, + name=self.processed_data[ligand]['fitted_data']['label'], + line=dict(color=colors[color_id])) + plot_data.append(trace_fitted) + color_id +=1 + + layout = dict(title = '', + xaxis = dict( + title = '[ligand] μM', + type ='log', + #range = [-4, 2], + exponentformat='e', + titlefont=dict( + size=20 + ), + tickfont=dict( + size=20 + )), + yaxis = dict( + title = '% Response', + #range = [0, 100], + titlefont=dict( + size=20), + tickfont=dict( + size=20) + + ), + legend=dict(font=dict(size=15)), + autosize=False, + width=850, + height=650, + ) + + fig = go.Figure(data=plot_data, layout=layout) + if save==True: + if filename==None: + filename='plot.html' + return pyoff.plot(fig, filename=filename) + else: + ext = os.path.splitext(filename)[-1] + if ext == '.png': fig.write_image(filename, scale=3) + elif ext == '.html': pyoff.plot(fig, filename=filename) + else: raise TypeError("extension not valid. Use png or html.") + elif save ==False: return fig + return + + def ShowPotency(self): + ''' + Return the potency values as a pandas DataFrame. + ''' + import pandas as pd + data = Simulation.Inhibition.PotencyToDict(self) + df = pd.DataFrame.from_dict(data, orient='index') + return df + + def PotencyToDict(self): + ''' + Convert potencies into a dictionary. + ''' + #dependencies + if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.inhibition.analysis() must be run first.') + + kvalues={} + for ligand in self.processed_data: + IC50 = list(self.processed_data[ligand].keys())[-2] + IC50_value = self.processed_data[ligand][IC50] + pIC50 = list(self.processed_data[ligand].keys())[-1] + pIC50_value = self.processed_data[ligand][pIC50] + kvalues[ligand]={IC50:IC50_value, pIC50:pIC50_value} + return kvalues + + def PotencyToCSV(self, path): + ''' + Exports the potency values into csv format. + + :parameter path: Required (kwarg str): directory path to save the csv file + ''' + data = Simulation.Inhibition.PotencyToDict(self) + df = pd.DataFrame.from_dict(data, orient='index') + df.to_csv(path, index=False) + return + +class FitModel: + """ + Fit a model to experimental data. + + .. note:: This class was developed to reproduce data from a specific experimental setup. Please see tutorial 4 (OXTR pathay). Use carefully! + """ + def __init__(self): + + #fitting parameters + self._expratio = None + self._seed = None + self._maxiter = None + self._seed_incrementor = None + self._target_parameter = None + + #Pathway parameters + self._ttotal = None + self._nsteps = None + self._pathway = None + self._observable = None + self.pathway_parameters = {} + + def SetSimulationParameters(self, **kwargs): + """ + :parameter pathway_parameters: Required (kwargs): dict of pathway parameters + :parameter pathway: Required (kwargs str): name of the pathway ('Gs', 'Gi', 'Gq') + :parameter ttotal: Required (kwargs int): simulation time (seconds) + :parameter nsteps: Required (kwargs int): simulation time step + :parameter observable: Required (kwargs str): molecular specie to be measured + + :return: instances of all parameters + + """ + + if 'pathway_parameters' in kwargs: + self.pathway_parameters = kwargs.pop('pathway_parameters') + #print('pathway_parameters YES') + self._DefaultPathwayParametersDataFrame=pd.DataFrame() + if 'ttotal' in kwargs: + self._ttotal = int(kwargs.pop('ttotal')) + print('ttotal =', self._ttotal) + else: raise TypeError("ttotal undefined.") + + if 'nsteps' in kwargs: + self._nsteps = int(kwargs.pop('nsteps', 1000)) + print('nsteps =', self._nsteps) + + if 'pathway' in kwargs: + self._pathway = str(kwargs.pop('pathway')) + print('pathway ->', self._pathway) + else: raise TypeError("pathway undefined.") + + available_pathways = ['Gs', 'Gi', 'Gq', 'OXTR_pathway'] + if self._pathway == 'Gz(Gi)': self._pathway = 'Gi' + if self._pathway not in available_pathways: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') + + + if'observable' in kwargs: + self._observable = str(kwargs.pop('observable')) + print('observable ->', self._observable) + else: raise TypeError("observable undefined.") + + return + + def PathwayParameters(self): + """ + Display table with default pathway parameters. + + .. warning:: this functions requires the qgrid library. It doens't work on Google Colab. + """ + import qgrid + self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) + + col_opts = { 'editable': False, 'sortable':False} + col_defs = {'Value': { 'editable': True, 'width': 150 }} + self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) + return self._DefaultPathwayParametersTable + + def UserPathwayParameters(self, path): + """ + Import user pathway parameters. + + :parameter path: Required (kwarg str): directory path + """ + import qgrid + self._DefaultPathwayParametersDataFrame = pd.read_csv(path) + col_opts = { 'editable': False, 'sortable':False} + col_defs = {'Value': { 'editable': True, 'width': 150 }} + self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) + return self._DefaultPathwayParametersTable + + def PathwayParametersToCSV(self, path): + """ + Export pathway parameters into CSV format. + + :parameter path: Required (kwarg str): directory path + """ + self._DefaultPathwayParametersTable.get_changed_df().to_csv(path, index=False) + print('saved in:', path) + return + + def Reactions(self): + """ + Display pathway reactions. + """ + from IPython.display import display, HTML + display(HTML("<style>.container {width:90% !important}</style>")) + return pd.read_csv(pathways_path+'/{}_reactions.csv'.format(self._pathway)) + + def Run(self, **kwargs): + """ + Fits of the model to experimental data. + + :parameter expratio: Required (kwargs flt): experimental signalling specie concentration ratio + :parameter target_parameter: Required (kwargs str):kinetic parameter to me modified + :parameter maxiter: Required (kwargs int): maximum number of iteration + :parameter seed: Required (kwargs flt): ramdom seed for scaling the modified parameter + :parameter seed_incrementor: Required (kwargs flt): seed incrementor (each iteration will increment the seed by this value) + :parameter seed_decrementor: Required (kwargs flt): seed decrementor (each iteration will decrement the seed by this value) + + """ + + from scipy.signal import find_peaks + import decimal + #fitting parameters + if 'expratio' in kwargs: + self._expratio = float(kwargs.pop('expratio')) + print('expratio =', self._expratio) + else: raise TypeError("exratio undefined.") + + if 'seed' in kwargs: + self._seed = float(kwargs.pop('seed')) + print('seed =', self._seed) + else: raise TypeError("seed undefined.") + + if 'maxiter' in kwargs: + self._maxiter = int(kwargs.pop('maxiter', 100)) + print('maxiter =', self._maxiter) + + if 'seed_incrementor' in kwargs: + self._seed_incrementor = float(kwargs.pop('seed_incrementor', 0.1)) + print('seed_incrementor =', self._seed_incrementor) + + if 'seed_decrementor' in kwargs: + self._seed_decrementor = float(kwargs.pop('seed_decrementor', 0.1)) + print('seed_decrementor =', self._seed_decrementor) + + if 'target_parameter' in kwargs: + self._target_parameter = str(kwargs.pop('target_parameter')) + print('target_parameter ->', self._target_parameter) + else: raise TypeError("target_parameter undefined.") + + + #Get default pathway parameters + if self._DefaultPathwayParametersDataFrame.empty and self.pathway_parameters==None: + self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) + self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() + + elif self._DefaultPathwayParametersDataFrame.empty is False and self.pathway_parameters is None: + try: + #extract data from qgrid + newparameters = self._DefaultPathwayParametersTable.get_changed_df() + self._PathwayParameters = newparameters.set_index('Parameter').iloc[:,0].to_dict() + except: + self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() + + elif self._DefaultPathwayParametersDataFrame.empty and self.pathway_parameters is not None: + self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) + self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self.pathway_parameters} + + elif self._DefaultPathwayParametersDataFrame.empty is False and self.pathway_parameters is not None: + try: + #extract data from qgrid + newparameters = self._DefaultPathwayParametersTable.get_changed_df() + self._PathwayParameters = {**newparameters.set_index('Parameter').iloc[:,0].to_dict(), **self.pathway_parameters} + except: + self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self.pathway_parameters} + + + + #simulation parameters: + if not self._ttotal: + raise TypeError("simulation parameters unknown. Set the the simulation parameters first wiht set_simulation_parameters()") + + #Main function + mypathway = importlib.import_module('.'+self._pathway, package='ssbtoolkit.pathways') + self.simtime = pl.geomspace(0.00001, self._ttotal, num=self._nsteps) + + #Simulation 1 + pathway_model = mypathway.network(LR=None, kinetics=True, **self._PathwayParameters) + sim1 = ScipyOdeSimulator(pathway_model, tspan=self.simtime,compiler='cython').run() + self.simres1 = sim1.all + + def calc_ratio(self): + + + #Simulation 2 + sim2 = ScipyOdeSimulator(mypathway.network(**self.new_pathway_parameters), tspan=self.simtime, compiler='cython').run() + self.simres2 = sim2.all + + #analysis + obs_name = 'obs_'+self._observable + obs_1 = self.simres1[obs_name] + obs_2 = self.simres2[obs_name] + + if 'time_in' in self.new_pathway_parameters: + self._time = np.take(self.simtime, np.where(self.simtime > int(self.new_pathway_parameters['time_in'])))[0] + obs_curve_1 = np.take(obs_1, np.where(self.simtime > int(self.new_pathway_parameters['time_in'])))[0] + obs_curve_2 = np.take(obs_2, np.where(self.simtime > int(self.new_pathway_parameters['time_in'])))[0] + + else: + self._time = np.take(self.simtime, np.where(self.simtime>0))[0] + obs_curve_1 = np.take(obs_1, np.where(self.simtime > 0))[0] + obs_curve_2 = np.take(obs_2, np.where(self.simtime > 0))[0] + + obs_peaks_1, _ = find_peaks(obs_curve_1) + obs_peaks_2, _ = find_peaks(obs_curve_2) + + vmax_obs_curve_1 = obs_curve_1[obs_peaks_1][-1]*1E3 + vmax_obs_curve_2 = obs_curve_2[obs_peaks_2][-1]*1E3 + + obs_ratio = round(vmax_obs_curve_2/vmax_obs_curve_1, abs(decimal.Decimal(str(self._expratio).rstrip('0')).as_tuple().exponent)) + + self._obs_curve_1=obs_curve_1 + self._obs_curve_2=obs_curve_2 + self._obs_peaks_1=obs_peaks_1 + self._obs_peaks_2=obs_peaks_2 + self._vmax_obs_curve_1=vmax_obs_curve_1 + self._vmax_obs_curve_2=vmax_obs_curve_2 + + return obs_ratio + + self._iteration=1 + print('\n') + + self._lst_ratio=[] + self._lst_seed=[] + + for idx in range(self._maxiter): + + prefix = 'iteration' + iteration_n = str(self._iteration) + print(f'\r{prefix} {iteration_n}', end='\r') + + self.new_pathway_parameters={**self._PathwayParameters, **{self._target_parameter:mypathway.defaultParameters[self._target_parameter]*self._seed}} + self.obs_ratio = calc_ratio(self) + + if self.obs_ratio == self._expratio: + self._lst_ratio.append(self.obs_ratio) + self._lst_seed.append(self._seed) + self._fold=round(self._seed, abs(decimal.Decimal(str(self._expratio).rstrip('0')).as_tuple().exponent)) + print('\n\nDONE!\n', '\nRatio: '+str(self.obs_ratio), '\nFOLD: '+str(self._fold), '\nNumber of iterations: '+str(self._iteration)) + break + elif self.obs_ratio < self._expratio: + + self._lst_ratio.append(self.obs_ratio) + self._lst_seed.append(self._seed) + self._iteration+=1 + self._seed += self._seed_incrementor + + else: + self._lst_ratio.append(self.obs_ratio) + self._lst_seed.append(self._seed) + + + self._iteration+=1 + self._seed -= self._seed_decrementor + + return + + def PlotIterations(self, save=False, filename=None): + ''' + Plot iterations. + ''' + import plotly.offline as pyoff + #dependencies + if self._iteration == None: raise TypeError('Simulation data not exist. simulation.fitModel.run() must be run first.') + + #import plotly + import plotly.graph_objs as go + + iterations = np.arange(1,self._iteration+1) + + trace=dict(type='scatter', x=self._lst_seed, y=self._lst_ratio, mode='markers', + marker=dict(color= iterations, colorscale='Bluered_r', size=14, colorbar=dict(thickness=20, title='iteration number'))) + #axis_style=dict(zeroline=False, showline=True, mirror=True) + layout = dict(title = '', + xaxis = dict( + title = 'seed', + titlefont=dict( + size=20 + ), + tickfont=dict( + size=20 + )), + yaxis = dict( + title = '['+self._observable+']' + ' ratio', + titlefont=dict( + size=20), + tickfont=dict( + size=20) + + ), + legend=dict(font=dict(size=15)), + autosize=False, + width=850, + height=650 + ) + + fig = go.Figure(data=[trace], layout=layout) + if save==True: + if filename==None: + filename='plot.html' + return pyoff.plot(fig, filename=filename) + else: + ext = os.path.splitext(filename)[-1] + if ext == '.png': fig.write_image(filename, scale=3) + elif ext == '.html': pyoff.plot(fig, filename=filename) + else: raise TypeError("extension not valid. Use png or html.") + elif save ==False: return fig + return fig + + def ShowGraphs(self, save=False, filename=None): + ''' + Plot the amount of obeservable in function of time, Amplitude, Area Under the Curve, and Full Width at Half Maximum. + + :parameter save: Optional (kwarg boolean): default False + :parameter filename: Optional (kwarg str) + ''' + + from IPython.core.display import display, HTML + display(HTML("<style>.container { width:90% !important; }</style>")) + + + from plotly.subplots import make_subplots + from scipy.signal import peak_widths + from sklearn import metrics + import plotly.offline as pyoff + + + half_1 = peak_widths(self._obs_curve_1, self._obs_peaks_1, rel_height=0.5) + half_2 = peak_widths(self._obs_curve_2, self._obs_peaks_2, rel_height=0.5) + fwhm_1 = self._time[int(half_1[3])]-self._time[int(half_1[2])] + fwhm_2 = self._time[int(half_2[3])]-self._time[int(half_2[2])] + + + fig = make_subplots(rows=2, cols=2,vertical_spacing=0.15, + subplot_titles=("{} concentration".format(self._observable), "Amplitude", "Area under the curve", "Full Width at Half Maximum")) + + #################### + #### MAIN PLOT #### + #################### + fig.add_trace(go.Scatter(x=self._time, y=self._obs_curve_1*1E3, name='control'), row=1, col=1) + fig.add_trace(go.Scatter(x=self._time, y=self._obs_curve_2*1E3, name='{}-fold'.format(self._fold)), row=1, col=1) + fig.add_trace(go.Scatter(x=self._time[self._obs_peaks_1], y=self._obs_curve_1[self._obs_peaks_1]*1E3, + name='max value', showlegend=False, mode='markers', + marker=dict(symbol='x', size=13, color='Black')), row=1,col=1) + fig.add_trace(go.Scatter(x=self._time[self._obs_peaks_2], y=self._obs_curve_2[self._obs_peaks_2]*1E3, + name='max value', showlegend=False, mode='markers', + marker=dict(symbol='x', size=13, color='Black')), row=1,col=1) + fig.add_shape(type='line', x0=self._time[int(half_1[2])],y0=half_1[1][0]*1E3, x1=self._time[int(half_1[3])], y1=half_1[1][0]*1E3, + line=dict(color='Blue',dash='dash'),xref='x',yref='y', row=1, col=1) + fig.add_shape(type='line', x0=self._time[int(half_2[2])],y0=half_2[1][0]*1E3, x1=self._time[int(half_2[3])], y1=half_2[1][0]*1E3, + line=dict(color='Red',dash='dash'),xref='x',yref='y', row=1, col=1) + + # Update xaxis properties + fig.update_xaxes(title_text="Time (s)", showgrid=False, row=1, col=1, titlefont=dict(size=18), + linecolor='black', linewidth=2, + ticks='inside', tickfont=dict(size=18), tickcolor='black', ticklen=10, tickwidth=2) + + fig.update_yaxes(title_text=self._observable+' (nM)', titlefont=dict(size=18), showgrid=False, row=1, col=1, + linecolor='black', linewidth=2, + ticks='inside', tickfont=dict(size=18), tickcolor='black', ticklen=10, tickwidth=2) + + + #################### + #### AMPLITUDE #### + #################### + + AMP_labels = [1,2] + AMP_values = [self._vmax_obs_curve_1, self._vmax_obs_curve_2] + fig.add_trace(go.Bar(x=AMP_labels,y=AMP_values, width = [0.35,0.35], showlegend=False, marker_color='black', name=''), row=1, col=2 ) + + + + # Update xaxis properties + fig.update_xaxes(row=1, col=2, showgrid=False, linecolor='black', linewidth=2, range=[0,3], + tickmode='array', tickvals=[1,2], ticktext=['control', '{}-fold'.format(self._fold)], tickfont=dict(size=18)) + + fig.update_yaxes(showgrid=False, range=[round((min(AMP_values)-min(AMP_values)*0.5)/5)*5,round((max(AMP_values)+max(AMP_values)*0.5)/5)*5 ], row=1, col=2, + title_text=self._observable+' (nM)', titlefont=dict(size=18), + linecolor='black', linewidth=2, ticks='inside', ticklen=10, tickwidth=2, tickfont=dict(size=18)) + + # Add diff lines + AMP_diffs = [max(AMP_values) - v for v in AMP_values] + AMP_diff_labels = dict(zip(AMP_labels, AMP_diffs)) + fig.add_trace(go.Scatter(name='',x=[1,1.5,2], y=[max(AMP_values)+(max(AMP_values)*0.3)]*3, mode = 'lines+text',showlegend=False, line=dict(color='black', width=1),text=['', 'diff. = {} nM'.format(round(AMP_diffs[0], 3)),''], textposition='top center'), row=1, col=2) + fig.add_trace(go.Scatter(name='',x=[AMP_labels[0]-0.175, AMP_labels[0]+0.175], y=[AMP_values[0]+(AMP_values[0]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) + fig.add_trace(go.Scatter(name='',x=[AMP_labels[1]-0.175, AMP_labels[1]+0.175], y=[AMP_values[1]+(AMP_values[1]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) + fig.add_trace(go.Scatter(name='',x=[AMP_labels[0], AMP_labels[0]], y=[AMP_values[0]+(AMP_values[0]*0.03), max(AMP_values)+(max(AMP_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) + fig.add_trace(go.Scatter(name='',x=[AMP_labels[1], AMP_labels[1]], y=[AMP_values[1]+(AMP_values[1]*0.03), max(AMP_values)+(max(AMP_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) + + + #################### + #### AUC #### + #################### + + # Data + AUC_labels = [1,2] + AUC_values = [round(metrics.auc(self._time, self._obs_curve_1),2), round(metrics.auc(self._time, self._obs_curve_2),2)] + fig.add_trace(go.Bar(x=AUC_labels,y=AUC_values, width = [0.35,0.35], showlegend=False, marker_color='black', name=''), row=2, col=1 ) + + # Update xaxis properties + fig.update_xaxes(row=2, col=1, tickmode='array', showgrid=False, range=[0,3], linecolor='black', linewidth=2, + tickvals=[1,2], ticktext=['control', '{}-fold'.format(self._fold)], tickfont=dict(size=18)) + + fig.update_yaxes(row=2, col=1,showgrid=False, title_text=self._observable+' (nM)', range=[round((min(AUC_values)-min(AUC_values)*0.5)/5)*5,round((max(AUC_values)+max(AUC_values)*0.5)/5)*5], + titlefont=dict(size=18),linecolor='black', linewidth=2, + ticks='inside', tickfont=dict(size=18),ticklen=10, tickwidth=2) + + # Add diff lines + AUC_diffs = [max(AUC_values) - v for v in AUC_values] + AUC_diff_labels = dict(zip(AUC_labels, AUC_diffs)) + fig.add_trace(go.Scatter(name='',x=[1,1.5,2], y=[max(AUC_values)+(max(AUC_values)*0.3)]*3, mode = 'lines+text',showlegend=False, + line=dict(color='black', width=1), text=['', 'diff. = {} nM'.format(round(AUC_diffs[0], 3)),''], textposition='top center'), row=2, col=1) + fig.add_trace(go.Scatter(name='',x=[AUC_labels[0]-0.175, AUC_labels[0]+0.175], y=[AUC_values[0]+(AUC_values[0]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) + fig.add_trace(go.Scatter(name='',x=[AUC_labels[1]-0.175, AUC_labels[1]+0.175], y=[AUC_values[1]+(AUC_values[1]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) + fig.add_trace(go.Scatter(name='',x=[AUC_labels[0], AUC_labels[0]], y=[AUC_values[0]+(AUC_values[0]*0.03), max(AUC_values)+(max(AUC_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) + fig.add_trace(go.Scatter(name='',x=[AUC_labels[1], AUC_labels[1]], y=[AUC_values[1]+(AUC_values[1]*0.03), max(AUC_values)+(max(AUC_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) + + + #################### + #### FWHM #### + #################### + # Data + FWHM_labels = [1,2] + FWHM_values = [fwhm_1, fwhm_2] + fig.add_trace(go.Bar(x=FWHM_labels,y=FWHM_values, width = [0.35,0.35], showlegend=False,marker_color='black', name=''), row=2, col=2 ) + + # Update xaxis properties + fig.update_xaxes(row=2, col=2, showgrid=False, range=[0,3], linecolor='black', linewidth=2, + tickmode='array', tickvals=[1,2], ticktext=['control', '{}-fold'.format(self._fold)], tickfont=dict(size=18)) + + fig.update_yaxes(row=2, col=2, showgrid=False, range=[self.pathway_parameters['time_in'],round((max(FWHM_values)+(max(FWHM_values)-self.pathway_parameters['time_in'])*0.5)/5)*5], + title_text='Time (s)', titlefont=dict(size=18), linecolor='black', linewidth=2, + ticks='inside', ticklen=10, tickwidth=2, tickfont=dict(size=18)) + + # Add diff lines + FWHM_diffs = [max(FWHM_values) - v for v in FWHM_values] + FWHM_diff_labels = dict(zip(FWHM_labels, FWHM_diffs)) + line_height = max(FWHM_values)+((max(FWHM_values)-self.pathway_parameters['time_in'])*0.30) + fig.add_trace(go.Scatter(x=[1,1.5,2], y=[line_height]*3, mode = 'lines+text',showlegend=False, line=dict(color='black', width=1),name='', + text=['', 'diff. = {} s'.format(round(FWHM_diffs[0], 3)),''], textposition='top center'), row=2, col=2) + fig.add_trace(go.Scatter(name='',x=[FWHM_labels[0]-0.175, FWHM_labels[0]+0.175], y=[FWHM_values[0]+(FWHM_values[0]*0.005)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) + fig.add_trace(go.Scatter(name='',x=[FWHM_labels[1]-0.175, FWHM_labels[1]+0.175], y=[FWHM_values[1]+(FWHM_values[1]*0.005)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) + fig.add_trace(go.Scatter(name='',x=[FWHM_labels[0], FWHM_labels[0]], y=[FWHM_values[0]+(FWHM_values[0]*0.005), line_height], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) + fig.add_trace(go.Scatter(name='',x=[FWHM_labels[1], FWHM_labels[1]], y=[FWHM_values[1]+(FWHM_values[1]*0.005), line_height], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) + + + #################### + #### FIGURE #### + #################### + + fig.update_layout(height=1200, width=1300, title_text="", plot_bgcolor='white',showlegend=True, + legend=dict(yanchor="top", x=0.3, y=.99,font=dict(family="sans-serif", size=14,color="black"))) + fig.update_annotations(font_size=20, font_color='black') + + if save==True: + if filename==None: + filename='plot.html' + return pyoff.plot(fig, filename=filename) + else: + ext = os.path.splitext(filename)[-1] + if ext == '.png': fig.write_image(filename, scale=3) + elif ext == '.html': pyoff.plot(fig, filename=filename) + else: raise TypeError("extension not valid. Use png or html.") + elif save ==False: return fig + + return + + diff --git a/ssbtoolkit/__init__.py b/ssbtoolkit/__init__.py deleted file mode 100644 index 4e42005d5661a52abaaeeaa9c967d36b375fe46d..0000000000000000000000000000000000000000 --- a/ssbtoolkit/__init__.py +++ /dev/null @@ -1,1414 +0,0 @@ -import pkgutil - -__all__ = [] -for loader, module_name, is_pkg in pkgutil.walk_packages(__path__): - __all__.append(module_name) - _module = loader.find_module(module_name).load_module(module_name) - globals()[module_name] = _module - - -import sys, os, warnings -sys.path.insert(0, os.path.abspath(os.path.split(os.path.realpath(__file__))[0])) -warnings.simplefilter(action='ignore') - - - - -import platform, site -distpath = site.getsitepackages()[0] -if platform.system() == 'Linux': - BioNetGen=os.path.join(distpath, 'bionetgen/bng-linux:') -elif platform.system() == 'Darwin': - BioNetGen=os.path.join(distpath, 'bionetgen/bng-mac:') -elif platform.system()=='Windows': - BioNetGen=os.path.join(distpath, 'bionetgen/bng-win:') -else: - raise ValueError('BioNetGen error. Platform unknown! The pygomodo was tested in Linux and Darwin (Mac) platforms.') -os.environ['PATH']=BioNetGen+os.environ['PATH'] - - -#LIBRARIES -import importlib -import pylab as pl -from pysb.simulator import ScipyOdeSimulator -from scipy.optimize import curve_fit -from sklearn.preprocessing import minmax_scale -import plotly.graph_objs as go -import pandas as pd -import numpy as np -import ssbtoolkit.Utils as utils - -pathways_path=(os.path.join(os.path.split(os.path.realpath(__file__))[0], 'pathways')) - -######MAIN CODE##### -class Binding: - """This class simulate ligand-target binding curves.""" - def __init__(self): - self.receptor_conc = None - self.lig_conc_range = None - self.pKd = None - self.submax_concentration = None - - def Bind(self, **kwargs): - """ - Applies an function to calculate the fraction of occupited receptors at equilibrium. - - :parameter receptor_conc: Required (kwarg flt): concentration of receptor - :parameter lig_conc_range: Required (kwarg array): array of range of ligand concentration - :parameter pKd: Required (kwarg flt): pKd value of the ligand - """ - - if 'receptor_conc' not in kwargs: raise TypeError("ERROR: receptor_conc is missing") - if 'lig_conc_range' not in kwargs: raise TypeError("ERROR: lig_conc_range is missing") - if 'pKd' not in kwargs: raise TypeError("ERROR: pKd is missing") - - self._receptor_conc = kwargs.pop('receptor_conc') - self._lig_conc_range = kwargs.pop('lig_conc_range') - self._pKd = kwargs.pop('pKd') - - binding_data=[] - for conc in self._lig_conc_range: - binding_data.append(utils.CalcOccupancy(self._receptor_conc, conc, 0, self._pKd, 0)) - self.binding_data=binding_data - return self.binding_data - - def SubMaxConcentration(self): - """ - Calculates the maximum bending point of a sigmoid-shaped curve according to the mathod of Sebaugh et al., 2003. - - :parameter drug_receptor: Required (int): concentration of the receptor - :parameter lig_conc_range: Required (array): array of a range of ligand concentration - :return: instance .submax_concentration (flt) - - .. note:: The minimization uses the Nelder-Mead method. - """ - - from scipy.optimize import curve_fit, minimize - - - def sigmoid(X, Bottom, Top, Kd, p): - return Bottom + (Top-Bottom)/(1+np.power((Kd/X),p)) - - xfit = np.geomspace(np.min(self._lig_conc_range), np.max(self._lig_conc_range), 50000) #warning: shoud this be the minimum and maximum of concentration - popt, pcov = curve_fit(sigmoid, self._lig_conc_range, self.binding_data, bounds=([np.min(self.binding_data),-np.inf,-np.inf, 0.5],[np.inf,np.max(self.binding_data),np.inf, 2.5])) - - - def sigmoid_deriv_b(x, a,d,c,b): - return (x/c)**b*(a - d)*np.log(x/c)/((x/c)**b + 1)**2 - - min_value = minimize(sigmoid_deriv_b, np.max(xfit), args=(popt[0],popt[1],popt[2],popt[3]), method = 'Nelder-Mead') - - self.submax_concentration = round(min_value.x[0],3) - return self.submax_concentration - - def ShowCurve(self): - """ - Plots ligand-target binding curve - """ - - #import plotly - import plotly.graph_objs as go - from scipy.optimize import curve_fit - from sklearn.preprocessing import minmax_scale - - ##Fitting curve to the data - - yy = minmax_scale(self.binding_data)*100 - - def equation_dose(X, Bottom, Top, EC50, p): - return Bottom + (Top-Bottom)/(1+np.power((EC50/X),p)) - - popt, pcov = curve_fit(equation_dose, self._lig_conc_range, yy, bounds=([np.min(yy),-np.inf,-np.inf, 0.5],[np.inf,np.max(yy),np.inf, 2.5])) - - xfit = np.geomspace(np.min(self._lig_conc_range), np.max(self._lig_conc_range), 50000) # These values are the same as the values for the simulation time and not ligand concentration - yfit = minmax_scale(equation_dose(xfit, *popt))*100 - - - - trace1 = go.Line(x=xfit, y=yfit, showlegend=False, name='radioligand') - if self.submax_concentration: - xsubmaximal = np.array(self.submax_concentration) - ysubmaximal = np.array(equation_dose(xsubmaximal, *popt)) - trace2 = go.Scatter(x=xsubmaximal, y=ysubmaximal, showlegend=True, mode='markers', name='submaximal ({} μM)'.format(xsubmaximal), - marker=dict(size=14)) - else: trace2=[] - - - layout = dict(title = '', - xaxis = dict( - title = '[ligand] μM', - type ='log', - exponentformat='e', - titlefont=dict( - size=20 - ), - tickfont=dict( - size=20 - )), - yaxis = dict( - title = '% occupied receptors', - - titlefont=dict( - size=20), - tickfont=dict( - size=20) - - ), - legend=dict(font=dict(size=15)), - autosize=False, - width=850, - height=650, - ) - if self.submax_concentration: - fig = go.Figure(data=[trace1, trace2], layout=layout) - else: - fig = go.Figure(data=[trace1], layout=layout) - return fig - -class Simulation: - """ - This class simulates the mathematical models of the signaling pathways. - """ - class Activation: - """ - Simulation of the activation of signaling pathways (i.e. activation by agonists) - """ - def __init__(self): - self._ligands=None - self._affinities=None - self._pathway=None - self._receptor_conc=None - self._lig_conc_range=None - self._ttotal=None - self._nsteps=None - self._binding_kinetics=True - self._binding_kinetic_parameters=None - self.simulation_data=None - self.processed_data=None - - def SetSimulationParameters(self, **kwargs): - """ - :parameter ligands: Required (kwargs list): list of ligands' names (str) - :parameter affinities: Required (kwargs list): list of pKd values (flt) - :parameter pathway: Required (kwargs str): name of the pathway ('Gs', 'Gi', 'Gq') - :parameter receptor_conc: Required (kwargs flt): receptors concentration (nM) - :parameter lig_conc_range: Required (kwargs array): range of ligands' concentration - :parameter ttotal: Required (kwargs int): simulation time (seconds) - :parameter nsteps: Required (kwargs int): simulation time step - :parameter binding_kinetics: Optional (kwargs boolean): default (False) - - - .. warning:: the order of the lists of ligands names and affinities list must be the same. - - """ - self._ligands= kwargs.pop('ligands') - if 'affinities' in kwargs: - self._affinities=kwargs.pop('affinities') - self._pathway=kwargs.pop('pathway') - self._receptor_conc=kwargs.pop('receptor_conc') - self._lig_conc_range=kwargs.pop('lig_conc_range') - self._ttotal=kwargs.pop('ttotal') - self._nsteps=kwargs.pop('nsteps') - self._binding_kinetics=kwargs.pop('binding_kinetics') - if 'binding_kinetic_parameters' in kwargs:self._binding_kinetic_parameters=kwargs.pop('binding_kinetic_parameters') - self._DefaultPathwayParametersDataFrame=pd.DataFrame() - - return - - def PathwayParameters(self): - """ - Display table with default pathway parameters. - - .. warning:: this functions requires the qgrid library. It doens't work on Google Colab. - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) - - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def UserPathwayParameters(self, path): - """ - Import user pathway parameters. - - :parameter path: Required (kwarg str): directory path - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv(path) - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def PathwayParametersToCSV(self, path): - """ - Export pathway parameters into CSV format. - - :parameter path: Required (kwarg str): directory path - """ - self._DefaultPathwayParametersTable.get_changed_df().to_csv(path, index=False) - print('saved in:', path) - return - - def Reactions(self): - """ - Display pathway reactions. - """ - from IPython.display import display, HTML - display(HTML("<style>.container {width:90% !important}</style>")) - return pd.read_csv(pathways_path+'/{}_reactions.csv'.format(self._pathway)) - - def Run(self): - ''' - This function runs the pathway simulation and returns the raw simulation data. - ''' - - #Check inputs - if self._ligands==None: raise TypeError("ligands list undefined.") - elif self._pathway==None: raise TypeError("pathway name undefined.") - elif self._binding_kinetics==False and self._affinities==None: raise TypeError("affinity_values_dict undefined.") - elif self._binding_kinetics==True and self._affinities==None: pass - elif self._lig_conc_range.any() == False: raise TypeError("lig_conc_range undefined.") - elif self._ttotal==None: raise TypeError("ttotal undefined.") - elif self._nsteps==None: raise TypeError("nsteps undefined.") - elif self._receptor_conc==None: raise TypeError("receptor_conc undefined.") - else: pass - - - #Check Pathway availability and import it - available_pathways = ['Gs', 'Gi', 'Gq'] - if self._pathway == 'Gz(Gi)': self._pathway = 'Gi' - if self._pathway not in available_pathways: raise Exception('Unvailable Pathway. Please, introduce it manually. Pathways available: "Gs", "Gi", "Gq".') - mypathway = importlib.import_module('.'+self._pathway, package='ssbtoolkit.pathways') - - #Get default pathway parameters - if self._DefaultPathwayParametersDataFrame.empty and self._binding_kinetic_parameters==None: - self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty is False and self._binding_kinetic_parameters is None: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = newparameters.set_index('Parameter').iloc[:,0].to_dict() - except: - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty and self._binding_kinetic_parameters is not None: - self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) - - elif self._DefaultPathwayParametersDataFrame.empty is False and self._binding_kinetic_parameters is not None: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = {**newparameters.set_index('Parameter').iloc[:,0].to_dict(), **self._binding_kinetic_parameters} - except: - self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self._binding_kinetic_parameters} - - #Input - t = pl.geomspace(0.00001, self._ttotal, num=self._nsteps) # (a,b,c); a is the starting time ; b is the total time simulated ; c is the number of points - - - #Output - simulation_data={} - - #Function - for ligand in self._ligands: - ligand_name = os.path.splitext(str(ligand))[0] - data=[] - utils.PrintProgressBar(0, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) - - ###DANGER ZONE### - if self._binding_kinetic_parameters is not None: - self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self._binding_kinetic_parameters[self._ligands.index(ligand)]} - ###################### - - for idx in range(len(self._lig_conc_range)): - - ligand_conc = self._lig_conc_range[idx] - if self._binding_kinetics == False: - #get LR conc - parameters = {**self._PathwayParameters, 'R_init':self._receptor_conc} - LR_conc_init = utils.CalcOccupancy(self._receptor_conc, ligand_conc, 0, self._affinities[self._ligands.index(ligand)], 0) - mymodel = mypathway.network(LR=LR_conc_init, kinetics=False, **parameters) - simres = ScipyOdeSimulator(mymodel, tspan=t, compiler='cython').run() - yout = simres.all - - elif self._binding_kinetics == True: - parameters={**self._PathwayParameters,'R_init':self._receptor_conc, 'L_init':self._lig_conc_range[idx] } - mymodel = mypathway.network(kinetics=True, **parameters) - simres = ScipyOdeSimulator(mymodel, tspan=t, compiler='cython').run() - yout = simres.all - - d1={'ligand_conc':ligand_conc, 'time':t } - - for idx2 in range(len(mypathway.list_of_observables)): - d2={mypathway.list_of_observables[idx2]:yout[mypathway.list_of_observables[idx2]]} - d1.update(d2) - data.append(d1) - utils.PrintProgressBar(idx + 1, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) - - - simulation_data[ligand_name] = {'sim_data':data, - 'label':ligand_name,} - self.simulation_data = simulation_data - return - - def Analysis(self): - ''' - This function calculates the dose-response effect. - - :return: instance of processed_data - ''' - - if self.simulation_data == None: raise TypeError('There is no simulation data. simulation.activation.run() must be run first.') - - # Define all the lists and dictionaries used in this function - raw_data=[] - normalized_data=[] - dose={} - - #defining concentration range - lig_conc_min = self._lig_conc_range.min() - lig_conc_max = self._lig_conc_range.max() - - #Main function - for ligand in self.simulation_data: - - #definig and dictionaries used in this loop: - raw_data_dict={} - normalized_data_dict={} - - # Calculate dose-response curve - #get metabolite concentration, rescale, and transform data if pathway/metabolite decrease - # metabolite_raw is not normalized - if self._pathway == 'Gi' or self._pathway == 'Gz(Gi)': - metabolite='cAMP' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(1-np.array(metabolite_conc_raw)) - elif self._pathway == 'Gs': - metabolite='cAMP' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) - elif self._pathway == 'Gq': - metabolite='IP3' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) - else: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') - - - ## save results - raw_data_dict['x']=self._lig_conc_range - raw_data_dict['y']=metabolite_conc_raw - raw_data_dict['label']=self.simulation_data[ligand]['label'] - - normalized_data_dict['x']=self._lig_conc_range - normalized_data_dict['y']=metabolite_conc_norm - normalized_data_dict['label']=self.simulation_data[ligand]['label'] - - ## create a list of all data - raw_data.append(raw_data_dict) - normalized_data.append(normalized_data_dict) - - ##Fitting curve to the data - - def equation_dose(X, Bottom, Top, EC50, p): - return Bottom + (Top-Bottom)/(1+np.power((EC50/X),p)) - - popt_EC50, pcov = curve_fit(equation_dose, self._lig_conc_range, metabolite_conc_norm, bounds=([np.min(metabolite_conc_norm),-np.inf,-np.inf, 0.5],[np.inf,np.max(metabolite_conc_norm),np.inf, 2.5])) - - xfit_EC50 = np.geomspace(lig_conc_min, lig_conc_max, 50000) # These values are the same as the values for the simulation time and not ligand concentration - yfit_EC50 = equation_dose(xfit_EC50, *popt_EC50) - - fit_EC50={'x':xfit_EC50, 'y':yfit_EC50, 'label':self.simulation_data[ligand]['label']} - - dose[ligand] = {'raw_data': raw_data_dict, - 'normalized_data':normalized_data_dict , - 'fitted_data': fit_EC50, - 'EC50 (μM)': round(popt_EC50[2],5), - 'pEC50': round(-np.log10(popt_EC50[2]*1E-6),2)} - - self.processed_data=dose - return - - def ShowCurve(self, save=False, filename=None): - ''' - Plots the dose-response curve. - ''' - - if self.simulation_data == None: raise TypeError('There is no simulation data. simulation.activation.run() must be run first.') - - import plotly - import plotly.graph_objs as go - import plotly.offline as pyoff - - colors = plotly.colors.DEFAULT_PLOTLY_COLORS - - plot_data=[] - - color_id=0 - for ligand in self.processed_data: - trace_norm = go.Scatter(x=self.processed_data[ligand]['normalized_data']['x'], - y=minmax_scale(self.processed_data[ligand]['normalized_data']['y'])*100 , - mode='markers', - showlegend=True, - name=self.processed_data[ligand]['normalized_data']['label'], - marker=dict(color=colors[color_id])) - plot_data.append(trace_norm) - - trace_fitted = go.Scatter(x=self.processed_data[ligand]['fitted_data']['x'], - y=minmax_scale(self.processed_data[ligand]['fitted_data']['y'])*100, - mode='lines', - showlegend=False, - name=self.processed_data[ligand]['fitted_data']['label'], - line=dict(color=colors[color_id])) - plot_data.append(trace_fitted) - color_id +=1 - - layout = dict(title = '', - xaxis = dict( - title = '[ligand] μM', - type ='log', - #range = [-3, 2], - exponentformat='e', - titlefont=dict( - size=20 - ), - tickfont=dict( - size=20 - )), - yaxis = dict( - title = '% Response', - #range = [0, 100], - titlefont=dict( - size=20), - tickfont=dict( - size=20) - - ), - legend=dict(font=dict(size=15)), - autosize=False, - width=850, - height=650, - ) - - fig = go.Figure(data=plot_data, layout=layout) - #fig['layout']['yaxis'].update(autorange = True) - - if save==True: - if filename==None: - filename='plot.html' - return pyoff.plot(fig, filename=filename) - else: - ext = os.path.splitext(filename)[-1] - if ext == '.png': fig.write_image(filename, scale=3) - elif ext == '.html': pyoff.plot(fig, filename=filename) - else: raise TypeError("extension not valid. Use png or html.") - elif save ==False: return fig - return - - def ShowPotency(self): - ''' - Return the potency values as a pandas DataFrame. - ''' - import pandas as pd - data = Simulation.Activation.PotencyToDict(self) - df = pd.DataFrame.from_dict(data, orient='index') - return df - - def PotencyToDict(self): - ''' - Convert potencies into a dictionary. - ''' - - #dependencies - if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.activation.analysis() must be run first.') - - kvalues={} - for ligand in self.processed_data: - IC50 = list(self.processed_data[ligand].keys())[-2] - IC50_value = self.processed_data[ligand][IC50] - pIC50 = list(self.processed_data[ligand].keys())[-1] - pIC50_value = self.processed_data[ligand][pIC50] - kvalues[ligand]={IC50:IC50_value, pIC50:pIC50_value} - return kvalues - - def PotencyToCSV(self, path): - ''' - Exports the potency values into csv format. - - :parameter path: Required (kwarg str): directory path to save the csv file - ''' - - data = Simulation.Activation.PotencyToDict(self) - df = pd.DataFrame.from_dict(data, orient='index') - df.to_csv(path, index=False) - return - - class Inhibition: - """ - Simulation of the inhibition of signaling pathways (i.e. inhibition by antagonists). - """ - def __init__(self): - self._agonist=None - self._agonist_affinity=None - self._agonist_submaximal_conc=None - self._antagonists=None - self._antagonists_affinities=None - self._pathway=None - self._receptor_conc=None - self._lig_conc_range=None - self._ttotal=None - self._nsteps=None - self._binding_kinetics=False - self._binding_kinetic_parameters=None - self.simulation_data=None - self.processed_data=None - - def SetSimulationParameters(self, **kwargs): - """ - :parameter agonist: Required (kwargs str): agonist name - :parameter agonist_affinity: Required (kwargs flt): agonist pKd value - :parameter agonist_submaximal_conc: Required (kwargs flt): agonist submaximal concentration - :parameter antagonists: Required (kwargs list):list of antagonists names (str) - :parameter antagonists_affinities: Required (kwargs list): list of antagonists affinity values (flt) - :parameter antagonists_conc_range: Required (kwargs array): range of ligands' concentration (nM) - :parameter pathway: Required (kwargs str): name of the pathway ('Gs', 'Gi', 'Gq') - :parameter receptor_conc: Required (kwargs flt): receptors concentration (nM) - :parameter ttotal: Required (kwargs int): simulation time (seconds) - :parameter nsteps: Required (kwargs int): simulation time step - :parameter kinetics: Optional (kwargs boolean): default (False) - - - :return: instances of all parameters - - .. warning:: the order of the lists of the antagonists names and affinities list must be the same. - - """ - self._agonist= kwargs.pop('agonist') - self._agonist_affinity=kwargs.pop('agonist_affinity') - self._agonist_submaximal_conc=kwargs.pop('agonist_submaximal_conc') - self._antagonists=kwargs.pop('antagonists') - self._antagonists_affinities=kwargs.pop('antagonists_affinities') - self._pathway=kwargs.pop('pathway') - self._receptor_conc=kwargs.pop('receptor_conc') - self._lig_conc_range=kwargs.pop('lig_conc_range') - self._ttotal=kwargs.pop('ttotal') - self._nsteps=kwargs.pop('nsteps') - if 'kinetics' in kwargs: - self._binding_kinetics=kwargs.pop('kinetics') - if self._binding_kinetics==True: raise TypeError("The of Kinetic parameters during an inhibition simulation it is not supported yet.") - else: self._binding_kinetics=False - if 'binding_kinetic_parameters' in kwargs: - self._binding_kinetic_parameters=kwargs.pop('binding_kinetic_parameters') - self._DefaultPathwayParametersDataFrame=pd.DataFrame() - - return - - def PathwayParameters(self): - """ - Display table with default pathway parameters. - - .. warning:: this functions requires the qgrid library. It doens't work on Google Colab. - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) - - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def UserPathwayParameters(self, path): - """ - Import user pathway parameters. - - :parameter path: Required (kwarg str): directory path - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv(path) - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def PathwayParametersToCSV(self, path): - """ - Export pathway parameters into CSV format. - - :parameter path: Required (kwarg str): directory path - """ - self._DefaultPathwayParametersTable.get_changed_df().to_csv(path, index=False) - print('saved in:', path) - return - - def Reactions(self): - """ - Display pathway reactions. - """ - from IPython.display import display, HTML - display(HTML("<style>.container {width:90% !important}</style>")) - return pd.read_csv(pathways_path+'/{}_reactions.csv'.format(self._pathway)) - - def Run(self): - ''' - This function runs the pathway simulation and returns the raw simulation data. - ''' - - #Check inputs - if self._agonist==None: raise TypeError("agonist undefined.") - elif self._agonist_affinity==None: raise TypeError("agonist_affinity undifined.") - elif self._antagonists==None: raise TypeError("antagonists list undefined.") - elif self._antagonists_affinities==None: raise TypeError("antagonists affinity values undefined.") - elif self._pathway==None: raise TypeError("pathway undefined.") - elif self._lig_conc_range.any() == False: raise TypeError("lig_conc_range undefined.") - elif self._agonist_submaximal_conc == None: raise TypeError("agonist_submaximal_conc undifined.") - elif self._ttotal==None: raise TypeError("ttotal undefined.") - elif self._nsteps==None: raise TypeError("nsteps undefined.") - elif self._receptor_conc==None: raise TypeError("receptor_conc undefined.") - elif self._binding_kinetics==True: raise TypeError("The of Kinetic parameters during an inhibition simulation it is not supported yet.") - else: pass - - #check pathway - available_pathways = ['Gs', 'Gi', 'Gq'] - if self._pathway == 'Gz(Gi)': self._pathway = 'Gi' - if self._pathway not in available_pathways: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') - mypathway = importlib.import_module('.'+self._pathway, package='ssbtoolkit.pathways') - - #Get default pathway parameters - if self._DefaultPathwayParametersDataFrame.empty: - self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty is False: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = newparameters.set_index('Parameter').iloc[:,0].to_dict() - except: - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - #Input - t = pl.geomspace(0.00001, self._ttotal, num=self._nsteps) # (a,b,c); a is the starting time ; b is the total time simulated ; c is the number of points - - #Output - simulation_data={} - - #Function - for ligand in self._antagonists: - ligand_name = os.path.splitext(ligand)[0] - data=[] - utils.PrintProgressBar(0, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) - - for idx in range(len(self._lig_conc_range)): - - ligand_conc = self._lig_conc_range[idx] - - #get LR conc - parameters = {**self._PathwayParameters, 'R_init':self._receptor_conc} - LR_conc_init = utils.CalcOccupancy(self._receptor_conc, self._agonist_submaximal_conc, ligand_conc, self._agonist_affinity, self._antagonists_affinities[self._antagonists.index(ligand)]) - mymodel = mypathway.network(LR=LR_conc_init, kinetics=False, **parameters) - simres = ScipyOdeSimulator(mymodel, tspan=t, compiler='cython').run() - yout = simres.all - - d1={'ligand_conc':ligand_conc, 'time':t } - - for idx2 in range(len(mypathway.list_of_observables)): - d2={mypathway.list_of_observables[idx2]:yout[mypathway.list_of_observables[idx2]]} - d1.update(d2) - data.append(d1) - utils.PrintProgressBar(idx + 1, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) - - simulation_data[ligand_name] = {'sim_data':data, - 'label':self._agonist+' + ' + ligand_name} - - self.simulation_data=simulation_data - return - - def Analysis(self): - ''' - This function calculates the dose-response effect. - - :return: instance processed_data - ''' - #dependencies - if self.simulation_data == None: raise TypeError('There is no simulation data. simulation.inhibition.run() must be run first.') - - # Define all the lists and dictionaries used in this function - raw_data=[] - normalized_data=[] - dose={} - - #defining concentration range - #defining concentration range - lig_conc_min = self._lig_conc_range.min() - lig_conc_max = self._lig_conc_range.max() - - #Main function - for ligand in self.simulation_data: - - #definig and dictionaries used in this loop: - raw_data_dict={} - normalized_data_dict={} - - # Calculate dose-response curve - #get metabolite concentration, rescale, and transform data if pathway/metabolite decrease - # metabolite_raw is not normalized - if self._pathway == 'Gi' or self._pathway == 'Gz(Gi)': - metabolite='cAMP' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(1-np.array(metabolite_conc_raw)) - elif self._pathway == 'Gs': - metabolite='cAMP' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) - elif self._pathway == 'Gq': - metabolite='IP3' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) - else: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') - - - ## save results - raw_data_dict['x']=self._lig_conc_range - raw_data_dict['y']=metabolite_conc_raw - raw_data_dict['label']=self.simulation_data[ligand]['label'] - - normalized_data_dict['x']=self._lig_conc_range - normalized_data_dict['y']=metabolite_conc_norm - normalized_data_dict['label']=self.simulation_data[ligand]['label'] - - ## create a list of all data - raw_data.append(raw_data_dict) - normalized_data.append(normalized_data_dict) - - ##Fitting curve to the data - - def equation_dose(X, Bottom, Top, EC50, p): - return Bottom + (Top-Bottom)/(1+np.power((EC50/X),p)) - - popt_IC50, pcov = curve_fit(equation_dose, self._lig_conc_range, metabolite_conc_norm, bounds=([np.min(metabolite_conc_norm),-np.inf,-np.inf, 0.5],[np.inf,np.max(metabolite_conc_norm),np.inf, 2.5])) - - xfit_IC50 = np.geomspace(lig_conc_min, lig_conc_max, 50000) # These values are the same as the values for the simulation time and not ligand concentration - yfit_IC50 = equation_dose(xfit_IC50, *popt_IC50) - - fit_IC50={'x':xfit_IC50, 'y':yfit_IC50, 'label':self.simulation_data[ligand]['label']} - - dose[ligand] = {'raw_data': raw_data_dict, - 'normalized_data':normalized_data_dict , - 'fitted_data': fit_IC50, - 'IC50 (μM)': round(popt_IC50[2],5), - 'pIC50': round(-np.log10(popt_IC50[2]*1E-6),2)} - - self.processed_data=dose - return - - def ShowCurve(self, save=False, filename=None): - ''' - Plot the dose-response curve. - ''' - #dependencies - if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.inhibition.analysis() must be run first.') - - import plotly - import plotly.graph_objs as go - import plotly.offline as pyoff - - colors = plotly.colors.DEFAULT_PLOTLY_COLORS - - plot_data=[] - - color_id=0 - for ligand in self.processed_data: - trace_norm = go.Scatter(x=self.processed_data[ligand]['normalized_data']['x'], - y=minmax_scale(self.processed_data[ligand]['normalized_data']['y'])*100 , - mode='markers', - showlegend=True, - name=self.processed_data[ligand]['normalized_data']['label'], - marker=dict(color=colors[color_id])) - plot_data.append(trace_norm) - - trace_fitted = go.Scatter(x=self.processed_data[ligand]['fitted_data']['x'], - y=minmax_scale(self.processed_data[ligand]['fitted_data']['y'])*100, - mode='lines', - showlegend=False, - name=self.processed_data[ligand]['fitted_data']['label'], - line=dict(color=colors[color_id])) - plot_data.append(trace_fitted) - color_id +=1 - - layout = dict(title = '', - xaxis = dict( - title = '[ligand] μM', - type ='log', - #range = [-4, 2], - exponentformat='e', - titlefont=dict( - size=20 - ), - tickfont=dict( - size=20 - )), - yaxis = dict( - title = '% Response', - #range = [0, 100], - titlefont=dict( - size=20), - tickfont=dict( - size=20) - - ), - legend=dict(font=dict(size=15)), - autosize=False, - width=850, - height=650, - ) - - fig = go.Figure(data=plot_data, layout=layout) - if save==True: - if filename==None: - filename='plot.html' - return pyoff.plot(fig, filename=filename) - else: - ext = os.path.splitext(filename)[-1] - if ext == '.png': fig.write_image(filename, scale=3) - elif ext == '.html': pyoff.plot(fig, filename=filename) - else: raise TypeError("extension not valid. Use png or html.") - elif save ==False: return fig - return - - def ShowPotency(self): - ''' - Return the potency values as a pandas DataFrame. - ''' - import pandas as pd - data = Simulation.Inhibition.PotencyToDict(self) - df = pd.DataFrame.from_dict(data, orient='index') - return df - - def PotencyToDict(self): - ''' - Convert potencies into a dictionary. - ''' - #dependencies - if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.inhibition.analysis() must be run first.') - - kvalues={} - for ligand in self.processed_data: - IC50 = list(self.processed_data[ligand].keys())[-2] - IC50_value = self.processed_data[ligand][IC50] - pIC50 = list(self.processed_data[ligand].keys())[-1] - pIC50_value = self.processed_data[ligand][pIC50] - kvalues[ligand]={IC50:IC50_value, pIC50:pIC50_value} - return kvalues - - def PotencyToCSV(self, path): - ''' - Exports the potency values into csv format. - - :parameter path: Required (kwarg str): directory path to save the csv file - ''' - data = Simulation.Inhibition.PotencyToDict(self) - df = pd.DataFrame.from_dict(data, orient='index') - df.to_csv(path, index=False) - return - - class FitModel: - """ - Fit a model to experimental data. - - .. note:: This class was developed to reproduce data from a specific experimental setup. Please see tutorial 4 (OXTR pathay). Use carefully! - """ - def __init__(self): - - #fitting parameters - self._expratio = None - self._seed = None - self._maxiter = None - self._seed_incrementor = None - self._target_parameter = None - - #Pathway parameters - self._ttotal = None - self._nsteps = None - self._pathway = None - self._observable = None - self.pathway_parameters = {} - - def SetSimulationParameters(self, **kwargs): - """ - :parameter pathway_parameters: Required (kwargs): dict of pathway parameters - :parameter pathway: Required (kwargs str): name of the pathway ('Gs', 'Gi', 'Gq') - :parameter ttotal: Required (kwargs int): simulation time (seconds) - :parameter nsteps: Required (kwargs int): simulation time step - :parameter observable: Required (kwargs str): molecular specie to be measured - - :return: instances of all parameters - - """ - - if 'pathway_parameters' in kwargs: - self.pathway_parameters = kwargs.pop('pathway_parameters') - #print('pathway_parameters YES') - self._DefaultPathwayParametersDataFrame=pd.DataFrame() - if 'ttotal' in kwargs: - self._ttotal = int(kwargs.pop('ttotal')) - print('ttotal =', self._ttotal) - else: raise TypeError("ttotal undefined.") - - if 'nsteps' in kwargs: - self._nsteps = int(kwargs.pop('nsteps', 1000)) - print('nsteps =', self._nsteps) - - if 'pathway' in kwargs: - self._pathway = str(kwargs.pop('pathway')) - print('pathway ->', self._pathway) - else: raise TypeError("pathway undefined.") - - available_pathways = ['Gs', 'Gi', 'Gq', 'OXTR_pathway'] - if self._pathway == 'Gz(Gi)': self._pathway = 'Gi' - if self._pathway not in available_pathways: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') - - - if'observable' in kwargs: - self._observable = str(kwargs.pop('observable')) - print('observable ->', self._observable) - else: raise TypeError("observable undefined.") - - return - - def PathwayParameters(self): - """ - Display table with default pathway parameters. - - .. warning:: this functions requires the qgrid library. It doens't work on Google Colab. - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) - - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def UserPathwayParameters(self, path): - """ - Import user pathway parameters. - - :parameter path: Required (kwarg str): directory path - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv(path) - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def PathwayParametersToCSV(self, path): - """ - Export pathway parameters into CSV format. - - :parameter path: Required (kwarg str): directory path - """ - self._DefaultPathwayParametersTable.get_changed_df().to_csv(path, index=False) - print('saved in:', path) - return - - def Reactions(self): - """ - Display pathway reactions. - """ - from IPython.display import display, HTML - display(HTML("<style>.container {width:90% !important}</style>")) - return pd.read_csv(pathways_path+'/{}_reactions.csv'.format(self._pathway)) - - def Run(self, **kwargs): - """ - Fits of the model to experimental data. - - :parameter expratio: Required (kwargs flt): experimental signalling specie concentration ratio - :parameter target_parameter: Required (kwargs str):kinetic parameter to me modified - :parameter maxiter: Required (kwargs int): maximum number of iteration - :parameter seed: Required (kwargs flt): ramdom seed for scaling the modified parameter - :parameter seed_incrementor: Required (kwargs flt): seed incrementor (each iteration will increment the seed by this value) - :parameter seed_decrementor: Required (kwargs flt): seed decrementor (each iteration will decrement the seed by this value) - - """ - - from scipy.signal import find_peaks - import decimal - #fitting parameters - if 'expratio' in kwargs: - self._expratio = float(kwargs.pop('expratio')) - print('expratio =', self._expratio) - else: raise TypeError("exratio undefined.") - - if 'seed' in kwargs: - self._seed = float(kwargs.pop('seed')) - print('seed =', self._seed) - else: raise TypeError("seed undefined.") - - if 'maxiter' in kwargs: - self._maxiter = int(kwargs.pop('maxiter', 100)) - print('maxiter =', self._maxiter) - - if 'seed_incrementor' in kwargs: - self._seed_incrementor = float(kwargs.pop('seed_incrementor', 0.1)) - print('seed_incrementor =', self._seed_incrementor) - - if 'seed_decrementor' in kwargs: - self._seed_decrementor = float(kwargs.pop('seed_decrementor', 0.1)) - print('seed_decrementor =', self._seed_decrementor) - - if 'target_parameter' in kwargs: - self._target_parameter = str(kwargs.pop('target_parameter')) - print('target_parameter ->', self._target_parameter) - else: raise TypeError("target_parameter undefined.") - - - #Get default pathway parameters - if self._DefaultPathwayParametersDataFrame.empty and self.pathway_parameters==None: - self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty is False and self.pathway_parameters is None: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = newparameters.set_index('Parameter').iloc[:,0].to_dict() - except: - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty and self.pathway_parameters is not None: - self._DefaultPathwayParametersDataFrame = pd.read_csv(pathways_path+'/{}_parameters.csv'.format(self._pathway)) - self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self.pathway_parameters} - - elif self._DefaultPathwayParametersDataFrame.empty is False and self.pathway_parameters is not None: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = {**newparameters.set_index('Parameter').iloc[:,0].to_dict(), **self.pathway_parameters} - except: - self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self.pathway_parameters} - - - - #simulation parameters: - if not self._ttotal: - raise TypeError("simulation parameters unknown. Set the the simulation parameters first wiht set_simulation_parameters()") - - #Main function - mypathway = importlib.import_module('.'+self._pathway, package='ssbtoolkit.pathways') - self.simtime = pl.geomspace(0.00001, self._ttotal, num=self._nsteps) - - #Simulation 1 - pathway_model = mypathway.network(LR=None, kinetics=True, **self._PathwayParameters) - sim1 = ScipyOdeSimulator(pathway_model, tspan=self.simtime,compiler='cython').run() - self.simres1 = sim1.all - - def calc_ratio(self): - - - #Simulation 2 - sim2 = ScipyOdeSimulator(mypathway.network(**self.new_pathway_parameters), tspan=self.simtime, compiler='cython').run() - self.simres2 = sim2.all - - #analysis - obs_name = 'obs_'+self._observable - obs_1 = self.simres1[obs_name] - obs_2 = self.simres2[obs_name] - - if 'time_in' in self.new_pathway_parameters: - self._time = np.take(self.simtime, np.where(self.simtime > int(self.new_pathway_parameters['time_in'])))[0] - obs_curve_1 = np.take(obs_1, np.where(self.simtime > int(self.new_pathway_parameters['time_in'])))[0] - obs_curve_2 = np.take(obs_2, np.where(self.simtime > int(self.new_pathway_parameters['time_in'])))[0] - - else: - self._time = np.take(self.simtime, np.where(self.simtime>0))[0] - obs_curve_1 = np.take(obs_1, np.where(self.simtime > 0))[0] - obs_curve_2 = np.take(obs_2, np.where(self.simtime > 0))[0] - - obs_peaks_1, _ = find_peaks(obs_curve_1) - obs_peaks_2, _ = find_peaks(obs_curve_2) - - vmax_obs_curve_1 = obs_curve_1[obs_peaks_1][-1]*1E3 - vmax_obs_curve_2 = obs_curve_2[obs_peaks_2][-1]*1E3 - - obs_ratio = round(vmax_obs_curve_2/vmax_obs_curve_1, abs(decimal.Decimal(str(self._expratio).rstrip('0')).as_tuple().exponent)) - - self._obs_curve_1=obs_curve_1 - self._obs_curve_2=obs_curve_2 - self._obs_peaks_1=obs_peaks_1 - self._obs_peaks_2=obs_peaks_2 - self._vmax_obs_curve_1=vmax_obs_curve_1 - self._vmax_obs_curve_2=vmax_obs_curve_2 - - return obs_ratio - - self._iteration=1 - print('\n') - - self._lst_ratio=[] - self._lst_seed=[] - - for idx in range(self._maxiter): - - prefix = 'iteration' - iteration_n = str(self._iteration) - print(f'\r{prefix} {iteration_n}', end='\r') - - self.new_pathway_parameters={**self._PathwayParameters, **{self._target_parameter:mypathway.defaultParameters[self._target_parameter]*self._seed}} - self.obs_ratio = calc_ratio(self) - - if self.obs_ratio == self._expratio: - self._lst_ratio.append(self.obs_ratio) - self._lst_seed.append(self._seed) - self._fold=round(self._seed, abs(decimal.Decimal(str(self._expratio).rstrip('0')).as_tuple().exponent)) - print('\n\nDONE!\n', '\nRatio: '+str(self.obs_ratio), '\nFOLD: '+str(self._fold), '\nNumber of iterations: '+str(self._iteration)) - break - elif self.obs_ratio < self._expratio: - - self._lst_ratio.append(self.obs_ratio) - self._lst_seed.append(self._seed) - self._iteration+=1 - self._seed += self._seed_incrementor - - else: - self._lst_ratio.append(self.obs_ratio) - self._lst_seed.append(self._seed) - - - self._iteration+=1 - self._seed -= self._seed_decrementor - - return - - def PlotIterations(self, save=False, filename=None): - ''' - Plot iterations. - ''' - import plotly.offline as pyoff - #dependencies - if self._iteration == None: raise TypeError('Simulation data not exist. simulation.fitModel.run() must be run first.') - - #import plotly - import plotly.graph_objs as go - - iterations = np.arange(1,self._iteration+1) - - trace=dict(type='scatter', x=self._lst_seed, y=self._lst_ratio, mode='markers', - marker=dict(color= iterations, colorscale='Bluered_r', size=14, colorbar=dict(thickness=20, title='iteration number'))) - #axis_style=dict(zeroline=False, showline=True, mirror=True) - layout = dict(title = '', - xaxis = dict( - title = 'seed', - titlefont=dict( - size=20 - ), - tickfont=dict( - size=20 - )), - yaxis = dict( - title = '['+self._observable+']' + ' ratio', - titlefont=dict( - size=20), - tickfont=dict( - size=20) - - ), - legend=dict(font=dict(size=15)), - autosize=False, - width=850, - height=650 - ) - - fig = go.Figure(data=[trace], layout=layout) - if save==True: - if filename==None: - filename='plot.html' - return pyoff.plot(fig, filename=filename) - else: - ext = os.path.splitext(filename)[-1] - if ext == '.png': fig.write_image(filename, scale=3) - elif ext == '.html': pyoff.plot(fig, filename=filename) - else: raise TypeError("extension not valid. Use png or html.") - elif save ==False: return fig - return fig - - def ShowGraphs(self, save=False, filename=None): - ''' - Plot the amount of obeservable in function of time, Amplitude, Area Under the Curve, and Full Width at Half Maximum. - - :parameter save: Optional (kwarg boolean): default False - :parameter filename: Optional (kwarg str) - ''' - - from IPython.core.display import display, HTML - display(HTML("<style>.container { width:90% !important; }</style>")) - - - from plotly.subplots import make_subplots - from scipy.signal import peak_widths - from sklearn import metrics - import plotly.offline as pyoff - - - half_1 = peak_widths(self._obs_curve_1, self._obs_peaks_1, rel_height=0.5) - half_2 = peak_widths(self._obs_curve_2, self._obs_peaks_2, rel_height=0.5) - fwhm_1 = self._time[int(half_1[3])]-self._time[int(half_1[2])] - fwhm_2 = self._time[int(half_2[3])]-self._time[int(half_2[2])] - - - fig = make_subplots(rows=2, cols=2,vertical_spacing=0.15, - subplot_titles=("{} concentration".format(self._observable), "Amplitude", "Area under the curve", "Full Width at Half Maximum")) - - #################### - #### MAIN PLOT #### - #################### - fig.add_trace(go.Scatter(x=self._time, y=self._obs_curve_1*1E3, name='control'), row=1, col=1) - fig.add_trace(go.Scatter(x=self._time, y=self._obs_curve_2*1E3, name='{}-fold'.format(self._fold)), row=1, col=1) - fig.add_trace(go.Scatter(x=self._time[self._obs_peaks_1], y=self._obs_curve_1[self._obs_peaks_1]*1E3, - name='max value', showlegend=False, mode='markers', - marker=dict(symbol='x', size=13, color='Black')), row=1,col=1) - fig.add_trace(go.Scatter(x=self._time[self._obs_peaks_2], y=self._obs_curve_2[self._obs_peaks_2]*1E3, - name='max value', showlegend=False, mode='markers', - marker=dict(symbol='x', size=13, color='Black')), row=1,col=1) - fig.add_shape(type='line', x0=self._time[int(half_1[2])],y0=half_1[1][0]*1E3, x1=self._time[int(half_1[3])], y1=half_1[1][0]*1E3, - line=dict(color='Blue',dash='dash'),xref='x',yref='y', row=1, col=1) - fig.add_shape(type='line', x0=self._time[int(half_2[2])],y0=half_2[1][0]*1E3, x1=self._time[int(half_2[3])], y1=half_2[1][0]*1E3, - line=dict(color='Red',dash='dash'),xref='x',yref='y', row=1, col=1) - - # Update xaxis properties - fig.update_xaxes(title_text="Time (s)", showgrid=False, row=1, col=1, titlefont=dict(size=18), - linecolor='black', linewidth=2, - ticks='inside', tickfont=dict(size=18), tickcolor='black', ticklen=10, tickwidth=2) - - fig.update_yaxes(title_text=self._observable+' (nM)', titlefont=dict(size=18), showgrid=False, row=1, col=1, - linecolor='black', linewidth=2, - ticks='inside', tickfont=dict(size=18), tickcolor='black', ticklen=10, tickwidth=2) - - - #################### - #### AMPLITUDE #### - #################### - - AMP_labels = [1,2] - AMP_values = [self._vmax_obs_curve_1, self._vmax_obs_curve_2] - fig.add_trace(go.Bar(x=AMP_labels,y=AMP_values, width = [0.35,0.35], showlegend=False, marker_color='black', name=''), row=1, col=2 ) - - - - # Update xaxis properties - fig.update_xaxes(row=1, col=2, showgrid=False, linecolor='black', linewidth=2, range=[0,3], - tickmode='array', tickvals=[1,2], ticktext=['control', '{}-fold'.format(self._fold)], tickfont=dict(size=18)) - - fig.update_yaxes(showgrid=False, range=[round((min(AMP_values)-min(AMP_values)*0.5)/5)*5,round((max(AMP_values)+max(AMP_values)*0.5)/5)*5 ], row=1, col=2, - title_text=self._observable+' (nM)', titlefont=dict(size=18), - linecolor='black', linewidth=2, ticks='inside', ticklen=10, tickwidth=2, tickfont=dict(size=18)) - - # Add diff lines - AMP_diffs = [max(AMP_values) - v for v in AMP_values] - AMP_diff_labels = dict(zip(AMP_labels, AMP_diffs)) - fig.add_trace(go.Scatter(name='',x=[1,1.5,2], y=[max(AMP_values)+(max(AMP_values)*0.3)]*3, mode = 'lines+text',showlegend=False, line=dict(color='black', width=1),text=['', 'diff. = {} nM'.format(round(AMP_diffs[0], 3)),''], textposition='top center'), row=1, col=2) - fig.add_trace(go.Scatter(name='',x=[AMP_labels[0]-0.175, AMP_labels[0]+0.175], y=[AMP_values[0]+(AMP_values[0]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) - fig.add_trace(go.Scatter(name='',x=[AMP_labels[1]-0.175, AMP_labels[1]+0.175], y=[AMP_values[1]+(AMP_values[1]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) - fig.add_trace(go.Scatter(name='',x=[AMP_labels[0], AMP_labels[0]], y=[AMP_values[0]+(AMP_values[0]*0.03), max(AMP_values)+(max(AMP_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) - fig.add_trace(go.Scatter(name='',x=[AMP_labels[1], AMP_labels[1]], y=[AMP_values[1]+(AMP_values[1]*0.03), max(AMP_values)+(max(AMP_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) - - - #################### - #### AUC #### - #################### - - # Data - AUC_labels = [1,2] - AUC_values = [round(metrics.auc(self._time, self._obs_curve_1),2), round(metrics.auc(self._time, self._obs_curve_2),2)] - fig.add_trace(go.Bar(x=AUC_labels,y=AUC_values, width = [0.35,0.35], showlegend=False, marker_color='black', name=''), row=2, col=1 ) - - # Update xaxis properties - fig.update_xaxes(row=2, col=1, tickmode='array', showgrid=False, range=[0,3], linecolor='black', linewidth=2, - tickvals=[1,2], ticktext=['control', '{}-fold'.format(self._fold)], tickfont=dict(size=18)) - - fig.update_yaxes(row=2, col=1,showgrid=False, title_text=self._observable+' (nM)', range=[round((min(AUC_values)-min(AUC_values)*0.5)/5)*5,round((max(AUC_values)+max(AUC_values)*0.5)/5)*5], - titlefont=dict(size=18),linecolor='black', linewidth=2, - ticks='inside', tickfont=dict(size=18),ticklen=10, tickwidth=2) - - # Add diff lines - AUC_diffs = [max(AUC_values) - v for v in AUC_values] - AUC_diff_labels = dict(zip(AUC_labels, AUC_diffs)) - fig.add_trace(go.Scatter(name='',x=[1,1.5,2], y=[max(AUC_values)+(max(AUC_values)*0.3)]*3, mode = 'lines+text',showlegend=False, - line=dict(color='black', width=1), text=['', 'diff. = {} nM'.format(round(AUC_diffs[0], 3)),''], textposition='top center'), row=2, col=1) - fig.add_trace(go.Scatter(name='',x=[AUC_labels[0]-0.175, AUC_labels[0]+0.175], y=[AUC_values[0]+(AUC_values[0]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) - fig.add_trace(go.Scatter(name='',x=[AUC_labels[1]-0.175, AUC_labels[1]+0.175], y=[AUC_values[1]+(AUC_values[1]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) - fig.add_trace(go.Scatter(name='',x=[AUC_labels[0], AUC_labels[0]], y=[AUC_values[0]+(AUC_values[0]*0.03), max(AUC_values)+(max(AUC_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) - fig.add_trace(go.Scatter(name='',x=[AUC_labels[1], AUC_labels[1]], y=[AUC_values[1]+(AUC_values[1]*0.03), max(AUC_values)+(max(AUC_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) - - - #################### - #### FWHM #### - #################### - # Data - FWHM_labels = [1,2] - FWHM_values = [fwhm_1, fwhm_2] - fig.add_trace(go.Bar(x=FWHM_labels,y=FWHM_values, width = [0.35,0.35], showlegend=False,marker_color='black', name=''), row=2, col=2 ) - - # Update xaxis properties - fig.update_xaxes(row=2, col=2, showgrid=False, range=[0,3], linecolor='black', linewidth=2, - tickmode='array', tickvals=[1,2], ticktext=['control', '{}-fold'.format(self._fold)], tickfont=dict(size=18)) - - fig.update_yaxes(row=2, col=2, showgrid=False, range=[self.pathway_parameters['time_in'],round((max(FWHM_values)+(max(FWHM_values)-self.pathway_parameters['time_in'])*0.5)/5)*5], - title_text='Time (s)', titlefont=dict(size=18), linecolor='black', linewidth=2, - ticks='inside', ticklen=10, tickwidth=2, tickfont=dict(size=18)) - - # Add diff lines - FWHM_diffs = [max(FWHM_values) - v for v in FWHM_values] - FWHM_diff_labels = dict(zip(FWHM_labels, FWHM_diffs)) - line_height = max(FWHM_values)+((max(FWHM_values)-self.pathway_parameters['time_in'])*0.30) - fig.add_trace(go.Scatter(x=[1,1.5,2], y=[line_height]*3, mode = 'lines+text',showlegend=False, line=dict(color='black', width=1),name='', - text=['', 'diff. = {} s'.format(round(FWHM_diffs[0], 3)),''], textposition='top center'), row=2, col=2) - fig.add_trace(go.Scatter(name='',x=[FWHM_labels[0]-0.175, FWHM_labels[0]+0.175], y=[FWHM_values[0]+(FWHM_values[0]*0.005)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) - fig.add_trace(go.Scatter(name='',x=[FWHM_labels[1]-0.175, FWHM_labels[1]+0.175], y=[FWHM_values[1]+(FWHM_values[1]*0.005)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) - fig.add_trace(go.Scatter(name='',x=[FWHM_labels[0], FWHM_labels[0]], y=[FWHM_values[0]+(FWHM_values[0]*0.005), line_height], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) - fig.add_trace(go.Scatter(name='',x=[FWHM_labels[1], FWHM_labels[1]], y=[FWHM_values[1]+(FWHM_values[1]*0.005), line_height], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) - - - #################### - #### FIGURE #### - #################### - - fig.update_layout(height=1200, width=1300, title_text="", plot_bgcolor='white',showlegend=True, - legend=dict(yanchor="top", x=0.3, y=.99,font=dict(family="sans-serif", size=14,color="black"))) - fig.update_annotations(font_size=20, font_color='black') - - if save==True: - if filename==None: - filename='plot.html' - return pyoff.plot(fig, filename=filename) - else: - ext = os.path.splitext(filename)[-1] - if ext == '.png': fig.write_image(filename, scale=3) - elif ext == '.html': pyoff.plot(fig, filename=filename) - else: raise TypeError("extension not valid. Use png or html.") - elif save ==False: return fig - - return diff --git a/ssbtoolkit/__init__py b/ssbtoolkit/__init__py new file mode 100644 index 0000000000000000000000000000000000000000..73756ced374a0ce493b73ee29d191fa2051b93dd --- /dev/null +++ b/ssbtoolkit/__init__py @@ -0,0 +1,15 @@ +import pkgutil + +__all__ = [] +for loader, module_name, is_pkg in pkgutil.walk_packages(__path__): + __all__.append(module_name) + _module = loader.find_module(module_name).load_module(module_name) + globals()[module_name] = _module + + +import sys, os, warnings +sys.path.insert(0, os.path.abspath(os.path.split(os.path.realpath(__file__))[0])) +warnings.simplefilter(action='ignore') + + + diff --git a/ssbtoolkit/__pycache__/Binding.cpython-39.pyc b/ssbtoolkit/__pycache__/Binding.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cef465df6d41f8c1c907a2a41a0fb20bd33dfe4d Binary files /dev/null and b/ssbtoolkit/__pycache__/Binding.cpython-39.pyc differ diff --git a/ssbtoolkit/__pycache__/Simulation.cpython-39.pyc b/ssbtoolkit/__pycache__/Simulation.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..460138feae6ca850aee45d0f6443def752cf6f7c Binary files /dev/null and b/ssbtoolkit/__pycache__/Simulation.cpython-39.pyc differ diff --git a/ssbtoolkit/__pycache__/Utils.cpython-39.pyc b/ssbtoolkit/__pycache__/Utils.cpython-39.pyc index a8b0c57ab461229eea031894352efa76c5bb7d7b..ff1259fb1d1bac67343b743163f5fa046c7adeeb 100644 Binary files a/ssbtoolkit/__pycache__/Utils.cpython-39.pyc and b/ssbtoolkit/__pycache__/Utils.cpython-39.pyc differ diff --git a/ssbtoolkit/__pycache__/__init__.cpython-39.pyc b/ssbtoolkit/__pycache__/__init__.cpython-39.pyc index a650def0a4ad5939e819b758c2da741abc190047..48ab15b99374e7ef7ef007a6d7495fb46a4bf955 100644 Binary files a/ssbtoolkit/__pycache__/__init__.cpython-39.pyc and b/ssbtoolkit/__pycache__/__init__.cpython-39.pyc differ diff --git a/ssbtoolkit/pathways/__pycache__/Gi.cpython-39.pyc b/ssbtoolkit/pathways/__pycache__/Gi.cpython-39.pyc index 90575c1b81be1350a768a8c3e93401a12ac20d7d..465eaabb494545925492e3a595ed849104b0d3f8 100644 Binary files a/ssbtoolkit/pathways/__pycache__/Gi.cpython-39.pyc and b/ssbtoolkit/pathways/__pycache__/Gi.cpython-39.pyc differ diff --git a/ssbtoolkit/pathways/__pycache__/Gq.cpython-39.pyc b/ssbtoolkit/pathways/__pycache__/Gq.cpython-39.pyc index fc9fdfb33151758ee35559f7b552a6788f835e08..67c3f6b11c0ab685fa225bc8fa8057291a9f91dc 100644 Binary files a/ssbtoolkit/pathways/__pycache__/Gq.cpython-39.pyc and b/ssbtoolkit/pathways/__pycache__/Gq.cpython-39.pyc differ diff --git a/ssbtoolkit/pathways/__pycache__/Gs.cpython-39.pyc b/ssbtoolkit/pathways/__pycache__/Gs.cpython-39.pyc index 7c707f341b8c5fbcde4986c40aa53d5fba6eb2e4..4e4edf05202da0d2e49b00e100c236281adee152 100644 Binary files a/ssbtoolkit/pathways/__pycache__/Gs.cpython-39.pyc and b/ssbtoolkit/pathways/__pycache__/Gs.cpython-39.pyc differ diff --git a/ssbtoolkit/pathways/__pycache__/OXTR_pathway.cpython-39.pyc b/ssbtoolkit/pathways/__pycache__/OXTR_pathway.cpython-39.pyc index 5b2f6392a2ca8ca76ba97f0891b93bf247c12ff7..b612432d031a19e64a986eec29dd22bbb1eb2918 100644 Binary files a/ssbtoolkit/pathways/__pycache__/OXTR_pathway.cpython-39.pyc and b/ssbtoolkit/pathways/__pycache__/OXTR_pathway.cpython-39.pyc differ diff --git a/ssbtoolkit/pathways/__pycache__/OXTR_pathway_testing.cpython-39.pyc b/ssbtoolkit/pathways/__pycache__/OXTR_pathway_testing.cpython-39.pyc index 08ef00fc91a148a55b99f4764ee945d04538dc67..8c15d617fdd3b9b05441cdc85c8090f28d1dcafb 100644 Binary files a/ssbtoolkit/pathways/__pycache__/OXTR_pathway_testing.cpython-39.pyc and b/ssbtoolkit/pathways/__pycache__/OXTR_pathway_testing.cpython-39.pyc differ diff --git a/ssbtoolkit/pathways/__pycache__/__init__.cpython-39.pyc b/ssbtoolkit/pathways/__pycache__/__init__.cpython-39.pyc index 05e041438bd8c0a475bfdf625d5417c05098cdc6..0eac17baffc854b251379832ee7ce48671f41b40 100644 Binary files a/ssbtoolkit/pathways/__pycache__/__init__.cpython-39.pyc and b/ssbtoolkit/pathways/__pycache__/__init__.cpython-39.pyc differ diff --git a/ssbtoolkit/ssbmain.py.txt b/ssbtoolkit/ssbmain.py.txt deleted file mode 100644 index 9031e98c87e217b8c6df045744c48a5f7475a8f5..0000000000000000000000000000000000000000 --- a/ssbtoolkit/ssbmain.py.txt +++ /dev/null @@ -1,1477 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# Copyright 2021 Rui Ribeiro -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -__author__ = "Rui Ribeiro" -__email__ = "rui.ribeiro@univr.it" - -#system libraries -from re import sub -import sys -import os -import importlib -import urllib.request as urllib -from glob import glob - -#Scientific Libraries -#import math -import numpy as np -import pandas as pd -from pandas.core import construction -from scipy.optimize import curve_fit, minimize -from sklearn.preprocessing import minmax_scale - -#Plotting Libraries -import plotly.graph_objs as go -import pylab as pl -from matplotlib import * - -#PYSB -from pysb import * -from pysb.macros import * -from pysb.simulator import ScipyOdeSimulator - -#Layout libraries -#import qgrid - -#directories (problem with sphinx) -abs_path=(os.path.join(os.path.split(os.getcwd())[0], 'src/lib')) -sys.path.insert(0, os.path.abspath(abs_path)) -try: - from ssbtoolkit.directories import * - import ssbtoolkit.utils as utils -except: - from directories import * - from utils import * - - -import warnings -warnings.simplefilter(action='ignore') - - - - -#Human Target Receptors DataBase directory PATH -HuTRdb_path = os.path.join(os.getcwd(),'SSBtoolkit/src/databases/HuTRdb.sqlite3') - -""" -SSBtoolkit API -""" - -class binding: - """This class simulate ligand-target binding curves.""" - def __init__(self): - self.receptor_conc = None - self.lig_conc_range = None - self.pKd = None - self.submax_concentration = None - - def bind(self, **kwargs): - """ - Applies an function to calculate the fraction of occupited receptors at equilibrium. - - :parameter receptor_conc: Required (kwarg flt): concentration of receptor - :parameter lig_conc_range: Required (kwarg array): array of range of ligand concentration - :parameter pKd: Required (kwarg flt): pKd value of the ligand - """ - - if 'receptor_conc' not in kwargs: raise TypeError("ERROR: receptor_conc is missing") - if 'lig_conc_range' not in kwargs: raise TypeError("ERROR: lig_conc_range is missing") - if 'pKd' not in kwargs: raise TypeError("ERROR: pKd is missing") - - self._receptor_conc = kwargs.pop('receptor_conc') - self._lig_conc_range = kwargs.pop('lig_conc_range') - self._pKd = kwargs.pop('pKd') - - binding_data=[] - for conc in self._lig_conc_range: - binding_data.append(utils.LR_eq_conc(self._receptor_conc, conc, 0, self._pKd, 0)) - self.binding_data=binding_data - return self.binding_data - - def maxbend(self): - """ - Calculates the maximum bending point of a sigmoid-shaped curve according to the mathod of Sebaugh et al., 2003. - - :parameter drug_receptor: Required (int): concentration of the receptor - :parameter lig_conc_range: Required (array): array of a range of ligand concentration - :return: instance .submax_concentration (flt) - - .. note:: The minimization uses the Nelder-Mead method. - """ - - from scipy.optimize import curve_fit, minimize - - - def sigmoid(X, Bottom, Top, Kd, p): - return Bottom + (Top-Bottom)/(1+np.power((Kd/X),p)) - - xfit = np.geomspace(np.min(self._lig_conc_range), np.max(self._lig_conc_range), 50000) #warning: shoud this be the minimum and maximum of concentration - popt, pcov = curve_fit(sigmoid, self._lig_conc_range, self.binding_data, bounds=([np.min(self.binding_data),-np.inf,-np.inf, 0.5],[np.inf,np.max(self.binding_data),np.inf, 2.5])) - - - def sigmoid_deriv_b(x, a,d,c,b): - return (x/c)**b*(a - d)*np.log(x/c)/((x/c)**b + 1)**2 - - min_value = minimize(sigmoid_deriv_b, np.max(xfit), args=(popt[0],popt[1],popt[2],popt[3]), method = 'Nelder-Mead') - - self.submax_concentration = round(min_value.x[0],3) - return self.submax_concentration - - def show_curve(self): - """ - Plots ligand-target binding curve - """ - - #import plotly - import plotly.graph_objs as go - from scipy.optimize import curve_fit - from sklearn.preprocessing import minmax_scale - - ##Fitting curve to the data - - yy = minmax_scale(self.binding_data)*100 - - def equation_dose(X, Bottom, Top, EC50, p): - return Bottom + (Top-Bottom)/(1+np.power((EC50/X),p)) - - popt, pcov = curve_fit(equation_dose, self._lig_conc_range, yy, bounds=([np.min(yy),-np.inf,-np.inf, 0.5],[np.inf,np.max(yy),np.inf, 2.5])) - - xfit = np.geomspace(np.min(self._lig_conc_range), np.max(self._lig_conc_range), 50000) # These values are the same as the values for the simulation time and not ligand concentration - yfit = minmax_scale(equation_dose(xfit, *popt))*100 - - - - trace1 = go.Line(x=xfit, y=yfit, showlegend=False, name='radioligand') - if self.submax_concentration: - xsubmaximal = np.array(self.submax_concentration) - ysubmaximal = np.array(equation_dose(xsubmaximal, *popt)) - trace2 = go.Scatter(x=xsubmaximal, y=ysubmaximal, showlegend=True, mode='markers', name='submaximal ({} μM)'.format(xsubmaximal), - marker=dict(size=14)) - else: trace2=[] - - - layout = dict(title = '', - xaxis = dict( - title = '[ligand] μM', - type ='log', - exponentformat='e', - titlefont=dict( - size=20 - ), - tickfont=dict( - size=20 - )), - yaxis = dict( - title = '% occupied receptors', - - titlefont=dict( - size=20), - tickfont=dict( - size=20) - - ), - legend=dict(font=dict(size=15)), - autosize=False, - width=850, - height=650, - ) - if self.submax_concentration: - fig = go.Figure(data=[trace1, trace2], layout=layout) - else: - fig = go.Figure(data=[trace1], layout=layout) - return fig - -class simulation: - """ - This class simulates the mathematical models of the signaling pathways. - """ - class activation: - """ - Simulation of the activation of signaling pathways (i.e. activation by agonists) - """ - def __init__(self): - self._ligands=None - self._affinities=None - self._pathway=None - self._receptor_conc=None - self._lig_conc_range=None - self._ttotal=None - self._nsteps=None - self._binding_kinetics=True - self._binding_kinetic_parameters=None - self.simulation_data=None - self.processed_data=None - - def SetSimulationParameters(self, **kwargs): - """ - :parameter ligands: Required (kwargs list): list of ligands' names (str) - :parameter affinities: Required (kwargs list): list of pKd values (flt) - :parameter pathway: Required (kwargs str): name of the pathway ('Gs', 'Gi', 'Gq') - :parameter receptor_conc: Required (kwargs flt): receptors concentration (nM) - :parameter lig_conc_range: Required (kwargs array): range of ligands' concentration - :parameter ttotal: Required (kwargs int): simulation time (seconds) - :parameter nsteps: Required (kwargs int): simulation time step - :parameter binding_kinetics: Optional (kwargs boolean): default (False) - - - .. warning:: the order of the lists of ligands names and affinities list must be the same. - - """ - self._ligands= kwargs.pop('ligands') - if 'affinities' in kwargs: - self._affinities=kwargs.pop('affinities') - self._pathway=kwargs.pop('pathway') - self._receptor_conc=kwargs.pop('receptor_conc') - self._lig_conc_range=kwargs.pop('lig_conc_range') - self._ttotal=kwargs.pop('ttotal') - self._nsteps=kwargs.pop('nsteps') - self._binding_kinetics=kwargs.pop('binding_kinetics') - if 'binding_kinetic_parameters' in kwargs:self._binding_kinetic_parameters=kwargs.pop('binding_kinetic_parameters') - self._DefaultPathwayParametersDataFrame=pd.DataFrame() - - return - - def PathwayParameters(self): - """ - Display table with default pathway parameters. - - .. warning:: this functions requires the qgrid library. It doens't work on Google Colab. - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv('src/lib/pathways/{}_parameters.csv'.format(self._pathway)) - - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def UserPathwayParameters(self, path): - """ - Import user pathway parameters. - - :parameter path: Required (kwarg str): directory path - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv(path) - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def PathwayParametersToCSV(self, path): - """ - Export pathway parameters into CSV format. - - :parameter path: Required (kwarg str): directory path - """ - self._DefaultPathwayParametersTable.get_changed_df().to_csv(path, index=False) - print('saved in:', path) - return - - def Reactions(self): - """ - Display pathway reactions. - """ - from IPython.display import display, HTML - display(HTML("<style>.container {width:90% !important}</style>")) - return pd.read_csv('src/lib/pathways/{}_reactions.csv'.format(self._pathway)) - - def Run(self): - ''' - This function runs the pathway simulation and returns the raw simulation data. - ''' - - #Check inputs - if self._ligands==None: raise TypeError("ligands list undefined.") - elif self._pathway==None: raise TypeError("pathway name undefined.") - elif self._binding_kinetics==False and self._affinities==None: raise TypeError("affinity_values_dict undefined.") - elif self._binding_kinetics==True and self._affinities==None: pass - elif self._lig_conc_range.any() == False: raise TypeError("lig_conc_range undefined.") - elif self._ttotal==None: raise TypeError("ttotal undefined.") - elif self._nsteps==None: raise TypeError("nsteps undefined.") - elif self._receptor_conc==None: raise TypeError("receptor_conc undefined.") - else: pass - - - #Check Pathway availability and import it - available_pathways = ['Gs', 'Gi', 'Gq'] - if self._pathway == 'Gz(Gi)': self._pathway = 'Gi' - if self._pathway not in available_pathways: raise Exception('Unvailable Pathway. Please, introduce it manually. Pathways available: "Gs", "Gi", "Gq".') - mypathway = importlib.import_module('.'+self._pathway, package='src.lib.pathways') - - #Get default pathway parameters - if self._DefaultPathwayParametersDataFrame.empty and self._binding_kinetic_parameters==None: - self._DefaultPathwayParametersDataFrame = pd.read_csv('src/lib/pathways/{}_parameters.csv'.format(self._pathway)) - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty is False and self._binding_kinetic_parameters is None: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = newparameters.set_index('Parameter').iloc[:,0].to_dict() - except: - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty and self._binding_kinetic_parameters is not None: - self._DefaultPathwayParametersDataFrame = pd.read_csv('src/lib/pathways/{}_parameters.csv'.format(self._pathway)) - - elif self._DefaultPathwayParametersDataFrame.empty is False and self._binding_kinetic_parameters is not None: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = {**newparameters.set_index('Parameter').iloc[:,0].to_dict(), **self._binding_kinetic_parameters} - except: - self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self._binding_kinetic_parameters} - - #Input - t = pl.geomspace(0.00001, self._ttotal, num=self._nsteps) # (a,b,c); a is the starting time ; b is the total time simulated ; c is the number of points - - - #Output - simulation_data={} - - #Function - for ligand in self._ligands: - ligand_name = os.path.splitext(str(ligand))[0] - data=[] - utils.printProgressBar(0, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) - - ###DANGER ZONE### - if self._binding_kinetic_parameters is not None: - self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self._binding_kinetic_parameters[self._ligands.index(ligand)]} - ###################### - - for idx in range(len(self._lig_conc_range)): - - ligand_conc = self._lig_conc_range[idx] - if self._binding_kinetics == False: - #get LR conc - parameters = {**self._PathwayParameters, 'R_init':self._receptor_conc} - LR_conc_init = utils.LR_eq_conc(self._receptor_conc, ligand_conc, 0, self._affinities[self._ligands.index(ligand)], 0) - mymodel = mypathway.network(LR=LR_conc_init, kinetics=False, **parameters) - simres = ScipyOdeSimulator(mymodel, tspan=t, compiler='cython').run() - yout = simres.all - - elif self._binding_kinetics == True: - parameters={**self._PathwayParameters,'R_init':self._receptor_conc, 'L_init':self._lig_conc_range[idx] } - mymodel = mypathway.network(kinetics=True, **parameters) - simres = ScipyOdeSimulator(mymodel, tspan=t, compiler='cython').run() - yout = simres.all - - d1={'ligand_conc':ligand_conc, 'time':t } - - for idx2 in range(len(mypathway.list_of_observables)): - d2={mypathway.list_of_observables[idx2]:yout[mypathway.list_of_observables[idx2]]} - d1.update(d2) - data.append(d1) - utils.printProgressBar(idx + 1, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) - - - simulation_data[ligand_name] = {'sim_data':data, - 'label':ligand_name,} - self.simulation_data = simulation_data - return - - def Analysis(self): - ''' - This function calculates the dose-response effect. - - :return: instance of processed_data - ''' - - if self.simulation_data == None: raise TypeError('There is no simulation data. simulation.activation.run() must be run first.') - - from sklearn.preprocessing import minmax_scale - - # Define all the lists and dictionaries used in this function - raw_data=[] - normalized_data=[] - fitted_data=[] - - dose={} - - #defining concentration range - lig_conc_min = self._lig_conc_range.min() - lig_conc_max = self._lig_conc_range.max() - - #Main function - for ligand in self.simulation_data: - - #definig and dictionaries used in this loop: - raw_data_dict={} - normalized_data_dict={} - fitted_data_dict={} - - # Calculate dose-response curve - #get metabolite concentration, rescale, and transform data if pathway/metabolite decrease - # metabolite_raw is not normalized - if self._pathway == 'Gi' or self._pathway == 'Gz(Gi)': - metabolite='cAMP' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(1-np.array(metabolite_conc_raw)) - elif self._pathway == 'Gs': - metabolite='cAMP' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) - elif self._pathway == 'Gq': - metabolite='IP3' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) - else: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') - - - ## save results - raw_data_dict['x']=self._lig_conc_range - raw_data_dict['y']=metabolite_conc_raw - raw_data_dict['label']=self.simulation_data[ligand]['label'] - - normalized_data_dict['x']=self._lig_conc_range - normalized_data_dict['y']=metabolite_conc_norm - normalized_data_dict['label']=self.simulation_data[ligand]['label'] - - ## create a list of all data - raw_data.append(raw_data_dict) - normalized_data.append(normalized_data_dict) - - ##Fitting curve to the data - - def equation_dose(X, Bottom, Top, EC50, p): - return Bottom + (Top-Bottom)/(1+np.power((EC50/X),p)) - - popt_EC50, pcov = curve_fit(equation_dose, self._lig_conc_range, metabolite_conc_norm, bounds=([np.min(metabolite_conc_norm),-np.inf,-np.inf, 0.5],[np.inf,np.max(metabolite_conc_norm),np.inf, 2.5])) - - xfit_EC50 = np.geomspace(lig_conc_min, lig_conc_max, 50000) # These values are the same as the values for the simulation time and not ligand concentration - yfit_EC50 = equation_dose(xfit_EC50, *popt_EC50) - - fit_EC50={'x':xfit_EC50, 'y':yfit_EC50, 'label':self.simulation_data[ligand]['label']} - - dose[ligand] = {'raw_data': raw_data_dict, - 'normalized_data':normalized_data_dict , - 'fitted_data': fit_EC50, - 'EC50 (μM)': round(popt_EC50[2],5), - 'pEC50': round(-np.log10(popt_EC50[2]*1E-6),2)} - - self.processed_data=dose - return - - def Curve(self, save=False, filename=None): - ''' - Plots the dose-response curve. - ''' - - if self.simulation_data == None: raise TypeError('There is no simulation data. simulation.activation.run() must be run first.') - - import plotly - import plotly.graph_objs as go - import plotly.offline as pyoff - - colors = plotly.colors.DEFAULT_PLOTLY_COLORS - - plot_data=[] - - color_id=0 - for ligand in self.processed_data: - trace_norm = go.Scatter(x=self.processed_data[ligand]['normalized_data']['x'], - y=minmax_scale(self.processed_data[ligand]['normalized_data']['y'])*100 , - mode='markers', - showlegend=True, - name=self.processed_data[ligand]['normalized_data']['label'], - marker=dict(color=colors[color_id])) - plot_data.append(trace_norm) - - trace_fitted = go.Scatter(x=self.processed_data[ligand]['fitted_data']['x'], - y=minmax_scale(self.processed_data[ligand]['fitted_data']['y'])*100, - mode='lines', - showlegend=False, - name=self.processed_data[ligand]['fitted_data']['label'], - line=dict(color=colors[color_id])) - plot_data.append(trace_fitted) - color_id +=1 - - layout = dict(title = '', - xaxis = dict( - title = '[ligand] μM', - type ='log', - #range = [-3, 2], - exponentformat='e', - titlefont=dict( - size=20 - ), - tickfont=dict( - size=20 - )), - yaxis = dict( - title = '% Response', - #range = [0, 100], - titlefont=dict( - size=20), - tickfont=dict( - size=20) - - ), - legend=dict(font=dict(size=15)), - autosize=False, - width=850, - height=650, - ) - - fig = go.Figure(data=plot_data, layout=layout) - #fig['layout']['yaxis'].update(autorange = True) - - if save==True: - if filename==None: - filename='plot.html' - return pyoff.plot(fig, filename=filename) - else: - ext = os.path.splitext(filename)[-1] - if ext == '.png': fig.write_image(filename, scale=3) - elif ext == '.html': pyoff.plot(fig, filename=filename) - else: raise TypeError("extension not valid. Use png or html.") - elif save ==False: return fig - return - - def Potency(self): - ''' - Return the potency values as a pandas DataFrame. - ''' - import pandas as pd - data = simulation.activation.PotencyToDict(self) - df = pd.DataFrame.from_dict(data, orient='index') - return df - - def PotencyToDict(self): - ''' - Convert potencies into a dictionary. - ''' - - #dependencies - if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.activation.analysis() must be run first.') - - kvalues={} - for ligand in self.processed_data: - IC50 = list(self.processed_data[ligand].keys())[-2] - IC50_value = self.processed_data[ligand][IC50] - pIC50 = list(self.processed_data[ligand].keys())[-1] - pIC50_value = self.processed_data[ligand][pIC50] - kvalues[ligand]={IC50:IC50_value, pIC50:pIC50_value} - return kvalues - - def PotencyToCSV(self, path): - ''' - Exports the potency values into csv format. - - :parameter path: Required (kwarg str): directory path to save the csv file - ''' - - data = simulation.activation.PotencyToDict(self) - df = pd.DataFrame.from_dict(data, orient='index') - df.to_csv(path, index=False) - return - - class inhibition: - """ - Simulation of the inhibition of signaling pathways (i.e. inhibition by antagonists). - """ - def __init__(self): - self._agonist=None - self._agonist_affinity=None - self._agonist_submaximal_conc=None - self._antagonists=None - self._antagonists_affinities=None - self._pathway=None - self._receptor_conc=None - self._lig_conc_range=None - self._ttotal=None - self._nsteps=None - self._binding_kinetics=False - self._binding_kinetic_parameters=None - self.simulation_data=None - self.processed_data=None - - def SetSimulationParameters(self, **kwargs): - """ - :parameter agonist: Required (kwargs str): agonist name - :parameter agonist_affinity: Required (kwargs flt): agonist pKd value - :parameter agonist_submaximal_conc: Required (kwargs flt): agonist submaximal concentration - :parameter antagonists: Required (kwargs list):list of antagonists names (str) - :parameter antagonists_affinities: Required (kwargs list): list of antagonists affinity values (flt) - :parameter antagonists_conc_range: Required (kwargs array): range of ligands' concentration (nM) - :parameter pathway: Required (kwargs str): name of the pathway ('Gs', 'Gi', 'Gq') - :parameter receptor_conc: Required (kwargs flt): receptors concentration (nM) - :parameter ttotal: Required (kwargs int): simulation time (seconds) - :parameter nsteps: Required (kwargs int): simulation time step - :parameter kinetics: Optional (kwargs boolean): default (False) - - - :return: instances of all parameters - - .. warning:: the order of the lists of the antagonists names and affinities list must be the same. - - """ - self._agonist= kwargs.pop('agonist') - self._agonist_affinity=kwargs.pop('agonist_affinity') - self._agonist_submaximal_conc=kwargs.pop('agonist_submaximal_conc') - self._antagonists=kwargs.pop('antagonists') - self._antagonists_affinities=kwargs.pop('antagonists_affinities') - self._pathway=kwargs.pop('pathway') - self._receptor_conc=kwargs.pop('receptor_conc') - self._lig_conc_range=kwargs.pop('lig_conc_range') - self._ttotal=kwargs.pop('ttotal') - self._nsteps=kwargs.pop('nsteps') - if 'kinetics' in kwargs: - self._binding_kinetics=kwargs.pop('kinetics') - if self._binding_kinetics==True: raise TypeError("The of Kinetic parameters during an inhibition simulation it is not supported yet.") - else: self._binding_kinetics=False - if 'binding_kinetic_parameters' in kwargs: - self._binding_kinetic_parameters=kwargs.pop('binding_kinetic_parameters') - self._DefaultPathwayParametersDataFrame=pd.DataFrame() - - return - - def PathwayParameters(self): - """ - Display table with default pathway parameters. - - .. warning:: this functions requires the qgrid library. It doens't work on Google Colab. - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv('src/lib/pathways/{}_parameters.csv'.format(self._pathway)) - - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def UserPathwayParameters(self, path): - """ - Import user pathway parameters. - - :parameter path: Required (kwarg str): directory path - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv(path) - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def PathwayParametersToCSV(self, path): - """ - Export pathway parameters into CSV format. - - :parameter path: Required (kwarg str): directory path - """ - self._DefaultPathwayParametersTable.get_changed_df().to_csv(path, index=False) - print('saved in:', path) - return - - def Reactions(self): - """ - Display pathway reactions. - """ - from IPython.display import display, HTML - display(HTML("<style>.container {width:90% !important}</style>")) - return pd.read_csv('src/lib/pathways/{}_reactions.csv'.format(self._pathway)) - - def Run(self): - ''' - This function runs the pathway simulation and returns the raw simulation data. - ''' - - #Check inputs - if self._agonist==None: raise TypeError("agonist undefined.") - elif self._agonist_affinity==None: raise TypeError("agonist_affinity undifined.") - elif self._antagonists==None: raise TypeError("antagonists list undefined.") - elif self._antagonists_affinities==None: raise TypeError("antagonists affinity values undefined.") - elif self._pathway==None: raise TypeError("pathway undefined.") - elif self._lig_conc_range.any() == False: raise TypeError("lig_conc_range undefined.") - elif self._agonist_submaximal_conc == None: raise TypeError("agonist_submaximal_conc undifined.") - elif self._ttotal==None: raise TypeError("ttotal undefined.") - elif self._nsteps==None: raise TypeError("nsteps undefined.") - elif self._receptor_conc==None: raise TypeError("receptor_conc undefined.") - elif self._binding_kinetics==True: raise TypeError("The of Kinetic parameters during an inhibition simulation it is not supported yet.") - else: pass - - #check pathway - available_pathways = ['Gs', 'Gi', 'Gq'] - if self._pathway == 'Gz(Gi)': self._pathway = 'Gi' - if self._pathway not in available_pathways: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') - mypathway = importlib.import_module('.'+self._pathway, package='src.lib.pathways') - - #Get default pathway parameters - if self._DefaultPathwayParametersDataFrame.empty: - self._DefaultPathwayParametersDataFrame = pd.read_csv('src/lib/pathways/{}_parameters.csv'.format(self._pathway)) - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty is False: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = newparameters.set_index('Parameter').iloc[:,0].to_dict() - except: - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - #Input - t = pl.geomspace(0.00001, self._ttotal, num=self._nsteps) # (a,b,c); a is the starting time ; b is the total time simulated ; c is the number of points - - #Output - simulation_data={} - - #Function - for ligand in self._antagonists: - ligand_name = os.path.splitext(ligand)[0] - data=[] - utils.printProgressBar(0, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) - - for idx in range(len(self._lig_conc_range)): - - ligand_conc = self._lig_conc_range[idx] - - #get LR conc - parameters = {**self._PathwayParameters, 'R_init':self._receptor_conc} - LR_conc_init = utils.LR_eq_conc(self._receptor_conc, self._agonist_submaximal_conc, ligand_conc, self._agonist_affinity, self._antagonists_affinities[self._antagonists.index(ligand)]) - mymodel = mypathway.network(LR=LR_conc_init, kinetics=False, **parameters) - simres = ScipyOdeSimulator(mymodel, tspan=t, compiler='cython').run() - yout = simres.all - - d1={'ligand_conc':ligand_conc, 'time':t } - - for idx2 in range(len(mypathway.list_of_observables)): - d2={mypathway.list_of_observables[idx2]:yout[mypathway.list_of_observables[idx2]]} - d1.update(d2) - data.append(d1) - utils.printProgressBar(idx + 1, len(self._lig_conc_range), prefix = "{:<15}".format(ligand_name[:15]), suffix = 'Complete', length = 50) - - simulation_data[ligand_name] = {'sim_data':data, - 'label':self._agonist+' + ' + ligand_name} - - self.simulation_data=simulation_data - return - - def Analysis(self): - ''' - This function calculates the dose-response effect. - - :return: instance processed_data - ''' - #dependencies - if self.simulation_data == None: raise TypeError('There is no simulation data. simulation.inhibition.run() must be run first.') - - - from sklearn.preprocessing import minmax_scale - - # Define all the lists and dictionaries used in this function - raw_data=[] - normalized_data=[] - fitted_data=[] - - dose={} - - #defining concentration range - #defining concentration range - lig_conc_min = self._lig_conc_range.min() - lig_conc_max = self._lig_conc_range.max() - - #Main function - for ligand in self.simulation_data: - - #definig and dictionaries used in this loop: - raw_data_dict={} - normalized_data_dict={} - fitted_data_dict={} - - # Calculate dose-response curve - #get metabolite concentration, rescale, and transform data if pathway/metabolite decrease - # metabolite_raw is not normalized - if self._pathway == 'Gi' or self._pathway == 'Gz(Gi)': - metabolite='cAMP' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(1-np.array(metabolite_conc_raw)) - elif self._pathway == 'Gs': - metabolite='cAMP' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) - elif self._pathway == 'Gq': - metabolite='IP3' - metabolite_conc_raw=[] - for i in range(len(self._lig_conc_range)): - n=np.amax(self.simulation_data[ligand]['sim_data'][i]['obs_'+metabolite]) #cad - metabolite_conc_raw.append(n) - metabolite_conc_norm = minmax_scale(np.array(metabolite_conc_raw)) - else: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') - - - ## save results - raw_data_dict['x']=self._lig_conc_range - raw_data_dict['y']=metabolite_conc_raw - raw_data_dict['label']=self.simulation_data[ligand]['label'] - - normalized_data_dict['x']=self._lig_conc_range - normalized_data_dict['y']=metabolite_conc_norm - normalized_data_dict['label']=self.simulation_data[ligand]['label'] - - ## create a list of all data - raw_data.append(raw_data_dict) - normalized_data.append(normalized_data_dict) - - ##Fitting curve to the data - - def equation_dose(X, Bottom, Top, EC50, p): - return Bottom + (Top-Bottom)/(1+np.power((EC50/X),p)) - - popt_IC50, pcov = curve_fit(equation_dose, self._lig_conc_range, metabolite_conc_norm, bounds=([np.min(metabolite_conc_norm),-np.inf,-np.inf, 0.5],[np.inf,np.max(metabolite_conc_norm),np.inf, 2.5])) - - xfit_IC50 = np.geomspace(lig_conc_min, lig_conc_max, 50000) # These values are the same as the values for the simulation time and not ligand concentration - yfit_IC50 = equation_dose(xfit_IC50, *popt_IC50) - - fit_IC50={'x':xfit_IC50, 'y':yfit_IC50, 'label':self.simulation_data[ligand]['label']} - - - - - dose[ligand] = {'raw_data': raw_data_dict, - 'normalized_data':normalized_data_dict , - 'fitted_data': fit_IC50, - 'IC50 (μM)': round(popt_IC50[2],5), - 'pIC50': round(-np.log10(popt_IC50[2]*1E-6),2)} - - self.processed_data=dose - return - - def Curve(self, save=False, filename=None): - ''' - Plot the dose-response curve. - ''' - #dependencies - if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.inhibition.analysis() must be run first.') - - import plotly - import plotly.graph_objs as go - import plotly.offline as pyoff - - colors = plotly.colors.DEFAULT_PLOTLY_COLORS - - plot_data=[] - - color_id=0 - for ligand in self.processed_data: - trace_norm = go.Scatter(x=self.processed_data[ligand]['normalized_data']['x'], - y=minmax_scale(self.processed_data[ligand]['normalized_data']['y'])*100 , - mode='markers', - showlegend=True, - name=self.processed_data[ligand]['normalized_data']['label'], - marker=dict(color=colors[color_id])) - plot_data.append(trace_norm) - - trace_fitted = go.Scatter(x=self.processed_data[ligand]['fitted_data']['x'], - y=minmax_scale(self.processed_data[ligand]['fitted_data']['y'])*100, - mode='lines', - showlegend=False, - name=self.processed_data[ligand]['fitted_data']['label'], - line=dict(color=colors[color_id])) - plot_data.append(trace_fitted) - color_id +=1 - - layout = dict(title = '', - xaxis = dict( - title = '[ligand] μM', - type ='log', - #range = [-4, 2], - exponentformat='e', - titlefont=dict( - size=20 - ), - tickfont=dict( - size=20 - )), - yaxis = dict( - title = '% Response', - #range = [0, 100], - titlefont=dict( - size=20), - tickfont=dict( - size=20) - - ), - legend=dict(font=dict(size=15)), - autosize=False, - width=850, - height=650, - ) - - fig = go.Figure(data=plot_data, layout=layout) - if save==True: - if filename==None: - filename='plot.html' - return pyoff.plot(fig, filename=filename) - else: - ext = os.path.splitext(filename)[-1] - if ext == '.png': fig.write_image(filename, scale=3) - elif ext == '.html': pyoff.plot(fig, filename=filename) - else: raise TypeError("extension not valid. Use png or html.") - elif save ==False: return fig - return - - def constants(self): - ''' - Returns the potency values. - ''' - - #dependencies - if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.activation.analysis() must be run first.') - - kvalues={} - for ligand in self.processed_data: - IC50 = list(self.processed_data[ligand].keys())[-2] - IC50_value = self.processed_data[ligand][IC50] - pIC50 = list(self.processed_data[ligand].keys())[-1] - pIC50_value = self.processed_data[ligand][pIC50] - kvalues[ligand]={IC50:IC50_value, pIC50:pIC50_value} - self.constants = kvalues - return kvalues - - def PotencyToDict(self): - ''' - Convert potencies into a dictionary. - ''' - #dependencies - if self.processed_data == None: raise TypeError('Simulation data unprocessed. simulation.inhibition.analysis() must be run first.') - - kvalues={} - for ligand in self.processed_data: - IC50 = list(self.processed_data[ligand].keys())[-2] - IC50_value = self.processed_data[ligand][IC50] - pIC50 = list(self.processed_data[ligand].keys())[-1] - pIC50_value = self.processed_data[ligand][pIC50] - kvalues[ligand]={IC50:IC50_value, pIC50:pIC50_value} - return kvalues - - def Potency(self): - ''' - Return the potency values as a pandas DataFrame. - ''' - import pandas as pd - data = simulation.inhibition.PotencyToDict(self) - df = pd.DataFrame.from_dict(data, orient='index') - return df - - def PotencyToCSV(self, path): - ''' - Exports the potency values into csv format. - - :parameter path: Required (kwarg str): directory path to save the csv file - ''' - data = simulation.inhibition.PotencyToDict(self) - df = pd.DataFrame.from_dict(data, orient='index') - df.to_csv(path, index=False) - return - - class fitModel: - """ - Fit a model to experimental data. - - .. note:: This class was developed to reproduce data from a specific experimental setup. Please see tutorial 4 (OXTR pathay). Use carefully! - """ - def __init__(self): - - #fitting parameters - self._expratio = None - self._seed = None - self._maxiter = None - self._seed_incrementor = None - self._target_parameter = None - - #Pathway parameters - self._ttotal = None - self._nsteps = None - self._pathway = None - self._observable = None - self.pathway_parameters = {} - - def SetSimulationParameters(self, **kwargs): - """ - :parameter pathway_parameters: Required (kwargs): dict of pathway parameters - :parameter pathway: Required (kwargs str): name of the pathway ('Gs', 'Gi', 'Gq') - :parameter ttotal: Required (kwargs int): simulation time (seconds) - :parameter nsteps: Required (kwargs int): simulation time step - :parameter observable: Required (kwargs str): molecular specie to be measured - - :return: instances of all parameters - - """ - - if 'pathway_parameters' in kwargs: - self.pathway_parameters = kwargs.pop('pathway_parameters') - #print('pathway_parameters YES') - self._DefaultPathwayParametersDataFrame=pd.DataFrame() - if 'ttotal' in kwargs: - self._ttotal = int(kwargs.pop('ttotal')) - print('ttotal =', self._ttotal) - else: raise TypeError("ttotal undefined.") - - if 'nsteps' in kwargs: - self._nsteps = int(kwargs.pop('nsteps', 1000)) - print('nsteps =', self._nsteps) - - if 'pathway' in kwargs: - self._pathway = str(kwargs.pop('pathway')) - print('pathway ->', self._pathway) - else: raise TypeError("pathway undefined.") - - available_pathways = ['Gs', 'Gi', 'Gq', 'OXTR_pathway'] - if self._pathway == 'Gz(Gi)': self._pathway = 'Gi' - if self._pathway not in available_pathways: raise Exception('Unvailable Pathway. Please, introduce it manually. Networs available: "Gs", "Gi", "Gq".') - - - if'observable' in kwargs: - self._observable = str(kwargs.pop('observable')) - print('observable ->', self._observable) - else: raise TypeError("observable undefined.") - - return - - def PathwayParameters(self): - """ - Display table with default pathway parameters. - - .. warning:: this functions requires the qgrid library. It doens't work on Google Colab. - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv('src/lib/pathways/{}_parameters.csv'.format(self._pathway)) - - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def UserPathwayParameters(self, path): - """ - Import user pathway parameters. - - :parameter path: Required (kwarg str): directory path - """ - import qgrid - self._DefaultPathwayParametersDataFrame = pd.read_csv(path) - col_opts = { 'editable': False, 'sortable':False} - col_defs = {'Value': { 'editable': True, 'width': 150 }} - self._DefaultPathwayParametersTable = qgrid.show_grid(self._DefaultPathwayParametersDataFrame, column_options=col_opts,column_definitions=col_defs) - return self._DefaultPathwayParametersTable - - def PathwayParametersToCSV(self, path): - """ - Export pathway parameters into CSV format. - - :parameter path: Required (kwarg str): directory path - """ - self._DefaultPathwayParametersTable.get_changed_df().to_csv(path, index=False) - print('saved in:', path) - return - - def Reactions(self): - """ - Display pathway reactions. - """ - from IPython.display import display, HTML - display(HTML("<style>.container {width:90% !important}</style>")) - return pd.read_csv('src/lib/pathways/{}_reactions.csv'.format(self._pathway)) - - def Run(self, **kwargs): - """ - Fits of the model to experimental data. - - :parameter expratio: Required (kwargs flt): experimental signalling specie concentration ratio - :parameter target_parameter: Required (kwargs str):kinetic parameter to me modified - :parameter maxiter: Required (kwargs int): maximum number of iteration - :parameter seed: Required (kwargs flt): ramdom seed for scaling the modified parameter - :parameter seed_incrementor: Required (kwargs flt): seed incrementor (each iteration will increment the seed by this value) - :parameter seed_decrementor: Required (kwargs flt): seed decrementor (each iteration will decrement the seed by this value) - - """ - - from scipy.signal import find_peaks - import decimal - #fitting parameters - if 'expratio' in kwargs: - self._expratio = float(kwargs.pop('expratio')) - print('expratio =', self._expratio) - else: raise TypeError("exratio undefined.") - - if 'seed' in kwargs: - self._seed = float(kwargs.pop('seed')) - print('seed =', self._seed) - else: raise TypeError("seed undefined.") - - if 'maxiter' in kwargs: - self._maxiter = int(kwargs.pop('maxiter', 100)) - print('maxiter =', self._maxiter) - - if 'seed_incrementor' in kwargs: - self._seed_incrementor = float(kwargs.pop('seed_incrementor', 0.1)) - print('seed_incrementor =', self._seed_incrementor) - - if 'seed_decrementor' in kwargs: - self._seed_decrementor = float(kwargs.pop('seed_decrementor', 0.1)) - print('seed_decrementor =', self._seed_decrementor) - - if 'target_parameter' in kwargs: - self._target_parameter = str(kwargs.pop('target_parameter')) - print('target_parameter ->', self._target_parameter) - else: raise TypeError("target_parameter undefined.") - - - #Get default pathway parameters - if self._DefaultPathwayParametersDataFrame.empty and self.pathway_parameters==None: - self._DefaultPathwayParametersDataFrame = pd.read_csv('src/lib/pathways/{}_parameters.csv'.format(self._pathway)) - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty is False and self.pathway_parameters is None: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = newparameters.set_index('Parameter').iloc[:,0].to_dict() - except: - self._PathwayParameters = self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict() - - elif self._DefaultPathwayParametersDataFrame.empty and self.pathway_parameters is not None: - self._DefaultPathwayParametersDataFrame = pd.read_csv('src/lib/pathways/{}_parameters.csv'.format(self._pathway)) - self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self.pathway_parameters} - - elif self._DefaultPathwayParametersDataFrame.empty is False and self.pathway_parameters is not None: - try: - #extract data from qgrid - newparameters = self._DefaultPathwayParametersTable.get_changed_df() - self._PathwayParameters = {**newparameters.set_index('Parameter').iloc[:,0].to_dict(), **self.pathway_parameters} - except: - self._PathwayParameters = {**self._DefaultPathwayParametersDataFrame.set_index('Parameter').iloc[:,0].to_dict(), **self.pathway_parameters} - - - - #simulation parameters: - if not self._ttotal: - raise TypeError("simulation parameters unknown. Set the the simulation parameters first wiht set_simulation_parameters()") - - #Main function - mypathway = importlib.import_module('.'+self._pathway, package='src.lib.pathways') - self.simtime = pl.geomspace(0.00001, self._ttotal, num=self._nsteps) - - #Simulation 1 - pathway_model = mypathway.network(LR=None, kinetics=True, **self._PathwayParameters) - sim1 = ScipyOdeSimulator(pathway_model, tspan=self.simtime,compiler='cython').run() - self.simres1 = sim1.all - - def calc_ratio(self): - - - #Simulation 2 - sim2 = ScipyOdeSimulator(mypathway.network(**self.new_pathway_parameters), tspan=self.simtime, compiler='cython').run() - self.simres2 = sim2.all - - #analysis - obs_name = 'obs_'+self._observable - obs_1 = self.simres1[obs_name] - obs_2 = self.simres2[obs_name] - - if 'time_in' in self.new_pathway_parameters: - self._time = np.take(self.simtime, np.where(self.simtime > int(self.new_pathway_parameters['time_in'])))[0] - obs_curve_1 = np.take(obs_1, np.where(self.simtime > int(self.new_pathway_parameters['time_in'])))[0] - obs_curve_2 = np.take(obs_2, np.where(self.simtime > int(self.new_pathway_parameters['time_in'])))[0] - - else: - self._time = np.take(self.simtime, np.where(self.simtime>0))[0] - obs_curve_1 = np.take(obs_1, np.where(self.simtime > 0))[0] - obs_curve_2 = np.take(obs_2, np.where(self.simtime > 0))[0] - - obs_peaks_1, _ = find_peaks(obs_curve_1) - obs_peaks_2, _ = find_peaks(obs_curve_2) - - vmax_obs_curve_1 = obs_curve_1[obs_peaks_1][-1]*1E3 - vmax_obs_curve_2 = obs_curve_2[obs_peaks_2][-1]*1E3 - - obs_ratio = round(vmax_obs_curve_2/vmax_obs_curve_1, abs(decimal.Decimal(str(self._expratio).rstrip('0')).as_tuple().exponent)) - - self._obs_curve_1=obs_curve_1 - self._obs_curve_2=obs_curve_2 - self._obs_peaks_1=obs_peaks_1 - self._obs_peaks_2=obs_peaks_2 - self._vmax_obs_curve_1=vmax_obs_curve_1 - self._vmax_obs_curve_2=vmax_obs_curve_2 - - return obs_ratio - - self._iteration=1 - print('\n') - - self._lst_ratio=[] - self._lst_seed=[] - - for idx in range(self._maxiter): - - prefix = 'iteration' - iteration_n = str(self._iteration) - print(f'\r{prefix} {iteration_n}', end='\r') - - self.new_pathway_parameters={**self._PathwayParameters, **{self._target_parameter:mypathway.defaultParameters[self._target_parameter]*self._seed}} - self.obs_ratio = calc_ratio(self) - - if self.obs_ratio == self._expratio: - self._lst_ratio.append(self.obs_ratio) - self._lst_seed.append(self._seed) - self._fold=round(self._seed, abs(decimal.Decimal(str(self._expratio).rstrip('0')).as_tuple().exponent)) - print('\n\nDONE!\n', '\nRatio: '+str(self.obs_ratio), '\nFOLD: '+str(self._fold), '\nNumber of iterations: '+str(self._iteration)) - break - elif self.obs_ratio < self._expratio: - - self._lst_ratio.append(self.obs_ratio) - self._lst_seed.append(self._seed) - self._iteration+=1 - self._seed += self._seed_incrementor - - else: - self._lst_ratio.append(self.obs_ratio) - self._lst_seed.append(self._seed) - - - self._iteration+=1 - self._seed -= self._seed_decrementor - - return - - def plotIterations(self, save=False, filename=None): - ''' - Plot iterations. - ''' - import plotly.offline as pyoff - #dependencies - if self._iteration == None: raise TypeError('Simulation data not exist. simulation.fitModel.run() must be run first.') - - #import plotly - import plotly.graph_objs as go - - iterations = np.arange(1,self._iteration+1) - - trace=dict(type='scatter', x=self._lst_seed, y=self._lst_ratio, mode='markers', - marker=dict(color= iterations, colorscale='Bluered_r', size=14, colorbar=dict(thickness=20, title='iteration number'))) - #axis_style=dict(zeroline=False, showline=True, mirror=True) - layout = dict(title = '', - xaxis = dict( - title = 'seed', - titlefont=dict( - size=20 - ), - tickfont=dict( - size=20 - )), - yaxis = dict( - title = '['+self._observable+']' + ' ratio', - titlefont=dict( - size=20), - tickfont=dict( - size=20) - - ), - legend=dict(font=dict(size=15)), - autosize=False, - width=850, - height=650 - ) - - fig = go.Figure(data=[trace], layout=layout) - if save==True: - if filename==None: - filename='plot.html' - return pyoff.plot(fig, filename=filename) - else: - ext = os.path.splitext(filename)[-1] - if ext == '.png': fig.write_image(filename, scale=3) - elif ext == '.html': pyoff.plot(fig, filename=filename) - else: raise TypeError("extension not valid. Use png or html.") - elif save ==False: return fig - return fig - - def plotCurves(self, save=False, filename=None): - ''' - Plot the amount of obeservable in function of time, Amplitude, Area Under the Curve, and Full Width at Half Maximum. - - :parameter save: Optional (kwarg boolean): default False - :parameter filename: Optional (kwarg str) - ''' - - from IPython.core.display import display, HTML - display(HTML("<style>.container { width:90% !important; }</style>")) - - - from plotly.subplots import make_subplots - from scipy.signal import peak_widths - from sklearn import metrics - import plotly.offline as pyoff - - - half_1 = peak_widths(self._obs_curve_1, self._obs_peaks_1, rel_height=0.5) - half_2 = peak_widths(self._obs_curve_2, self._obs_peaks_2, rel_height=0.5) - fwhm_1 = self._time[int(half_1[3])]-self._time[int(half_1[2])] - fwhm_2 = self._time[int(half_2[3])]-self._time[int(half_2[2])] - - - fig = make_subplots(rows=2, cols=2,vertical_spacing=0.15, - subplot_titles=("{} concentration".format(self._observable), "Amplitude", "Area under the curve", "Full Width at Half Maximum")) - - #################### - #### MAIN PLOT #### - #################### - fig.add_trace(go.Scatter(x=self._time, y=self._obs_curve_1*1E3, name='control'), row=1, col=1) - fig.add_trace(go.Scatter(x=self._time, y=self._obs_curve_2*1E3, name='{}-fold'.format(self._fold)), row=1, col=1) - fig.add_trace(go.Scatter(x=self._time[self._obs_peaks_1], y=self._obs_curve_1[self._obs_peaks_1]*1E3, - name='max value', showlegend=False, mode='markers', - marker=dict(symbol='x', size=13, color='Black')), row=1,col=1) - fig.add_trace(go.Scatter(x=self._time[self._obs_peaks_2], y=self._obs_curve_2[self._obs_peaks_2]*1E3, - name='max value', showlegend=False, mode='markers', - marker=dict(symbol='x', size=13, color='Black')), row=1,col=1) - fig.add_shape(type='line', x0=self._time[int(half_1[2])],y0=half_1[1][0]*1E3, x1=self._time[int(half_1[3])], y1=half_1[1][0]*1E3, - line=dict(color='Blue',dash='dash'),xref='x',yref='y', row=1, col=1) - fig.add_shape(type='line', x0=self._time[int(half_2[2])],y0=half_2[1][0]*1E3, x1=self._time[int(half_2[3])], y1=half_2[1][0]*1E3, - line=dict(color='Red',dash='dash'),xref='x',yref='y', row=1, col=1) - - # Update xaxis properties - fig.update_xaxes(title_text="Time (s)", showgrid=False, row=1, col=1, titlefont=dict(size=18), - linecolor='black', linewidth=2, - ticks='inside', tickfont=dict(size=18), tickcolor='black', ticklen=10, tickwidth=2) - - fig.update_yaxes(title_text=self._observable+' (nM)', titlefont=dict(size=18), showgrid=False, row=1, col=1, - linecolor='black', linewidth=2, - ticks='inside', tickfont=dict(size=18), tickcolor='black', ticklen=10, tickwidth=2) - - - #################### - #### AMPLITUDE #### - #################### - - AMP_labels = [1,2] - AMP_values = [self._vmax_obs_curve_1, self._vmax_obs_curve_2] - fig.add_trace(go.Bar(x=AMP_labels,y=AMP_values, width = [0.35,0.35], showlegend=False, marker_color='black', name=''), row=1, col=2 ) - - - - # Update xaxis properties - fig.update_xaxes(row=1, col=2, showgrid=False, linecolor='black', linewidth=2, range=[0,3], - tickmode='array', tickvals=[1,2], ticktext=['control', '{}-fold'.format(self._fold)], tickfont=dict(size=18)) - - fig.update_yaxes(showgrid=False, range=[round((min(AMP_values)-min(AMP_values)*0.5)/5)*5,round((max(AMP_values)+max(AMP_values)*0.5)/5)*5 ], row=1, col=2, - title_text=self._observable+' (nM)', titlefont=dict(size=18), - linecolor='black', linewidth=2, ticks='inside', ticklen=10, tickwidth=2, tickfont=dict(size=18)) - - # Add diff lines - AMP_diffs = [max(AMP_values) - v for v in AMP_values] - AMP_diff_labels = dict(zip(AMP_labels, AMP_diffs)) - fig.add_trace(go.Scatter(name='',x=[1,1.5,2], y=[max(AMP_values)+(max(AMP_values)*0.3)]*3, mode = 'lines+text',showlegend=False, line=dict(color='black', width=1),text=['', 'diff. = {} nM'.format(round(AMP_diffs[0], 3)),''], textposition='top center'), row=1, col=2) - fig.add_trace(go.Scatter(name='',x=[AMP_labels[0]-0.175, AMP_labels[0]+0.175], y=[AMP_values[0]+(AMP_values[0]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) - fig.add_trace(go.Scatter(name='',x=[AMP_labels[1]-0.175, AMP_labels[1]+0.175], y=[AMP_values[1]+(AMP_values[1]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) - fig.add_trace(go.Scatter(name='',x=[AMP_labels[0], AMP_labels[0]], y=[AMP_values[0]+(AMP_values[0]*0.03), max(AMP_values)+(max(AMP_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) - fig.add_trace(go.Scatter(name='',x=[AMP_labels[1], AMP_labels[1]], y=[AMP_values[1]+(AMP_values[1]*0.03), max(AMP_values)+(max(AMP_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=1, col=2) - - - #################### - #### AUC #### - #################### - - # Data - AUC_labels = [1,2] - AUC_values = [round(metrics.auc(self._time, self._obs_curve_1),2), round(metrics.auc(self._time, self._obs_curve_2),2)] - fig.add_trace(go.Bar(x=AUC_labels,y=AUC_values, width = [0.35,0.35], showlegend=False, marker_color='black', name=''), row=2, col=1 ) - - # Update xaxis properties - fig.update_xaxes(row=2, col=1, tickmode='array', showgrid=False, range=[0,3], linecolor='black', linewidth=2, - tickvals=[1,2], ticktext=['control', '{}-fold'.format(self._fold)], tickfont=dict(size=18)) - - fig.update_yaxes(row=2, col=1,showgrid=False, title_text=self._observable+' (nM)', range=[round((min(AUC_values)-min(AUC_values)*0.5)/5)*5,round((max(AUC_values)+max(AUC_values)*0.5)/5)*5], - titlefont=dict(size=18),linecolor='black', linewidth=2, - ticks='inside', tickfont=dict(size=18),ticklen=10, tickwidth=2) - - # Add diff lines - AUC_diffs = [max(AUC_values) - v for v in AUC_values] - AUC_diff_labels = dict(zip(AUC_labels, AUC_diffs)) - fig.add_trace(go.Scatter(name='',x=[1,1.5,2], y=[max(AUC_values)+(max(AUC_values)*0.3)]*3, mode = 'lines+text',showlegend=False, - line=dict(color='black', width=1), text=['', 'diff. = {} nM'.format(round(AUC_diffs[0], 3)),''], textposition='top center'), row=2, col=1) - fig.add_trace(go.Scatter(name='',x=[AUC_labels[0]-0.175, AUC_labels[0]+0.175], y=[AUC_values[0]+(AUC_values[0]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) - fig.add_trace(go.Scatter(name='',x=[AUC_labels[1]-0.175, AUC_labels[1]+0.175], y=[AUC_values[1]+(AUC_values[1]*0.03)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) - fig.add_trace(go.Scatter(name='',x=[AUC_labels[0], AUC_labels[0]], y=[AUC_values[0]+(AUC_values[0]*0.03), max(AUC_values)+(max(AUC_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) - fig.add_trace(go.Scatter(name='',x=[AUC_labels[1], AUC_labels[1]], y=[AUC_values[1]+(AUC_values[1]*0.03), max(AUC_values)+(max(AUC_values)*0.3)], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=1) - - - #################### - #### FWHM #### - #################### - # Data - FWHM_labels = [1,2] - FWHM_values = [fwhm_1, fwhm_2] - fig.add_trace(go.Bar(x=FWHM_labels,y=FWHM_values, width = [0.35,0.35], showlegend=False,marker_color='black', name=''), row=2, col=2 ) - - # Update xaxis properties - fig.update_xaxes(row=2, col=2, showgrid=False, range=[0,3], linecolor='black', linewidth=2, - tickmode='array', tickvals=[1,2], ticktext=['control', '{}-fold'.format(self._fold)], tickfont=dict(size=18)) - - fig.update_yaxes(row=2, col=2, showgrid=False, range=[self.pathway_parameters['time_in'],round((max(FWHM_values)+(max(FWHM_values)-self.pathway_parameters['time_in'])*0.5)/5)*5], - title_text='Time (s)', titlefont=dict(size=18), linecolor='black', linewidth=2, - ticks='inside', ticklen=10, tickwidth=2, tickfont=dict(size=18)) - - # Add diff lines - FWHM_diffs = [max(FWHM_values) - v for v in FWHM_values] - FWHM_diff_labels = dict(zip(FWHM_labels, FWHM_diffs)) - line_height = max(FWHM_values)+((max(FWHM_values)-self.pathway_parameters['time_in'])*0.30) - fig.add_trace(go.Scatter(x=[1,1.5,2], y=[line_height]*3, mode = 'lines+text',showlegend=False, line=dict(color='black', width=1),name='', - text=['', 'diff. = {} s'.format(round(FWHM_diffs[0], 3)),''], textposition='top center'), row=2, col=2) - fig.add_trace(go.Scatter(name='',x=[FWHM_labels[0]-0.175, FWHM_labels[0]+0.175], y=[FWHM_values[0]+(FWHM_values[0]*0.005)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) - fig.add_trace(go.Scatter(name='',x=[FWHM_labels[1]-0.175, FWHM_labels[1]+0.175], y=[FWHM_values[1]+(FWHM_values[1]*0.005)]*2, mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) - fig.add_trace(go.Scatter(name='',x=[FWHM_labels[0], FWHM_labels[0]], y=[FWHM_values[0]+(FWHM_values[0]*0.005), line_height], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) - fig.add_trace(go.Scatter(name='',x=[FWHM_labels[1], FWHM_labels[1]], y=[FWHM_values[1]+(FWHM_values[1]*0.005), line_height], mode = 'lines',showlegend=False, line=dict(color='black', width=1)), row=2, col=2) - - - #################### - #### FIGURE #### - #################### - - fig.update_layout(height=1200, width=1300, title_text="", plot_bgcolor='white',showlegend=True, - legend=dict(yanchor="top", x=0.3, y=.99,font=dict(family="sans-serif", size=14,color="black"))) - fig.update_annotations(font_size=20, font_color='black') - - if save==True: - if filename==None: - filename='plot.html' - return pyoff.plot(fig, filename=filename) - else: - ext = os.path.splitext(filename)[-1] - if ext == '.png': fig.write_image(filename, scale=3) - elif ext == '.html': pyoff.plot(fig, filename=filename) - else: raise TypeError("extension not valid. Use png or html.") - elif save ==False: return fig - - return -