示例#1
0
def test_musyc_no_gamma():
    import numpy as np
    from synergy.combination import MuSyC
    from synergy.utils.dose_tools import grid

    E0, E1, E2, E3 = 1, 0.2, 0.1, 0
    h1, h2 = 2.3, 0.8
    C1, C2 = 1e-2, 1e-1
    alpha12, alpha21 = 3.2, 1.1

    model = MuSyC(E0=E0,
                  E1=E1,
                  E2=E2,
                  E3=E3,
                  h1=h1,
                  h2=h2,
                  C1=C1,
                  C2=C2,
                  alpha12=alpha12,
                  alpha21=alpha21,
                  variant="no_gamma")

    npoints = 8
    npoints2 = 12

    D1, D2 = grid(1e-3, 1e0, 1e-2, 1e1, npoints, npoints2)

    np.random.seed(0)
    E = model.E(D1, D2)
    Efit = E * (1 + (np.random.rand(len(D1)) - 0.5) / 10.)

    model.fit(D1, D2, Efit)

    assert model.r_squared > 0.9
示例#2
0
def test_musyc_higher():
    import numpy as np
    from synergy.utils import dose_tools
    from synergy.higher import MuSyC
    from synergy.utils import plots

    E_params = [2, 1, 1, 1, 1, 0, 0, 0]
    h_params = [2, 1, 0.8]
    C_params = [0.1, 0.01, 0.1]
    alpha_params = [2, 3, 1, 1, 0.7, 0.5, 2, 1, 1]
    gamma_params = [0.4, 2, 1, 2, 0.7, 3, 2, 0.5, 2]

    params = E_params + h_params + C_params + alpha_params + gamma_params

    truemodel = MuSyC()
    truemodel.parameters = params

    d = dose_tools.grid_multi((1e-3, 1e-3, 1e-3), (1, 1, 1), (6, 6, 6),
                              include_zero=True)

    d1 = d[:, 0]
    d2 = d[:, 1]
    d3 = d[:, 2]
    np.random.seed(0)
    E = truemodel.E(d)
    noise = 0.05
    E_fit = E + noise * (E_params[0] -
                         E_params[-1]) * (2 * np.random.rand(len(E)) - 1)

    model = MuSyC(E_bounds=(0, 2),
                  h_bounds=(1e-3, 1e3),
                  alpha_bounds=(1e-5, 1e5),
                  gamma_bounds=(1e-5, 1e5))
    model.fit(d, E_fit)

    assert model.r_squared > 0.9
示例#3
0
                         npoints,
                         npoints2,
                         replicates=replicates,
                         include_zero=True)

D1 = D1 / 3.

E = model.E(D1, D2)
Efit = E * (1 + (np.random.rand(len(D1)) - 0.5) / 5.)

scatter_points = pd.DataFrame({
    'drug1.conc': D1,
    'drug2.conc': D2,
    'effect': Efit
})
model.fit(D1, D2, Efit)

D1, D2 = dose_tools.grid(1e-3,
                         1,
                         1e-2,
                         10,
                         npoints * 10,
                         npoints2 * 10,
                         include_zero=True)
D1 = D1 / 3

model.plot_surface_plotly(D1,
                          D2,
                          scatter_points=scatter_points,
                          xlabel="Drug1",
                          ylabel="Drug2",
示例#4
0
npoints2 = 8
d1, d2 = grid(C1 / 1e2,
              C1 * 1e2,
              C2 / 1e2,
              C2 * 1e2,
              npoints,
              npoints2,
              include_zero=True)

E = truemodel.E(d1, d2)

noise = 0.05
E_fit = E + noise * (E0 - E3) * (2 * np.random.rand(len(E)) - 1)

model = MuSyC()
model.fit(d1, d2, E_fit, bootstrap_iterations=100)

#print(model)
#if model.converged:
#    print(model.get_parameter_range().T)
print(model.summary())

if False:
    scatter_points = pd.DataFrame({
        'drug1.conc': d1,
        'drug2.conc': d2,
        'effect': E_fit
    })
    DD1, DD2 = grid(C1 / 1e4, C1 * 1e4, C2 / 1e4, C2 * 1e4, npoints * 2,
                    npoints2 * 2)
示例#5
0
schindler = Schindler()
s_synergy = schindler.fit(d1,
                          d2,
                          E,
                          drug1_model=loewe.drug1_model,
                          drug2_model=loewe.drug2_model)

bliss = Bliss()
bsynergy = bliss.fit(d1,
                     d2,
                     E,
                     drug1_model=loewe.drug1_model,
                     drug2_model=loewe.drug2_model)

musyc = MuSyC()
musyc.fit(d1, d2, E)

fig = plt.figure(figsize=(12, 3))

ax = fig.add_subplot(1, 4, 1)
musyc.plot_heatmap(d1, d2, ax=ax, logscale=False, title="Sham Surface")

ax = fig.add_subplot(1, 4, 2)
loewe.plot_heatmap(ax=ax,
                   title="-log(Loewe)",
                   vmin=-0.01,
                   vmax=0.01,
                   logscale=False,
                   neglog=True)
ax.set_yticks([])