public ObservedIsotopeEnvelope(double monoMass, int charge, int scanNum, Ms1Peak[] peaks, TheoreticalIsotopeEnvelope theoreticalEnvelope)
 {
     MonoMass = monoMass;
     Charge = charge;
     ScanNum = scanNum;
     TheoreticalEnvelope = theoreticalEnvelope;
     Peaks = new Ms1Peak[theoreticalEnvelope.Size];
     
     Array.Copy(peaks, Peaks, theoreticalEnvelope.Size);
     GoodEnough = false;
 }
Beispiel #2
0
        public ObservedIsotopeEnvelope(double monoMass, int charge, int scanNum, Ms1Peak[] peaks, TheoreticalIsotopeEnvelope theoreticalEnvelope)
        {
            MonoMass            = monoMass;
            Charge              = charge;
            ScanNum             = scanNum;
            TheoreticalEnvelope = theoreticalEnvelope;
            Peaks = new Ms1Peak[theoreticalEnvelope.Size];

            Array.Copy(peaks, Peaks, theoreticalEnvelope.Size);
            GoodEnough = false;
        }
Beispiel #3
0
        public LcMsPeakCluster(LcMsRun run, TheoreticalIsotopeEnvelope theoreticalIsotopeEnvelope, double mass, int charge, double repMz, int repScanNum, double abundance)
            : base(mass, charge, repMz, repScanNum, abundance)
        {
            _run = run;
            TheoreticalEnvelope = theoreticalIsotopeEnvelope;
            Flag = 0;
            RepresentativeSummedEnvelop = new double[TheoreticalEnvelope.Size];

            AbundanceDistributionAcrossCharge = new double[2];
            BestCorrelationScoreAcrossCharge = new double[2];
            BestDistanceScoreAcrossCharge = new double[2];
            BestIntensityScoreAcrossCharge = new double[2];

            EnvelopeDistanceScoreAcrossCharge = new double[2];
            EnvelopeCorrelationScoreAcrossCharge = new double[2];
            EnvelopeIntensityScoreAcrossCharge = new double[2];
            BestCharge = new int[2];

            XicCorrelationBetweenBestCharges = new double[2];
            _initScore = false;
        }
Beispiel #4
0
        public LcMsPeakCluster(LcMsRun run, TheoreticalIsotopeEnvelope theoreticalIsotopeEnvelope, double mass, int charge, double repMz, int repScanNum, double abundance)
            : base(mass, charge, repMz, repScanNum, abundance)
        {
            _run = run;
            TheoreticalEnvelope = theoreticalIsotopeEnvelope;
            Flag = 0;
            RepresentativeSummedEnvelop = new double[TheoreticalEnvelope.Size];

            AbundanceDistributionAcrossCharge = new double[2];
            BestCorrelationScoreAcrossCharge  = new double[2];
            BestDistanceScoreAcrossCharge     = new double[2];
            BestIntensityScoreAcrossCharge    = new double[2];

            EnvelopeDistanceScoreAcrossCharge    = new double[2];
            EnvelopeCorrelationScoreAcrossCharge = new double[2];
            EnvelopeIntensityScoreAcrossCharge   = new double[2];
            BestCharge = new int[2];

            XicCorrelationBetweenBestCharges = new double[2];
            _initScore = false;
        }
Beispiel #5
0
 private void SetTargetMass(double targetMass)
 {
     /*var chargeLowerBound = Math.Ceiling(targetMass / Run.MaxMs1Mz);
     var chargeUpperBound = Math.Floor(targetMass / Run.MinMs1Mz);
     if (targetMass > 2000) chargeLowerBound = Math.Max(chargeLowerBound, 2);
     var rowLb = Math.Max(0, chargeLowerBound - MinScanCharge);
     var rowUb = Math.Min(NRows - 1, chargeUpperBound - MinScanCharge);
     */
     _targetMass = targetMass;
     var chargeRange = GetDetectableMinMaxCharge(targetMass, Run.MinMs1Mz, Run.MaxMs1Mz);
     _targetMinCharge = chargeRange.Item1;
     _targetMaxCharge = chargeRange.Item2;
     _rows = Enumerable.Range(0, _targetMaxCharge - _targetMinCharge + 1).ToArray();
     _theoreticalEnvelope = new TheoreticalIsotopeEnvelope(targetMass, MaxEnvelopeLength, RelativeIsotopePeakIntensityThreshold);
 }
Beispiel #6
0
        public double GetMs1EvidenceScore(int ms2ScanNum, double targetMass, int charge)
        {
            var tolerance = new Tolerance(Comparer.Ppm*0.5);
            if (_ms1Filter != null)
            {
                var ms2ScanNums = _ms1Filter.GetMatchingMs2ScanNums(targetMass);
                if (ms2ScanNums.Any(ms2 => ms2 == ms2ScanNum)) return 1.0d;
            }

            var theoreticalEnvelope = new TheoreticalIsotopeEnvelope(targetMass, MaxEnvelopeLength, RelativeIsotopePeakIntensityThreshold);
            var totalElutionTime = Run.GetElutionTime(Run.MaxLcScan);
            var elutionTime = Run.GetElutionTime(ms2ScanNum);
            var ms1ScanNums = Run.GetMs1ScanVector();

            var minElutionTime = elutionTime - totalElutionTime * 0.002;
            var maxElutionTime = elutionTime + totalElutionTime * 0.002;

            var ms1ScanIndex = Run.GetPrevScanNum(ms2ScanNum, 1);

            var bcDistances = new List<double>();
            var correlations = new List<double>();
            var maxSearchScans = (int)Math.Max(ms1ScanNums.Length - ms1ScanIndex + 1, ms1ScanIndex);

            for (var i = 0; i <= maxSearchScans; i++)
            {
                for (var j = 0; j < 2; j++)
                {
                    if (i == 0 && j > 0) continue;

                    var col = (j < 1) ? ms1ScanIndex + i : ms1ScanIndex - i;
                    if (col >= ms1ScanNums.Length || col < 0) continue;
                    if (Run.GetElutionTime(ms1ScanNums[col]) > maxElutionTime || Run.GetElutionTime(ms1ScanNums[col]) < minElutionTime) continue;

                    var ms1Spec = Ms1Spectra[col];
                    var observedPeaks = ms1Spec.GetAllIsotopePeaks(targetMass, charge, theoreticalEnvelope, tolerance);

                    var bcDist = theoreticalEnvelope.GetBhattacharyyaDistance(observedPeaks);
                    var corrCoeff = theoreticalEnvelope.GetPearsonCorrelation(observedPeaks);

                    if (bcDist < 0.05)
                    {
                        return 1 - bcDist;
                    }
                    if (corrCoeff > 0.7)
                    {
                        return corrCoeff;
                    }

                    bcDistances.Add(bcDist);
                    correlations.Add(corrCoeff);
                }
            }

            if (bcDistances.Count < 1) return 0d;
            return correlations.Max();
        }