Ejemplo n.º 1
0
def test_simeval(testdata):
    orig = Model(testdata / 'nonmem' / 'pheno.mod')
    base = Model(testdata / 'nonmem' / 'qa' / 'pheno_linbase.mod')
    simeval_res = read_results(testdata / 'nonmem' / 'qa' /
                               'simeval_results.json')
    cdd_res = read_results(testdata / 'nonmem' / 'qa' / 'cdd_results.json')
    calculate_results(orig,
                      base,
                      simeval_results=simeval_res,
                      cdd_results=cdd_res)
Ejemplo n.º 2
0
def test_tdist(testdata):
    orig = Model(testdata / 'nonmem' / 'pheno.mod')
    base = Model(testdata / 'nonmem' / 'qa' / 'pheno_linbase.mod')
    td = Model(testdata / 'nonmem' / 'qa' / 'tdist.mod')
    res = calculate_results(orig, base, tdist_model=td)
    correct = """df,new_sd,old_sd
ETA(1),3.77,0.344951,0.333246
ETA(2),3.77,0.400863,0.448917
"""
    correct = pd.read_csv(StringIO(correct), index_col=[0])
    pd.testing.assert_frame_equal(res.tdist_parameters, correct)

    assert res.dofv['dofv']['parameter_variability', 'tdist',
                            np.nan] == pytest.approx(730.89472681373070 -
                                                     729.45800311609150)
    assert res.dofv['df']['parameter_variability', 'tdist', np.nan] == 2

    res = calculate_results(orig, base, tdist_model=None)
Ejemplo n.º 3
0
def test_boxcox(testdata):
    orig = Model(testdata / 'nonmem' / 'pheno.mod')
    base = Model(testdata / 'nonmem' / 'qa' / 'pheno_linbase.mod')
    bc = Model(testdata / 'nonmem' / 'qa' / 'boxcox.mod')
    res = calculate_results(orig, base, boxcox_model=bc)
    correct = """lambda,new_sd,old_sd
ETA(1),-1.581460,0.296257,0.333246
ETA(2),0.645817,0.429369,0.448917
"""
    correct = pd.read_csv(StringIO(correct), index_col=[0])
    pd.testing.assert_frame_equal(res.boxcox_parameters, correct)

    assert res.dofv['dofv']['parameter_variability', 'boxcox',
                            np.nan] == pytest.approx(730.89472681373070 -
                                                     721.78812733817688)
    assert res.dofv['df']['parameter_variability', 'boxcox', np.nan] == 2

    res = calculate_results(orig, base, boxcox_model=None)
    assert res.boxcox_parameters is None
Ejemplo n.º 4
0
def test_fullblock(testdata):
    orig = Model(testdata / 'nonmem' / 'pheno.mod')
    base = Model(testdata / 'nonmem' / 'qa' / 'pheno_linbase.mod')
    fb = Model(testdata / 'nonmem' / 'qa' / 'fullblock.mod')
    res = calculate_results(orig, base, fullblock_model=fb)
    correct = """,new,old
"OMEGA(1,1)",0.486600,0.333246
"OMEGA(2,1)",0.846728,NaN
"OMEGA(2,2)",0.423262,0.448917
"""
    correct = pd.read_csv(StringIO(correct), index_col=[0])
    pd.testing.assert_frame_equal(res.fullblock_parameters, correct)

    assert res.dofv['dofv']['parameter_variability', 'fullblock',
                            np.nan] == pytest.approx(730.89472681373070 -
                                                     706.36113798726512)
    assert res.dofv['df']['parameter_variability', 'fullblock', np.nan] == 1

    res = calculate_results(orig, base, fullblock_model=None)
    assert res.fullblock_parameters is None
Ejemplo n.º 5
0
def test_iov(testdata):
    orig = Model(testdata / 'nonmem' / 'pheno.mod')
    base = Model(testdata / 'nonmem' / 'qa' / 'pheno_linbase.mod')
    iov = Model(testdata / 'nonmem' / 'qa' / 'iov.mod')
    res = calculate_results(orig, base, iov_model=iov)
    correct = """new_iiv_sd,orig_iiv_sd,iov_sd
ETA(1),0.259560,0.333246,0.555607
ETA(2),0.071481,0.448917,0.400451
"""
    correct = pd.read_csv(StringIO(correct), index_col=[0])
    pd.testing.assert_frame_equal(res.iov_parameters, correct)

    assert res.dofv['dofv']['parameter_variability', 'iov',
                            np.nan] == pytest.approx(42.314986)
    assert res.dofv['df']['parameter_variability', 'iov', np.nan] == 2
Ejemplo n.º 6
0
def test_scm(testdata):
    orig = Model(testdata / 'nonmem' / 'pheno.mod')
    base = Model(testdata / 'nonmem' / 'qa' / 'pheno_linbase.mod')
    scm_res = read_results(testdata / 'nonmem' / 'qa' / 'scm_results.json')
    res = calculate_results(orig, base, scm_results=scm_res)
    correct = """,,dofv,coeff
ETA(1),APGR,2.48792,-0.033334
ETA(1),WGT,0.48218,0.052342
ETA(2),APGR,0.59036,0.008371
ETA(2),WGT,0.00887,-0.003273
"""
    correct = pd.read_csv(StringIO(correct), index_col=[0, 1])
    correct.index.set_names(['parameter', 'covariate'], inplace=True)
    pd.testing.assert_frame_equal(res.covariate_effects, correct, atol=1e-6)
    assert res.dofv['dofv']['covariates', 'ET1APGR-2',
                            np.nan] == pytest.approx(2.48792)
    assert res.dofv['df']['covariates', 'ET1APGR-2', np.nan] == 1
Ejemplo n.º 7
0
def test_resmod(testdata):
    orig = Model(testdata / 'nonmem' / 'pheno.mod')
    base = Model(testdata / 'nonmem' / 'qa' / 'pheno_linbase.mod')
    resmod_res = read_results(testdata / 'nonmem' / 'qa' /
                              'resmod_results.json')
    res = calculate_results(orig, base, resmod_idv_results=resmod_res)
    assert list(
        res.residual_error['additional_parameters']) == [2, 2, 1, 1, 1, 1]
    assert list(
        res.residual_error['dOFV']) == [13.91, 8.03, 5.53, 3.34, 1.31, 0.03]
    assert res.residual_error.index.tolist() == [
        (1, 'dtbs'),
        (1, 'time_varying'),
        (1, 'tdist'),
        (1, 'autocorrelation'),
        (1, 'IIV_on_RUV'),
        (1, 'power'),
    ]
    assert res.dofv['dofv']['residual_error_model', 'dtbs',
                            1] == pytest.approx(13.91)
Ejemplo n.º 8
0
def test_add_etas(testdata):
    orig = Model(testdata / 'nonmem' / 'pheno.mod')
    base = Model(testdata / 'nonmem' / 'qa' / 'pheno_linbase.mod')
    add_etas = Model(testdata / 'nonmem' / 'qa' / 'add_etas_linbase.mod')
    res = calculate_results(orig,
                            base,
                            add_etas_model=add_etas,
                            etas_added_to=['CL', 'V'])
    correct = """added,new_sd,orig_sd
ETA(1),True,0.338974,0.333246
ETA(2),True,0.449430,0.448917
CL,False,0.010001,NaN
V,False,0.010000,NaN
"""
    correct = pd.read_csv(StringIO(correct), index_col=[0])
    pd.testing.assert_frame_equal(res.add_etas_parameters, correct, atol=1e-6)

    assert res.dofv['dofv']['parameter_variability', 'add_etas',
                            np.nan] == pytest.approx(730.89472681373070 -
                                                     730.84697789365532)
    assert res.dofv['df']['parameter_variability', 'add_etas', np.nan] == 2
Ejemplo n.º 9
0
def test_resmod_dvid(testdata):
    orig = Model(testdata / 'nonmem' / 'pheno.mod')
    base = Model(testdata / 'nonmem' / 'qa' / 'pheno_linbase.mod')
    resmod_res = psn_resmod_results(testdata / 'psn' / 'resmod_dir2')
    res = calculate_results(orig, base, resmod_idv_results=resmod_res)
    assert res.residual_error.loc[("4", "tdist"), 'dOFV'] == 2.41