Skip to content

Commit

Permalink
Soften calibration tolerance (#2423)
Browse files Browse the repository at this point in the history
* update mzlib nuget package to 551

* revise path to selection of calibration tolerances

* fasd

* works

* u

* zCX

* revert most changes run on dataAcquisition and one calibration

* fas

* delete unused code in DataPointAcquisitionResults

* calibration task unit test coverage existing toml

* no calibration psms unit test

* correctly update experimental design file after failed calibration
  • Loading branch information
trishorts authored Oct 18, 2024
1 parent b753e3c commit c2d5a41
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 173 deletions.
6 changes: 0 additions & 6 deletions MetaMorpheus/EngineLayer/Calibration/CalibrationEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ protected override MetaMorpheusEngineResults RunSpecific()
//generate new scans
MsDataScan[] calibratedScans = new MsDataScan[originalScans.Count];

//hard copy original scans
for (int i = 0; i < originalScans.Count; i++)
{
calibratedScans[i] = originalScans[i];
}

//apply a smoothing function, so that outlier scans aren't wildly shifted
double[] ms1SmoothedErrors = SmoothErrors(ms1RelativeErrors);
double[] ms2SmoothedErrors = new double[ms2RelativeErrors.Length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ private static List<LabeledDataPoint> SearchMS2Spectrum(Ms2ScanWithSpecificMass
double theoreticalMass = matchedIon.NeutralTheoreticalProduct.NeutralMass;
//get envelopes that match
var envelopesThatMatch = isotopicEnvelopes.Where(x => ms2Tolerance.Within(x.MonoisotopicMass, theoreticalMass)).OrderBy(x => Math.Abs(x.MonoisotopicMass - theoreticalMass)).ToList();

if(envelopesThatMatch.Count == 0)
continue;
//only allow one envelope per charge state
bool[] chargeStateFound = new bool[envelopesThatMatch.Max(x => x.Charge) + 1];

Expand Down
25 changes: 3 additions & 22 deletions MetaMorpheus/EngineLayer/Calibration/DataPointAquisitionResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace EngineLayer.Calibration
{
/// <summary>
/// Returns PSMs that can be used for calibration based on tolerance limits passed from the calibration task
/// </summary>
public class DataPointAquisitionResults : MetaMorpheusEngineResults
{
public DataPointAquisitionResults(
Expand All @@ -27,19 +30,9 @@ public DataPointAquisitionResults(

var ms1Range = Ms1List.Select(b => b.ExperimentalMz - b.TheoreticalMz).ToArray();
var ms2Range = Ms2List.Select(b => b.ExperimentalMz - b.TheoreticalMz).ToArray();
Ms1InfoTh = new Tuple<double, double>(ArrayStatistics.Mean(ms1Range), ArrayStatistics.StandardDeviation(ms1Range));
Ms2InfoTh = new Tuple<double, double>(ArrayStatistics.Mean(ms2Range), ArrayStatistics.StandardDeviation(ms2Range));


var ms1PpmRange = Ms1List.Select(b => (b.ExperimentalMz - b.TheoreticalMz) / b.TheoreticalMz).ToArray();
var ms2PpmRange = Ms2List.Select(b => (b.ExperimentalMz - b.TheoreticalMz) / b.TheoreticalMz).ToArray();
Ms1InfoPpm = new Tuple<double, double>(ArrayStatistics.Mean(ms1PpmRange), ArrayStatistics.StandardDeviation(ms1PpmRange));
Ms2InfoPpm = new Tuple<double, double>(ArrayStatistics.Mean(ms2PpmRange), ArrayStatistics.StandardDeviation(ms2PpmRange));

NumMs1MassChargeCombinationsConsidered = numMs1MassChargeCombinationsConsidered;
NumMs1MassChargeCombinationsThatAreIgnoredBecauseOfTooManyPeaks = numMs1MassChargeCombinationsThatAreIgnoredBecauseOfTooManyPeaks;
NumMs2MassChargeCombinationsConsidered = numMs2MassChargeCombinationsConsidered;
NumMs2MassChargeCombinationsThatAreIgnoredBecauseOfTooManyPeaks = numMs2MassChargeCombinationsThatAreIgnoredBecauseOfTooManyPeaks;

var precursorErrors = psms.Select(p => (p.ScanPrecursorMass - p.BioPolymerWithSetModsMonoisotopicMass.Value) / p.BioPolymerWithSetModsMonoisotopicMass.Value * 1e6).ToList();
PsmPrecursorIqrPpmError = precursorErrors.InterquartileRange();
Expand All @@ -50,16 +43,6 @@ public DataPointAquisitionResults(
PsmProductMedianPpmError = productErrors.Median();
}

public Tuple<double, double> Ms1InfoTh { get; }
public Tuple<double, double> Ms2InfoTh { get; }
public Tuple<double, double> Ms1InfoPpm { get; }
public Tuple<double, double> Ms2InfoPpm { get; }

public int NumMs1MassChargeCombinationsConsidered { get; }
public int NumMs1MassChargeCombinationsThatAreIgnoredBecauseOfTooManyPeaks { get; }
public int NumMs2MassChargeCombinationsConsidered { get; }
public int NumMs2MassChargeCombinationsThatAreIgnoredBecauseOfTooManyPeaks { get; }

public List<LabeledDataPoint> Ms1List { get; }
public List<LabeledDataPoint> Ms2List { get; }

Expand All @@ -69,8 +52,6 @@ public DataPointAquisitionResults(
public readonly double PsmProductIqrPpmError;
public readonly List<SpectralMatch> Psms;

public int Count { get { return Ms1List.Count + Ms2List.Count; } }

public override string ToString()
{
var sb = new StringBuilder();
Expand Down
2 changes: 1 addition & 1 deletion MetaMorpheus/GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace MetaMorpheusGUI
/// </summary>
public partial class MainWindow : Window
{
private readonly ObservableCollection<RawDataForDataGrid> SpectraFiles = new ObservableCollection<RawDataForDataGrid>();
private readonly ObservableCollection<RawDataForDataGrid> SpectraFiles = new ObservableCollection<RawDataForDataGrid>();
private ObservableCollection<ProteinDbForDataGrid> ProteinDatabases = new ObservableCollection<ProteinDbForDataGrid>();
private readonly ObservableCollection<PreRunTask> PreRunTasks = new ObservableCollection<PreRunTask>();
private readonly ObservableCollection<RawDataForDataGrid> SelectedSpectraFiles = new ObservableCollection<RawDataForDataGrid>();
Expand Down
Loading

0 comments on commit c2d5a41

Please sign in to comment.