Exemplo n.º 1
0
            public GraphData(SrmDocument document, int resultIndex, bool bestResult, PointsTypeMassError pointsType)
            {
                _document         = document;
                _resultIndex      = resultIndex;
                _replicateDisplay = ShowReplicate;

                var vals = new List <double>();
                var dictPpmBin2ToCount = new Dictionary <int, int>();

                _displayType = MassErrorGraphController.HistogramDisplayType;
                _binSize     = Settings.Default.MassErorrHistogramBinSize;
                _transition  = MassErrorGraphController.HistogramTransiton;
                _pointsType  = pointsType;

                if (document != null)
                {
                    bool decoys     = pointsType == PointsTypeMassError.decoys;
                    bool precursors = _displayType == DisplayTypeMassError.precursors;

                    foreach (var nodePep in document.Molecules)
                    {
                        if (decoys != nodePep.IsDecoy)
                        {
                            continue;
                        }

                        var replicateIndex = bestResult && nodePep.BestResult != -1 ? nodePep.BestResult : resultIndex;
                        foreach (var nodeGroup in nodePep.TransitionGroups)
                        {
                            foreach (var nodeTran in nodeGroup.Transitions)
                            {
                                if (precursors != nodeTran.IsMs1)
                                {
                                    continue;
                                }
                                if (replicateIndex >= 0)
                                {
                                    AddChromInfo(nodeGroup, nodeTran, replicateIndex, dictPpmBin2ToCount, vals);
                                }
                                else
                                {
                                    for (int i = 0; i < nodeTran.Results.Count; i++)
                                    {
                                        AddChromInfo(nodeGroup, nodeTran, i, dictPpmBin2ToCount, vals);
                                    }
                                }
                            }
                        }
                    }
                }

                _bins = dictPpmBin2ToCount.Select(ppmBin => new PpmBinCount((float)(ppmBin.Key * _binSize), ppmBin.Value)).ToArray();

                var statVals = new Statistics(vals.ToArray());

                _mean   = statVals.Mean();
                _stdDev = statVals.StdDev();
            }
Exemplo n.º 2
0
            public GraphData(SrmDocument document, GraphData dataPrevious, int resultIndex,
                             bool bestResult, PointsTypeMassError pointsType)
            {
                _document         = document;
                _resultIndex      = resultIndex;
                _replicateDisplay = ShowReplicate;

                int[,] counts2D = EMPTY_COUNTS;
                _displayType    = MassErrorGraphController.HistogramDisplayType;
                _binSizePpm     = Settings.Default.MassErorrHistogramBinSize;
                _transition     = MassErrorGraphController.HistogramTransiton;
                _xAxis          = MassErrorGraphController.Histogram2DXAxis;
                _pointsType     = pointsType;
                if (_pointsType == PointsTypeMassError.targets_1FDR && !document.Settings.PeptideSettings.Integration.PeakScoringModel.IsTrained)
                {
                    _pointsType = PointsTypeMassError.targets;
                }

                bool decoys     = pointsType == PointsTypeMassError.decoys;
                bool precursors = _displayType == DisplayTypeMassError.precursors;

                while (ReferenceEquals(counts2D, EMPTY_COUNTS))
                {
                    if (_maxMass != double.MinValue)
                    {
                        counts2D = new int[xAxisBins, (int)((_maxMass - _minMass) / _binSizePpm + 1)];
                    }

                    foreach (var nodePep in document.Molecules)
                    {
                        if (decoys != nodePep.IsDecoy)
                        {
                            continue;
                        }

                        var replicateIndex = bestResult && nodePep.BestResult != -1 ? nodePep.BestResult : resultIndex;
                        foreach (var nodeGroup in nodePep.TransitionGroups)
                        {
                            foreach (var nodeTran in nodeGroup.Transitions)
                            {
                                if (precursors != nodeTran.IsMs1)
                                {
                                    continue;
                                }
                                var mz = nodeTran.Mz.Value;
                                if (replicateIndex >= 0)
                                {
                                    AddChromInfo(nodeGroup, nodeTran, replicateIndex, mz, counts2D);
                                }
                                else
                                {
                                    for (int i = 0; i < nodeTran.Results.Count; i++)
                                    {
                                        AddChromInfo(nodeGroup, nodeTran, i, mz, counts2D);
                                    }
                                }
                            }
                        }
                    }

                    // No values. Leave _maxCount == 0
                    if (_maxMass == double.MinValue)
                    {
                        return;
                    }
                }

                var points = new List <Point3D>();

                for (int x = 0; x < counts2D.GetLength(0); x++)
                {
                    for (int y = 0; y < counts2D.GetLength(1); y++)
                    {
                        int count = counts2D[x, y];
                        if (count > 0)
                        {
                            double binSizeX = (_maxX - _minX) / xAxisBins;
                            double xPoint   = x * binSizeX + _minX + binSizeX / 2;
                            double yPoint   = y * _binSizePpm + _minMass + _binSizePpm / 2;
                            points.Add(new Point3D(xPoint, yPoint, count));
                        }
                        _maxCount = Math.Max(_maxCount, count);
                    }
                }
                _heatMapData = new HeatMapData(points);
            }