Skip to content

algorithm changes - #10

Merged
robertsamples merged 3 commits into
robertsamples:mainfrom
yiluchen-fs:main
Nov 16, 2026
Merged

robertsamples merged 3 commits into
robertsamples:mainfrom
yiluchen-fs:main

Conversation

@yiluchen-fs

Copy link
Copy Markdown
Contributor

No description provided.

old ubuntu package version dropped in october- fixed
@robertsamples

Copy link
Copy Markdown
Owner

Thanks for this! Merged (squashed) with some changes. Here's what I found benchmarking it:

Mass defect filter is a clear win:
I ran all 36k NPAtlas compounds through it as [M+H]+. It rejects only 0.1% of real natural products: about 0.01% of CHNOPS-only compounds and 1.4% of halogenated ones, and none at all with md_halogen on.
On the PTY087I2 example it removes 833 of 4,956 features. Their fractional m/z clusters around 0.5–0.8, so they're mostly multiply charged or junk ions.
As you noted in the docstring, it can't reject anything above about m/z 690.
Adduct grouping: this works very well. I tested it on one of our CHM350 course dataset MS-DIAL alignments (31,652 features) using a target/decoy check: the real adduct mass differences versus randomly shifted fake ones.

The real list made 1,235 adduct calls; the decoys made about 6. That's an estimated false-call rate around 0.5%.
One caveat: 152 of the calls landed on features MS-DIAL marks as isotopes, so the isotope and adduct steps still overlap a bit.

Peak correction rewrite: I merged this as an opt-in beta (peak_correction = beta), and the published filter stays the default.
It's much more conservative. On PTY087I2 it removes 23 features, versus 270 for the old filter.
It never removes a feature that's stronger than its "parent". The old filter did does 139 times, so the intensity check is a real improvement.
But it catches only about 4.5% of the isotopes MS-DIAL flags, versus about 44% for the legacy filter. Its precision is better (about 50% vs 25%), but recall is very low. Loosening iso_ppm from 3 to 20 only gets recall to 9%, so something else in the rules is blocking most matches. This would be worth digging into, I think long term this will be prudent to upgrade this the default and we would keep the what is currently used as a "legacy" option but it will need more testing to see what catches what.

Changes I made:
All three features are off by default, and with them off the output is byte-identical to before.
Fixed a crash when feature IDs aren't integers (e.g. Progenesis-style 0.80_418.1451n).
Fixed the beta filter's intensity matrix, which was including the m/z and RT columns as if they were samples (I think you were getting higher numbers on the peak correction rewrite before because of htis issue)
Kept your comments and added short English summaries.
Added tests in code/tests/test_beta_filters.py.

These will also go into the web version (MPACT Web) as beta options pending some UX changes on the website

@robertsamples
robertsamples merged commit 0319c1a into robertsamples:main Nov 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants