

.. _sphx_glr_gallery_plot_nonlinear_regression.py:


Fitting nonlinear genotype-phenotype maps
=========================================

Use a linear, logistic regression model to estimate the positive/negative effects
of mutations.




.. image:: /gallery/images/sphx_glr_plot_nonlinear_regression_001.png
    :align: center





.. code-block:: python


    # Imports
    import matplotlib.pyplot as plt

    from gpmap.simulate import MountFujiSimulation

    from epistasis.models import EpistasisPowerTransform
    from epistasis.pyplot import plot_power_transform

    # The data
    gpm = MountFujiSimulation.from_length(4, field_strength=-1, roughness=(-1,1))

    # Initialize a model
    model = EpistasisPowerTransform(lmbda=1, A=0, B=0)
    model.add_gpm(gpm)

    # Fit the model
    model.fit()

    fig, ax = plt.subplots(figsize=(2.5,2.5))
    ax = plot_power_transform(model, ax=ax)
    plt.show()

**Total running time of the script:** ( 0 minutes  1.979 seconds)



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: plot_nonlinear_regression.py <plot_nonlinear_regression.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: plot_nonlinear_regression.ipynb <plot_nonlinear_regression.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
