Skip to content

_blood_correct_test_() ignores commu_score_col and always corrects Commu_Score #31

Description

@LeonYiFan

Hi MEBOCOST developers,

I noticed that _blood_correct_test_() exposes a commu_score_col argument, and the official multisample demo calls it with commu_score_col='Norm_Commu_Score', but the current implementation appears to ignore this argument and always uses Commu_Score for the regression and correction.

Where

In src/mebocost/mebocost.py:

https://github.com/kaifuchenlab/MEBOCOST/blob/main/src/mebocost/mebocost.py#L1149-L1172

The argument is defined here:

commu_score_col = 'Commu_Score'

but the function body later hard-codes Commu_Score here:

r1, p1 = pearsonr(commu_res['blood_level'], commu_res['Commu_Score'])
sr1, sp1 = spearmanr(commu_res['blood_level'], commu_res['Commu_Score'])
model.fit(commu_res[['blood_level']], commu_res['Commu_Score'])
commu_res['Corrected_Commu_Score'] = commu_res['Commu_Score'] - commu_res['pred']

The plotting code also hard-codes Commu_Score:

sns.regplot(data=commu_res, x='blood_level', y='Commu_Score', ...)

Why this is confusing

The official multisample demo calls:

https://github.com/kaifuchenlab/MEBOCOST/blob/main/Demo_Multisample_mCCC_analysis.ipynb#L995-L999

corrected_commu_res = mebo_obj._blood_correct_test_(
    met_cont_file='data/mebocost_db/common/hmdb_blood_metabolite_concentration.tsv',
    commu_score_col='Norm_Commu_Score',
    ...
)

Based on this call, users would expect:

Corrected_Commu_Score = Norm_Commu_Score - predicted_blood_component

But the current function actually computes:

Corrected_Commu_Score = Commu_Score - predicted_blood_component

even when commu_score_col='Norm_Commu_Score' is passed.

Suggested fix

Use commu_score_col consistently inside _blood_correct_test_().

For example:

if commu_score_col not in commu_res.columns:
    raise KeyError(f"{commu_score_col} is not found in commu_res columns")

r1, p1 = pearsonr(commu_res['blood_level'], commu_res[commu_score_col])
sr1, sp1 = spearmanr(commu_res['blood_level'], commu_res[commu_score_col])

model = LinearRegression(fit_intercept=True)
model.fit(commu_res[['blood_level']], commu_res[commu_score_col])

commu_res['pred'] = model.predict(commu_res[['blood_level']])
commu_res['Corrected_Commu_Score'] = commu_res[commu_score_col] - commu_res['pred']

And for the first regression plot:

sns.regplot(
    data=commu_res,
    x='blood_level',
    y=commu_score_col,
    ci=False,
    ax=ax[0],
    scatter_kws={'alpha': .5}
)

Optionally, the y-axis label could also reflect the score column being corrected.

Expected behavior

When users pass:

commu_score_col='Norm_Commu_Score'

the returned Corrected_Commu_Score should be based on Norm_Commu_Score, not Commu_Score.

This would make the implementation consistent with the official demo and with the function argument.


Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions