Saving an epistasis model ========================= All epistasis models/simulators store epistatic coefficients in Pandas_ Series/DataFrames, so the coefficients can be written to various file formats. This page lists a few. .. _Pandas: http://pandas.pydata.org/ Pickle ------ The recommended way to save an epistasis model to be used again is by **pickling** the model(See Python's ``pickle`` library). .. code-block:: python # Import pickle module import pickle from epistasis.models import EpistasisLinearRegression # Simple model object model = EpistasisLinearRegression(model=1) # Save to disk to open later. with open('model.pickle', 'wb') as f: pickle.dump(f, model) To load the saved model, .. code-block:: python # Import pickle module import pickle # Read from file. with open('model.pickle', 'rb') as f: model = pickle.load(f) .. warning:: Pickled models will only work with the same version of the ``epistasis`` package that created it. If you save a model and upgrade the library, you likely won't be able to use the model anymore. Excel Spreadsheet ----------------- Epistatic coefficients can be written to an excel file using the ``to_excel`` method .. code-block:: python model.to_excel('data.xlsx') .. raw:: html
sites | values | |
---|---|---|
0 | [0] | 0.501191 |
1 | [1] | -0.600019 |
2 | [2] | 0.064983 |
3 | [3] | 0.609166 |
4 | [4] | 0.242095 |
5 | [1, 2] | 0.286914 |
6 | [1, 3] | -0.264455 |
7 | [1, 4] | -0.464212 |
8 | [2, 3] | 0.638260 |
9 | [2, 4] | 0.235989 |
10 | [3, 4] | 0.717954 |
11 | [1, 2, 3] | -0.473122 |
12 | [1, 2, 4] | -0.041919 |
13 | [1, 3, 4] | -0.309124 |
14 | [2, 3, 4] | 0.606674 |
15 | [1, 2, 3, 4] | -0.268982 |