def test_estimate_fdr_digitize_works(): fdr = FDR(job_id=0, decoy_sample_size=1, target_adducts=['+H'], db=None) fdr.fdr_levels = [0.4, 0.8] fdr.td_df = pd.DataFrame([['C1', '+H', '+Cu'], ['C2', '+H', '+Ag'], ['C3', '+H', '+Cl'], ['C4', '+H', '+Co']], columns=['sf', 'ta', 'da']) msm_df = pd.DataFrame([['C1', '+H', 1.0], ['C2', '+H', 0.75], ['C3', '+H', 0.5], ['C4', '+H', 0.25], ['C1', '+Cu', 0.75], ['C2', '+Ag', 0.3], ['C3', '+Cl', 0.25], ['C4', '+Co', 0.1]], columns=['sf', 'adduct', 'msm']).set_index(['sf', 'adduct']).sort_index() exp_sf_df = pd.DataFrame([['C1', '+H', 0.4], ['C2', '+H', 0.4], ['C3', '+H', 0.4], ['C4', '+H', 0.8]], columns=['sf', 'adduct', 'fdr']).set_index(['sf', 'adduct']) assert_frame_equal(fdr.estimate_fdr(msm_df), exp_sf_df)
def test_estimate_fdr_returns_correct_df(): fdr = FDR(job_id=0, decoy_sample_size=2, target_adducts=['+H'], db=None) fdr.fdr_levels = [0.2, 0.8] fdr.td_df = pd.DataFrame([['H2O', '+H', '+Cu'], ['H2O', '+H', '+Co'], ['C2H2', '+H', '+Ag'], ['C2H2', '+H', '+Ar']], columns=['sf', 'ta', 'da']) msm_df = pd.DataFrame( [['H2O', '+H', 0.85], ['C2H2', '+H', 0.5], ['H2O', '+Cu', 0.5], ['H2O', '+Co', 0.5], ['C2H2', '+Ag', 0.75], ['C2H2', '+Ar', 0.0]], columns=['sf', 'adduct', 'msm']).set_index(['sf', 'adduct']).sort_index() exp_sf_df = pd.DataFrame([['H2O', '+H', 0.2], ['C2H2', '+H', 0.8]], columns=['sf', 'adduct', 'fdr']).set_index(['sf', 'adduct']) assert_frame_equal(fdr.estimate_fdr(msm_df), exp_sf_df)
def test_estimate_fdr_digitize_works(): fdr = FDR(0, 0, 1, ['+H'], None) fdr.fdr_levels = [0.4, 0.8] fdr.td_df = pd.DataFrame([[1, '+H', '+Cu'], [2, '+H', '+Ag'], [3, '+H', '+Cl'], [4, '+H', '+Co']], columns=['sf_id', 'ta', 'da']) msm_df = pd.DataFrame( [[1, '+H', 1.0], [2, '+H', 0.75], [3, '+H', 0.5], [4, '+H', 0.25], [1, '+Cu', 0.75], [2, '+Ag', 0.3], [3, '+Cl', 0.25], [4, '+Co', 0.1]], columns=['sf_id', 'adduct', 'msm']).set_index(['sf_id', 'adduct']).sort_index() exp_sf_df = pd.DataFrame( [[1, '+H', 0.4], [2, '+H', 0.4], [3, '+H', 0.4], [4, '+H', 0.8]], columns=['sf_id', 'adduct', 'fdr']).set_index(['sf_id', 'adduct']) assert_frame_equal(fdr.estimate_fdr(msm_df), exp_sf_df)
def test_estimate_fdr_returns_correct_df(): fdr = FDR(0, 0, 2, ['+H'], None) fdr.fdr_levels = [0.2, 0.8] fdr.td_df = pd.DataFrame([[1, '+H', '+Cu'], [1, '+H', '+Co'], [2, '+H', '+Ag'], [2, '+H', '+Ar']], columns=['sf_id', 'ta', 'da']) msm_df = pd.DataFrame([[1, '+H', 0.85], [2, '+H', 0.5], [1, '+Cu', 0.5], [1, '+Co', 0.5], [2, '+Ag', 0.75], [2, '+Ar', 0.0]], columns=['sf_id', 'adduct', 'msm']).set_index(['sf_id', 'adduct']).sort_index() exp_sf_df = pd.DataFrame([[1, '+H', 0.2], [2, '+H', 0.8]], columns=['sf_id', 'adduct', 'fdr']).set_index(['sf_id', 'adduct']) assert_frame_equal(fdr.estimate_fdr(msm_df), exp_sf_df)
def test_estimate_fdr_returns_correct_df(): fdr = FDR(job_id=0, decoy_sample_size=2, target_adducts=['+H'], db=None) fdr.fdr_levels = [0.2, 0.8] fdr.td_df = pd.DataFrame([['H2O', '+H', '+Cu'], ['H2O', '+H', '+Co'], ['C2H2', '+H', '+Ag'], ['C2H2', '+H', '+Ar']], columns=['sf', 'ta', 'da']) msm_df = pd.DataFrame([['H2O', '+H', 0.85], ['C2H2', '+H', 0.5], ['H2O', '+Cu', 0.5], ['H2O', '+Co', 0.5], ['C2H2', '+Ag', 0.75], ['C2H2', '+Ar', 0.0]], columns=['sf', 'adduct', 'msm']).set_index(['sf', 'adduct']).sort_index() exp_sf_df = pd.DataFrame([['H2O', '+H', 0.2], ['C2H2', '+H', 0.8]], columns=['sf', 'adduct', 'fdr']).set_index(['sf', 'adduct']) assert_frame_equal(fdr.estimate_fdr(msm_df), exp_sf_df)