pub struct IntensityMatrix {Show 19 fields
pub search_guidance: Option<SearchGuidance>,
pub consensus: Vec<ConsensusFeature>,
pub n_features: usize,
pub n_runs: usize,
pub run_names: Vec<String>,
pub reference_run: String,
pub feature_mz: Vec<f64>,
pub feature_mass: Vec<f64>,
pub feature_charge: Vec<u8>,
pub feature_rt: Vec<f64>,
pub feature_im: Vec<f64>,
pub feature_combined_score: Vec<f64>,
pub feature_seed_run: Vec<String>,
pub feature_n_contributing_runs: Vec<usize>,
pub hills_per_run: Vec<usize>,
pub intensities: Vec<f64>,
pub q_values: Vec<f64>,
pub decoy_intensities: Vec<f64>,
pub entries: Vec<LfqEntry>,
}Expand description
Final intensity matrix: features (rows) × runs (columns).
Fields§
§search_guidance: Option<SearchGuidance>Peptide identities and donor evidence, present only in search-guided mode.
consensus: Vec<ConsensusFeature>Original consensus membership retained for long-format evidence export.
n_features: usize§n_runs: usize§run_names: Vec<String>§reference_run: String§feature_mz: Vec<f64>§feature_mass: Vec<f64>§feature_charge: Vec<u8>§feature_rt: Vec<f64>§feature_im: Vec<f64>§feature_combined_score: Vec<f64>Seed feature’s combined_score (isotope × chromato cosine) per consensus row.
feature_seed_run: Vec<String>Name of the run that provided the seed feature for each consensus row.
feature_n_contributing_runs: Vec<usize>Number of runs that contributed at least one detection to each consensus group.
hills_per_run: Vec<usize>Hill count per run (recorded as each run’s hills were streamed in).
intensities: Vec<f64>§q_values: Vec<f64>§decoy_intensities: Vec<f64>Decoy intensities, same flat layout as intensities.
All zeros when run_tdc = false.
entries: Vec<LfqEntry>Full per-(feature, run) target + decoy entries with detail stats.
Empty when run_tdc = false and details are not requested.
Implementations§
Source§impl IntensityMatrix
impl IntensityMatrix
Sourcepub fn intensity(&self, feat: usize, run: usize) -> f64
pub fn intensity(&self, feat: usize, run: usize) -> f64
Examples found in repository?
examples/support/lfq_matrices.rs (line 52)
4pub fn matrices(m: &IntensityMatrix, folder: &Path) -> anyhow::Result<()> {
5 let meta = [
6 "massCalib",
7 "mz",
8 "charge",
9 "rtApex",
10 "im",
11 "combined_score",
12 "seed_run",
13 "n_contributing_runs",
14 ];
15 for (kind, name) in [
16 "consensus_features.tsv",
17 "intensity_matrix.tsv",
18 "qvalue_matrix.tsv",
19 "decoy_intensity_matrix.tsv",
20 ]
21 .iter()
22 .enumerate()
23 {
24 let mut out = csv::WriterBuilder::new()
25 .delimiter(b'\t')
26 .from_path(folder.join(name))?;
27 let mut header: Vec<String> = meta.iter().map(|s| s.to_string()).collect();
28 if kind == 0 {
29 header.extend(["n_runs_detected", "group_score", "group_qvalue"].map(String::from));
30 } else {
31 header.extend(m.run_names.clone());
32 }
33 out.write_record(header)?;
34 for (i, g) in m.consensus.iter().enumerate() {
35 let mut row = vec![
36 format!("{:.6}", g.neutral_mass),
37 format!("{:.6}", g.ref_mz),
38 g.charge.to_string(),
39 format!("{:.6}", g.ref_rt),
40 if g.ref_im == 0.0 {
41 String::new()
42 } else {
43 format!("{:.6}", g.ref_im)
44 },
45 format!("{:.6}", g.seed_combined_score),
46 m.run_names[g.seed_run_idx].clone(),
47 g.n_contributing_runs.to_string(),
48 ];
49 if kind == 0 {
50 row.extend([
51 (0..m.n_runs)
52 .filter(|&r| m.intensity(i, r) > 0.0)
53 .count()
54 .to_string(),
55 format!("{:.6}", g.group_score),
56 format!("{:.6}", g.group_qvalue),
57 ]);
58 } else {
59 for r in 0..m.n_runs {
60 let v = match kind {
61 1 => m.intensity(i, r),
62 2 => m.q_value(i, r),
63 _ => m.decoy_intensity(i, r),
64 };
65 row.push(if kind == 2 {
66 format!("{v:.4}")
67 } else if v > 0.0 {
68 format!("{v:.5e}")
69 } else {
70 "0".into()
71 });
72 }
73 }
74 out.write_record(row)?;
75 }
76 out.flush()?;
77 }
78 let mut audit = csv::WriterBuilder::new()
79 .delimiter(b'\t')
80 .from_path(folder.join("ownership.tsv"))?;
81 audit.write_record([
82 "feature_idx",
83 "run_idx",
84 "is_decoy",
85 "intensity",
86 "ownership_status",
87 "owned_samples",
88 "excluded_samples",
89 "competing_feature",
90 "apex_rt",
91 "bhattacharyya",
92 "coelution",
93 "preceding_signal_fraction",
94 ])?;
95 for e in &m.entries {
96 audit.write_record([
97 e.feature_idx.to_string(),
98 e.run_idx.to_string(),
99 e.is_decoy.to_string(),
100 e.intensity.to_string(),
101 e.ownership_status.to_string(),
102 e.owned_samples.to_string(),
103 e.excluded_samples.to_string(),
104 e.competing_feature
105 .map(|i| i.to_string())
106 .unwrap_or_default(),
107 e.apex_rt.to_string(),
108 e.spectral_bhattacharyya.to_string(),
109 e.coelution.to_string(),
110 e.preceding_signal_fraction.to_string(),
111 ])?;
112 }
113 audit.flush()?;
114 Ok(())
115}Sourcepub fn q_value(&self, feat: usize, run: usize) -> f64
pub fn q_value(&self, feat: usize, run: usize) -> f64
Examples found in repository?
examples/support/lfq_matrices.rs (line 62)
4pub fn matrices(m: &IntensityMatrix, folder: &Path) -> anyhow::Result<()> {
5 let meta = [
6 "massCalib",
7 "mz",
8 "charge",
9 "rtApex",
10 "im",
11 "combined_score",
12 "seed_run",
13 "n_contributing_runs",
14 ];
15 for (kind, name) in [
16 "consensus_features.tsv",
17 "intensity_matrix.tsv",
18 "qvalue_matrix.tsv",
19 "decoy_intensity_matrix.tsv",
20 ]
21 .iter()
22 .enumerate()
23 {
24 let mut out = csv::WriterBuilder::new()
25 .delimiter(b'\t')
26 .from_path(folder.join(name))?;
27 let mut header: Vec<String> = meta.iter().map(|s| s.to_string()).collect();
28 if kind == 0 {
29 header.extend(["n_runs_detected", "group_score", "group_qvalue"].map(String::from));
30 } else {
31 header.extend(m.run_names.clone());
32 }
33 out.write_record(header)?;
34 for (i, g) in m.consensus.iter().enumerate() {
35 let mut row = vec![
36 format!("{:.6}", g.neutral_mass),
37 format!("{:.6}", g.ref_mz),
38 g.charge.to_string(),
39 format!("{:.6}", g.ref_rt),
40 if g.ref_im == 0.0 {
41 String::new()
42 } else {
43 format!("{:.6}", g.ref_im)
44 },
45 format!("{:.6}", g.seed_combined_score),
46 m.run_names[g.seed_run_idx].clone(),
47 g.n_contributing_runs.to_string(),
48 ];
49 if kind == 0 {
50 row.extend([
51 (0..m.n_runs)
52 .filter(|&r| m.intensity(i, r) > 0.0)
53 .count()
54 .to_string(),
55 format!("{:.6}", g.group_score),
56 format!("{:.6}", g.group_qvalue),
57 ]);
58 } else {
59 for r in 0..m.n_runs {
60 let v = match kind {
61 1 => m.intensity(i, r),
62 2 => m.q_value(i, r),
63 _ => m.decoy_intensity(i, r),
64 };
65 row.push(if kind == 2 {
66 format!("{v:.4}")
67 } else if v > 0.0 {
68 format!("{v:.5e}")
69 } else {
70 "0".into()
71 });
72 }
73 }
74 out.write_record(row)?;
75 }
76 out.flush()?;
77 }
78 let mut audit = csv::WriterBuilder::new()
79 .delimiter(b'\t')
80 .from_path(folder.join("ownership.tsv"))?;
81 audit.write_record([
82 "feature_idx",
83 "run_idx",
84 "is_decoy",
85 "intensity",
86 "ownership_status",
87 "owned_samples",
88 "excluded_samples",
89 "competing_feature",
90 "apex_rt",
91 "bhattacharyya",
92 "coelution",
93 "preceding_signal_fraction",
94 ])?;
95 for e in &m.entries {
96 audit.write_record([
97 e.feature_idx.to_string(),
98 e.run_idx.to_string(),
99 e.is_decoy.to_string(),
100 e.intensity.to_string(),
101 e.ownership_status.to_string(),
102 e.owned_samples.to_string(),
103 e.excluded_samples.to_string(),
104 e.competing_feature
105 .map(|i| i.to_string())
106 .unwrap_or_default(),
107 e.apex_rt.to_string(),
108 e.spectral_bhattacharyya.to_string(),
109 e.coelution.to_string(),
110 e.preceding_signal_fraction.to_string(),
111 ])?;
112 }
113 audit.flush()?;
114 Ok(())
115}Sourcepub fn decoy_intensity(&self, feat: usize, run: usize) -> f64
pub fn decoy_intensity(&self, feat: usize, run: usize) -> f64
Examples found in repository?
examples/support/lfq_matrices.rs (line 63)
4pub fn matrices(m: &IntensityMatrix, folder: &Path) -> anyhow::Result<()> {
5 let meta = [
6 "massCalib",
7 "mz",
8 "charge",
9 "rtApex",
10 "im",
11 "combined_score",
12 "seed_run",
13 "n_contributing_runs",
14 ];
15 for (kind, name) in [
16 "consensus_features.tsv",
17 "intensity_matrix.tsv",
18 "qvalue_matrix.tsv",
19 "decoy_intensity_matrix.tsv",
20 ]
21 .iter()
22 .enumerate()
23 {
24 let mut out = csv::WriterBuilder::new()
25 .delimiter(b'\t')
26 .from_path(folder.join(name))?;
27 let mut header: Vec<String> = meta.iter().map(|s| s.to_string()).collect();
28 if kind == 0 {
29 header.extend(["n_runs_detected", "group_score", "group_qvalue"].map(String::from));
30 } else {
31 header.extend(m.run_names.clone());
32 }
33 out.write_record(header)?;
34 for (i, g) in m.consensus.iter().enumerate() {
35 let mut row = vec![
36 format!("{:.6}", g.neutral_mass),
37 format!("{:.6}", g.ref_mz),
38 g.charge.to_string(),
39 format!("{:.6}", g.ref_rt),
40 if g.ref_im == 0.0 {
41 String::new()
42 } else {
43 format!("{:.6}", g.ref_im)
44 },
45 format!("{:.6}", g.seed_combined_score),
46 m.run_names[g.seed_run_idx].clone(),
47 g.n_contributing_runs.to_string(),
48 ];
49 if kind == 0 {
50 row.extend([
51 (0..m.n_runs)
52 .filter(|&r| m.intensity(i, r) > 0.0)
53 .count()
54 .to_string(),
55 format!("{:.6}", g.group_score),
56 format!("{:.6}", g.group_qvalue),
57 ]);
58 } else {
59 for r in 0..m.n_runs {
60 let v = match kind {
61 1 => m.intensity(i, r),
62 2 => m.q_value(i, r),
63 _ => m.decoy_intensity(i, r),
64 };
65 row.push(if kind == 2 {
66 format!("{v:.4}")
67 } else if v > 0.0 {
68 format!("{v:.5e}")
69 } else {
70 "0".into()
71 });
72 }
73 }
74 out.write_record(row)?;
75 }
76 out.flush()?;
77 }
78 let mut audit = csv::WriterBuilder::new()
79 .delimiter(b'\t')
80 .from_path(folder.join("ownership.tsv"))?;
81 audit.write_record([
82 "feature_idx",
83 "run_idx",
84 "is_decoy",
85 "intensity",
86 "ownership_status",
87 "owned_samples",
88 "excluded_samples",
89 "competing_feature",
90 "apex_rt",
91 "bhattacharyya",
92 "coelution",
93 "preceding_signal_fraction",
94 ])?;
95 for e in &m.entries {
96 audit.write_record([
97 e.feature_idx.to_string(),
98 e.run_idx.to_string(),
99 e.is_decoy.to_string(),
100 e.intensity.to_string(),
101 e.ownership_status.to_string(),
102 e.owned_samples.to_string(),
103 e.excluded_samples.to_string(),
104 e.competing_feature
105 .map(|i| i.to_string())
106 .unwrap_or_default(),
107 e.apex_rt.to_string(),
108 e.spectral_bhattacharyya.to_string(),
109 e.coelution.to_string(),
110 e.preceding_signal_fraction.to_string(),
111 ])?;
112 }
113 audit.flush()?;
114 Ok(())
115}Auto Trait Implementations§
impl Freeze for IntensityMatrix
impl RefUnwindSafe for IntensityMatrix
impl Send for IntensityMatrix
impl Sync for IntensityMatrix
impl Unpin for IntensityMatrix
impl UnsafeUnpin for IntensityMatrix
impl UnwindSafe for IntensityMatrix
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.