

.. _sphx_glr_gallery_plot_logistic_regression.py:


Handling dead phenotypes
========================

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




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





.. code-block:: python


    # Imports
    import matplotlib.pyplot as plt

    from gpmap import GenotypePhenotypeMap
    from epistasis.models import EpistasisLogisticRegression
    from epistasis.pyplot import plot_coefs

    # The data
    wildtype = "000"
    genotypes = ['000', '001', '010', '011', '100', '101', '110', '111']
    phenotypes = [ 0.366, -0.593,  1.595, -0.753,  0.38 ,  1.296,  1.025, -0.519]
    gpm = GenotypePhenotypeMap(wildtype, genotypes, phenotypes)

    # Threshold
    threshold = 1.0

    # Initialize a model
    model = EpistasisLogisticRegression(threshold=threshold)
    model.add_gpm(gpm)

    # Fit the model
    model.fit()

    fig, ax = plot_coefs(model, figsize=(1,3))
    plt.show()

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



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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


.. only:: html

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

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