Skip to content

Commit 0a458a2

Browse files
committed
quant: use each MS2's acquisition context (survey scan, scan window, FAIMS voltage)
The readers now record, for every searched MS2, the scan its precursor references (mzML <precursor spectrumRef>, .raw Master Scan Number), its acquired m/z range and its FAIMS compensation voltage; MS1 scans keep their native id and voltage, and MS3 reporter scans their m/z range. - Precursor purity is computed on the MS2's own survey scan (else the last MS1 at the same FAIMS voltage, else the last MS1 in time). On a three- voltage FAIMS SPS-MS3 TKO run (PXD017803) the last MS1 in time is usually another voltage's survey scan: purity was missing for 2,308 of 4,570 PSMs and 0 for most others (median 0); it is now present for all, median 0.98. Filtering at purity >= 0.9 keeps 3,487 PSMs and lowers the knockout-channel interference (KO/non-KO median) from 0.128 to 0.040. - A reporter scan whose scan window does not cover every reporter m/z is not quantified. On the same study's FAIMS hrMS2 run the automatic first mass was above 126 Th for 4,345 of 6,361 quantified PSMs: their low channels were never measured and were written as zero intensities. - Label-free extraction keeps one chromatographic series per FAIMS voltage and extracts each precursor at its PSM's voltage. Interleaved voltages put zeros between the measured scans: on the FAIMS hrMS2 run the mixed series gave a median integration window of 3.9 s instead of 22 s and areas 10.7x too small. Runs without FAIMS and without recorded survey references behave as before.
1 parent 1b50c9b commit 0a458a2

9 files changed

Lines changed: 574 additions & 74 deletions

File tree

‎DOCS.md‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,10 @@ single input run's MS1 scans still need to fit in memory while it is processed.
679679
`<precursor spectrumRef>` (mzML) or `Master Scan Number` trailer (`.raw`) is that MS2 — the MS3
680680
scans are kept by the reader for this and are never searched. The default `--tmt-tol` follows
681681
the reporter scan: SPS-MS3 reporters are read in the Orbitrap even when the MS2 is an ion-trap
682-
scan, so `--tmt-level 3` defaults to 20 ppm.
682+
scan, so `--tmt-level 3` defaults to 20 ppm. A reporter scan whose recorded scan window
683+
(`scan window lower/upper limit`, the `.raw` acquisition range) does not reach every reporter
684+
m/z is not quantified — an automatic first mass above 126 Th never measured the low channels,
685+
and their zeros are not ratios — and is counted in the log.
683686
* **Impurity correction** (`--tmt-correction <file>`). The kit lot sheet in the OpenMS text form,
684687
one line per channel in kit order, `-2/-1/+1/+2` percentages separated by `/` (eight columns
685688
`-2C13/-N15-C13/-C13/-N15/+N15/+C13/+N15+C13/+2C13` for TMTpro), optional `<channel>:` prefix,
@@ -690,7 +693,10 @@ single input run's MS1 scans still need to fit in memory while it is processed.
690693
correction (Sage's behavior). The raw values are always kept (`raw_` columns, parquet
691694
`additional_intensities`).
692695
* **Precursor purity.** The share of the MS1 isolation window's ion current that belongs to the
693-
precursor's isotope envelope, from the survey scan preceding the MS2: the most intense peak
696+
precursor's isotope envelope, from the MS2's survey scan — the scan its precursor references
697+
(mzML `<precursor spectrumRef>`, `.raw` `Master Scan Number`), else the last MS1 before it at
698+
the same FAIMS compensation voltage, else the last MS1 before it. (On FAIMS runs the last MS1 in
699+
time is usually a survey scan at another voltage, which does not contain the precursor.) The most intense peak
694700
within 10 ppm of the precursor m/z anchors a ¹³C isotope ladder (10 ppm per step, both
695701
directions) inside the strict isolation window. This is the ladder of OpenMS's
696702
`IsobaricChannelExtractor` without its fuzzy window border and next-scan interpolation, and
@@ -748,6 +754,11 @@ andes --spectrum tmt_run.mzML --database human.fasta --mods tmt10_mods.txt \
748754
PSM identification FDR and quantitative accuracy are separate from this estimate.
749755
Feature competition does not replace PSM confidence: an incorrect peptide assignment
750756
can still anchor a convincing MS1 trace and survive the feature filter.
757+
* **FAIMS.** On runs with several FAIMS compensation voltages the survey scans of each voltage
758+
form their own chromatographic series, and each precursor is extracted from the series of the
759+
voltage its PSM was acquired at. (Interleaved voltages otherwise put zeros between every
760+
measured scan, which truncates the peak boundaries: on a three-voltage Lumos run the mixed
761+
series gave a median integration window of 4 s instead of 22 s and areas ~10x too small.)
751762
* **Runs.** Each `--spectrum` file is quantified on its own identifications (no transfer of
752763
identifications between runs yet); `lfq.tsv` is wide over the files.
753764
* **Not done here:** normalization, MaxLFQ / top-N protein intensities, match between runs.

‎crates/andes/src/bin/andes/ms1_cache.rs‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ impl Ms1Cache {
1616
let mut out = BufWriter::with_capacity(1024 * 1024, file.as_file());
1717
out.write_all(&(index.len() as u64).to_le_bytes())?;
1818
for i in 0..index.len() {
19+
let scan = index.scan(i);
1920
out.write_all(&index.rt(i).to_le_bytes())?;
21+
out.write_all(&(scan.id.len() as u64).to_le_bytes())?;
22+
out.write_all(scan.id.as_bytes())?;
23+
out.write_all(&scan.faims_cv.map_or(f32::NAN, |v| v).to_le_bytes())?;
2024
out.write_all(&(index.peaks(i).len() as u64).to_le_bytes())?;
2125
for &(mz, intensity) in index.peaks(i) {
2226
out.write_all(&mz.to_le_bytes())?;
@@ -37,6 +41,15 @@ impl Ms1Cache {
3741
let mut scans = Vec::with_capacity(count);
3842
for _ in 0..count {
3943
let rt = f64::from_le_bytes(read::<8>(&mut input, &mut remaining)?);
44+
let id_len = u64::from_le_bytes(read::<8>(&mut input, &mut remaining)?);
45+
let id_len = bounded_count(id_len, remaining)?;
46+
let mut id = vec![0u8; id_len];
47+
input.read_exact(&mut id)?;
48+
remaining -= id_len as u64;
49+
let id = String::from_utf8(id)
50+
.map_err(|_| io::Error::new(io::ErrorKind::InvalidData, "MS1 cache scan id"))?;
51+
let faims_cv = f32::from_le_bytes(read::<4>(&mut input, &mut remaining)?);
52+
let faims_cv = (!faims_cv.is_nan()).then_some(faims_cv);
4053
let n = u64::from_le_bytes(read::<8>(&mut input, &mut remaining)?);
4154
let n = bounded_count(n, remaining / 12)?;
4255
let mut peaks = Vec::with_capacity(n);
@@ -45,7 +58,12 @@ impl Ms1Cache {
4558
let intensity = f32::from_le_bytes(read::<4>(&mut input, &mut remaining)?);
4659
peaks.push((mz, intensity));
4760
}
48-
scans.push(Ms1Scan { rt, peaks });
61+
scans.push(Ms1Scan {
62+
rt,
63+
peaks,
64+
id,
65+
faims_cv,
66+
});
4967
}
5068
if remaining != 0 {
5169
return Err(io::Error::new(
@@ -83,10 +101,13 @@ mod tests {
83101
Ms1Scan {
84102
rt: 3.123456789,
85103
peaks: vec![(600.123456789, 1234.5678), (700.0, -0.0)],
104+
id: "scan=2".into(),
105+
faims_cv: Some(-45.0),
86106
},
87107
Ms1Scan {
88108
rt: 1.0,
89109
peaks: vec![],
110+
..Ms1Scan::default()
90111
},
91112
]);
92113
let cache = Ms1Cache::store(&index).unwrap();
@@ -101,6 +122,8 @@ mod tests {
101122
assert_eq!(a.1.to_bits(), b.1.to_bits());
102123
}
103124
assert_eq!(loaded.peaks(i).len(), index.peaks(i).len());
125+
assert_eq!(loaded.scan(i).id, index.scan(i).id);
126+
assert_eq!(loaded.scan(i).faims_cv, index.scan(i).faims_cv);
104127
}
105128
}
106129
drop(cache);
@@ -114,6 +137,7 @@ mod tests {
114137
let index = Ms1RunIndex::new(vec![Ms1Scan {
115138
rt: 1.0,
116139
peaks: vec![(500.0, 1.0)],
140+
..Ms1Scan::default()
117141
}]);
118142
let cache = Ms1Cache::store(&index).unwrap();
119143
cache.file.as_file().set_len(25).unwrap();

0 commit comments

Comments
 (0)