public override ChromCorrelationData CorrelateData(Run run, IqResult iqResult, int startScan, int stopScan) { var correlationData = new ChromCorrelationData(); var o16MzValue = iqResult.Target.TheorIsotopicProfile.Peaklist[0].XValue; var o18SingleLabelMzValue = iqResult.Target.TheorIsotopicProfile.Peaklist[2].XValue; var o18DoubleLabelMzValue = iqResult.Target.TheorIsotopicProfile.Peaklist[4].XValue; var o16ChromXyData = GetBaseChromXYData(run, startScan, stopScan, o16MzValue); var o18SingleLabelChromXyData = GetBaseChromXYData(run, startScan, stopScan, o18SingleLabelMzValue); var o18DoubleLabelChromXyData = GetBaseChromXYData(run, startScan, stopScan, o18DoubleLabelMzValue); double slope, intercept, rsquaredVal; GetElutionCorrelationData(o16ChromXyData, o18SingleLabelChromXyData, out slope, out intercept, out rsquaredVal); correlationData.AddCorrelationData(slope, intercept, rsquaredVal); GetElutionCorrelationData(o16ChromXyData, o18DoubleLabelChromXyData, out slope, out intercept, out rsquaredVal); correlationData.AddCorrelationData(slope, intercept, rsquaredVal); GetElutionCorrelationData(o18SingleLabelChromXyData, o18DoubleLabelChromXyData, out slope, out intercept, out rsquaredVal); correlationData.AddCorrelationData(slope, intercept, rsquaredVal); return(correlationData); }
public IqResult(IqTarget target) { _labelFreeResultExporter = new IqLabelFreeResultExporter(); _childResults = new List <IqResult>(); Target = target; IqResultDetail = new IqResultDetail(); CorrelationData = new ChromCorrelationData(); FitScore = 1; InterferenceScore = 1; IsExported = true; }
public ChromCorrelationData CorrelateO16O18Profiles(Run run, IsotopicProfile iso, int startScan, int stopScan) { var correlationData = new ChromCorrelationData(); var indexO16MonoPeak = 0; var indexO18SingleLabelPeak = 2; var indexO18DoubleLabelPeak = 4; var baseMZValue = iso.Peaklist[indexO16MonoPeak].XValue; bool baseChromDataIsOK; var basePeakChromXYData = GetBaseChromXYData(run, startScan, stopScan, baseMZValue); baseChromDataIsOK = basePeakChromXYData != null && basePeakChromXYData.Xvalues != null && basePeakChromXYData.Xvalues.Length > 3; if (!baseChromDataIsOK) { return(new ChromCorrelationData()); } ChromCorrelationDataItem o18SingleLabelChromCorrDataItem; if (indexO18SingleLabelPeak >= iso.Peaklist.Count) { o18SingleLabelChromCorrDataItem = new ChromCorrelationDataItem(); } else { var correlatedO18SingleLabelMzValue = iso.Peaklist[indexO18SingleLabelPeak].XValue; o18SingleLabelChromCorrDataItem = GetChromCorrDataItem(run, startScan, stopScan, basePeakChromXYData, correlatedO18SingleLabelMzValue); } ChromCorrelationDataItem o18DoubleLabelChromCorrDataItem; if (indexO18DoubleLabelPeak >= iso.Peaklist.Count) { o18DoubleLabelChromCorrDataItem = new ChromCorrelationDataItem(); } else { var correlatedO18DoubleLabelMzValue = iso.Peaklist[indexO18DoubleLabelPeak].XValue; o18DoubleLabelChromCorrDataItem = GetChromCorrDataItem(run, startScan, stopScan, basePeakChromXYData, correlatedO18DoubleLabelMzValue); } correlationData.AddCorrelationData(o18SingleLabelChromCorrDataItem); correlationData.AddCorrelationData(o18DoubleLabelChromCorrDataItem); return(correlationData); }
private void UpdateIsoIntensitiesUsingChromCorrData(ChromCorrelationData chromCorrelationData, IsotopicProfile iso) { var totalChromCorrDataItems = chromCorrelationData.CorrelationDataItems.Count; double heightMaxPeak = iso.getMostIntensePeak().Height; for (var i = 0; i < iso.Peaklist.Count; i++) { if (i < totalChromCorrDataItems) { var correctedRelIntensity = chromCorrelationData.CorrelationDataItems[i].CorrelationSlope; if (correctedRelIntensity.HasValue) { iso.Peaklist[i].Height = (float)(heightMaxPeak * correctedRelIntensity); } } } }
/// <summary> /// Selects a peak that correlates with the reference target and returns a bool to continue extending the charge range /// </summary> /// <param name="parentTarget"></param> /// <param name="referenceTarget"></param> /// <param name="chargeTarget"></param> /// <param name="correlationCutoff"></param> /// <param name="fitCutoff"></param> /// <returns></returns> private bool ChargeExpansionPeakSelection(TopDownIqTarget parentTarget, ChromPeakIqTarget referenceTarget, IqChargeStateTarget chargeTarget, double correlationCutoff, double fitCutoff) { var iqChargeCorrelator = ChromatogramCorrelator as IqChargeCorrelator; var peakTargets = chargeTarget.ChildTargets(); var sortedPeakTargets = peakTargets.OrderBy(x => x.GetResult().FitScore); foreach (ChromPeakIqTarget target in sortedPeakTargets) { if (referenceTarget.ChromPeak != null) { var minScan = referenceTarget.ChromPeak.XValue - (0.5 * referenceTarget.ChromPeak.Width); var maxScan = referenceTarget.ChromPeak.XValue + (0.5 * +referenceTarget.ChromPeak.Width); if ((target.ChromPeak.XValue > minScan) && (target.ChromPeak.XValue < maxScan)) { var correlation = iqChargeCorrelator.PairWiseChargeCorrelation(referenceTarget, target, Run, 3); if (correlation > correlationCutoff && target.GetResult().FitScore < fitCutoff) { UpdateSelection(target); var parentResult = parentTarget.GetResult() as TopDownIqResult; foreach (var item in parentResult.ChargeCorrelationData.CorrelationData) { if (referenceTarget == item.ReferenceTarget) { var corrItem = new ChromCorrelationDataItem(0, 0, correlation); var corr = new ChromCorrelationData(); corr.AddCorrelationData(corrItem); item.PeakCorrelationData.Add(target, corr); } } return(true); } } } } return(false); }
private IsotopicProfile GetIsoDataPassingChromCorrelation(ChromCorrelationData chromCorrelationData, IsotopicProfile iso) { var returnedIso = iso.CloneIsotopicProfile(); returnedIso.Peaklist.Clear(); for (var i = 0; i < iso.Peaklist.Count; i++) { if (i < chromCorrelationData.CorrelationDataItems.Count) { if (chromCorrelationData.CorrelationDataItems[i].CorrelationRSquaredVal > MinimumRSquaredValForQuant) { returnedIso.Peaklist.Add(iso.Peaklist[i]); } else { break; } } } return(returnedIso); }
public ChromCorrelationData CorrelatePeaksWithinIsotopicProfile(Run run, IsotopicProfile iso, int startScan, int stopScan) { var correlationData = new ChromCorrelationData(); var indexMostAbundantPeak = iso.GetIndexOfMostIntensePeak(); var baseMZValue = iso.Peaklist[indexMostAbundantPeak].XValue; bool baseChromDataIsOK; var basePeakChromXYData = GetBaseChromXYData(run, startScan, stopScan, baseMZValue); baseChromDataIsOK = basePeakChromXYData != null && basePeakChromXYData.Xvalues != null; //&&basePeakChromXYData.Xvalues.Length > 3; var minIntensity = iso.Peaklist[indexMostAbundantPeak].Height * MinimumRelativeIntensityForChromCorr; for (var i = 0; i < iso.Peaklist.Count; i++) { if (!baseChromDataIsOK) { var defaultChromCorrDataItem = new ChromCorrelationDataItem(); correlationData.AddCorrelationData(defaultChromCorrDataItem); break; } if (i == indexMostAbundantPeak) { //peak is being correlated to itself correlationData.AddCorrelationData(1.0, 0, 1); } else if (iso.Peaklist[i].Height >= minIntensity) { var correlatedMZValue = iso.Peaklist[i].XValue; bool chromDataIsOK; var chromPeakXYData = GetCorrelatedChromPeakXYData(run, startScan, stopScan, basePeakChromXYData, correlatedMZValue); chromDataIsOK = chromPeakXYData != null && chromPeakXYData.Xvalues != null; //&&chromPeakXYData.Xvalues.Length > 3; if (chromDataIsOK) { double slope; double intercept; double rsquaredVal; chromPeakXYData = FillInAnyMissingValuesInChromatogram(basePeakChromXYData, chromPeakXYData); GetElutionCorrelationData(basePeakChromXYData, chromPeakXYData, out slope, out intercept, out rsquaredVal); correlationData.AddCorrelationData(slope, intercept, rsquaredVal); } else { var defaultChromCorrDataItem = new ChromCorrelationDataItem(); correlationData.AddCorrelationData(defaultChromCorrDataItem); } } else { var defaultChromCorrDataItem = new ChromCorrelationDataItem(); correlationData.AddCorrelationData(defaultChromCorrDataItem); } } return(correlationData); }
/// <summary> /// Performs charge correlation on all peaks within a sequence level target /// </summary> /// <param name="targetList"></param> /// <param name="run"></param> /// <param name="correlationThreshold"></param> /// <param name="peaksToCorrelate"></param> /// <returns></returns> public ChargeCorrelationData CorrelateData(List <ChromPeakIqTarget> targetList, Run run, double correlationThreshold = 0.8, int peaksToCorrelate = 3) { var correlationList = new List <ChargeCorrelationItem>(); var availableTargets = new List <ChromPeakIqTarget>(targetList); //Sorts target list by fit score //Lowest to Highest var sortedTargetList = targetList.OrderBy(n => n.GetResult().FitScore); foreach (var referenceTarget in sortedTargetList) { //Checks to see if reference peak is in availableTargets list if (!availableTargets.Contains(referenceTarget)) { continue; } //New ChargeCorrelationItem for the reference peak var referenceCorrelationData = new ChargeCorrelationItem(referenceTarget); //Gets the ChromPeaks base width in scans for correlation int startScan, stopScan; GetBaseScanRange(referenceTarget.ChromPeak, out startScan, out stopScan); //Generates an array of XICs for the reference peak var referenceMZList = DeconTools.Backend.Utilities.IsotopicProfileUtilities.GetTopNMZValues(referenceTarget.TheorIsotopicProfile.Peaklist, peaksToCorrelate); var referenceXIC = GetCorrelationXICs(peaksToCorrelate, referenceMZList, run, startScan, stopScan); //Iterates through the rest of the available targets foreach (var correlatingTarget in targetList) { //Checks if target is available if (!availableTargets.Contains(correlatingTarget)) { continue; } //Checks if the peak to be correlated has an XValue that falls within the base peak range of the reference peak if (correlatingTarget.ChromPeak.XValue > startScan && correlatingTarget.ChromPeak.XValue < stopScan) { //Generates an XIC array for the peak being correlated. var correlationMZList = DeconTools.Backend.Utilities.IsotopicProfileUtilities.GetTopNMZValues( correlatingTarget.TheorIsotopicProfile.Peaklist, peaksToCorrelate); var correlationXIC = GetCorrelationXICs(peaksToCorrelate, correlationMZList, run, startScan, stopScan); //Generates new correlation data item for current correlation var correlationData = new ChromCorrelationData(); for (var i = 0; i < peaksToCorrelate; i++) { //Checks if either of the XICs are null if (referenceXIC[i] != null && correlationXIC[i] != null) { double slope, intercept, rsquaredval; GetElutionCorrelationData(referenceXIC[i], FillInAnyMissingValuesInChromatogram(referenceXIC[i].Xvalues, correlationXIC[i]), out slope, out intercept, out rsquaredval); correlationData.AddCorrelationData(slope, intercept, rsquaredval); } else { //A placeholder to show that the data was poor correlationData.AddCorrelationData(-9999, -9999, 0); } } //Checks if the overall correlation median is higher than the correlation threshold if (correlationData.RSquaredValsMedian >= correlationThreshold) { referenceCorrelationData.PeakCorrelationData.Add(correlatingTarget, correlationData); //Removes correlating target from the availableTargets list because it was successfully correlated. availableTargets.Remove(correlatingTarget); } } } //Removes reference target from availableTargets list availableTargets.Remove(referenceTarget); correlationList.Add(referenceCorrelationData); } var chargeCorrelationData = new ChargeCorrelationData(); chargeCorrelationData.CorrelationData = correlationList; return(chargeCorrelationData); }