djwooten / synergy

Python library for calculting synergy of drug combinations using several drug synergy frameworks
GNU General Public License v3.0
27 stars 5 forks source link

mode.fit generates different values when executed in function #13

Open spencertr opened 2 years ago

spencertr commented 2 years ago

hi, thanks for sharing this amazing library. I am having trouble with running the fit in a slightly different scenario (wrapping it in a function). Can you please shed some light on this? Thank you.

similar way that was shown in the github:

(1)

model = MuSyC(E0_bounds=(0,1), E1_bounds=(0,1), E2_bounds=(0,1), E3_bounds=(0,1))
model.fit(df['drug1.conc'], df['drug2.conc'], df['effect'], bootstrap_iterations=100)
print(model._model)
model.plot_surface_plotly(df['drug1.conc'], df['drug2.conc'], xlabel="Drug1",   \
                           E = model.E(df['drug1.conc'], df['drug2.conc']),
                          ylabel="Drug2", zlabel="Effect", fname="plotly.html", \
                          scatter_points=df)

(2)

  def run_model(df,
              e0_bounds,
              e1_bounds,
              e2_bounds,
              e3_bounds):

    print('model running...')

    model = MuSyC(e0_bounds,
                  e1_bounds,
                  e2_bounds,
                  e3_bounds)

    model.fit(df['drug1.conc'], 
             df['drug2.conc'],
             df['effect'],
             bootstrap_iterations=100)

    print(model._model)
    model.plot_surface_plotly(df['drug1.conc'], df['drug2.conc'], xlabel="Drug1",   \
                           E = model.E(df['drug1.conc'], df['drug2.conc']),
                          ylabel="Drug2", zlabel="Effect", fname="plotly.html", \
                          scatter_points=df)

(1) Screen Shot 2022-03-18 at 17 26 35

(2) Screen Shot 2022-03-18 at 17 27 12

The E values are different:

(1)

array([[0.99234471, 0.99232517, 0.98983648, 0.78499822, 0.42663821,
        0.41895113, 0.41889069],
       [0.92745658, 0.92099986, 0.89843988, 0.72526569, 0.42578858,
        0.41866482, 0.41860817],
       [0.85404101, 0.84161908, 0.80186889, 0.65842245, 0.4226679 ,
        0.41630959, 0.416254  ],
       [0.73284317, 0.71298465, 0.65401291, 0.54405546, 0.40046613,
        0.39553146, 0.39544341],
       [0.58577002, 0.55600499, 0.47214075, 0.36395382, 0.27705488,
        0.27214091, 0.2717931 ],
       [0.4616021 , 0.4154494 , 0.29018871, 0.15299739, 0.09006842,
        0.08407883, 0.08332656],
       [0.38504124, 0.33486151, 0.20545397, 0.07816384, 0.03675587,
        0.03116274, 0.03030261]])

(2)

array([[1.17546891, 1.02594286, 0.91916416, 0.77681686, 0.62354652,
        0.49219075, 0.39989497],
       [0.9841819 , 0.88708001, 0.79841986, 0.64967837, 0.5410741 ,
        0.45209552, 0.38230723],
       [0.86079753, 0.79213061, 0.71485338, 0.56648383, 0.4829463 ,
        0.42031973, 0.36699584],
       [0.71099783, 0.67065761, 0.60671839, 0.46415404, 0.40637307,
        0.37308215, 0.34156684],
       [0.56590302, 0.54527555, 0.49229252, 0.35821869, 0.31813049,
        0.306914  , 0.29605938],
       [0.45306642, 0.43035406, 0.35145488, 0.13147678, 0.069242  ,
        0.06167019, 0.05727641],
       [0.37938355, 0.3650692 , 0.28926189, 0.073687  , 0.01705196,
        0.01320579, 0.01297481]])```