Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched to Geometric Mean for Peptide Level Scores #392

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion casanovo/denovo/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ def _aa_pep_score(
peptide_score : float
The peptide score.
"""
peptide_score = np.mean(aa_scores)
peptide_score = np.exp(np.mean(np.log(aa_scores)))
bittremieux marked this conversation as resolved.
Show resolved Hide resolved
aa_scores = (aa_scores + peptide_score) / 2
if not fits_precursor_mz:
peptide_score -= 1
Expand Down
8 changes: 4 additions & 4 deletions tests/unit_tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,12 +439,12 @@ def test_aa_pep_score():
aa_scores_raw = np.asarray([0.0, 0.5, 1.0])

aa_scores, peptide_score = _aa_pep_score(aa_scores_raw, True)
np.testing.assert_array_equal(aa_scores, np.asarray([0.25, 0.5, 0.75]))
assert peptide_score == pytest.approx(0.5)
np.testing.assert_array_equal(aa_scores, np.asarray([0.0, 0.25, 0.5]))
assert peptide_score == pytest.approx(0.0)

aa_scores, peptide_score = _aa_pep_score(aa_scores_raw, False)
np.testing.assert_array_equal(aa_scores, np.asarray([0.25, 0.5, 0.75]))
assert peptide_score == pytest.approx(-0.5)
np.testing.assert_array_equal(aa_scores, np.asarray([0.0, 0.25, 0.5]))
assert peptide_score == pytest.approx(-1.0)


def test_beam_search_decode():
Expand Down
Loading