예제 #1
0
        public void MakeFilesLists(ComparePeakBoundaries comparer, double falsePositiveCutoff, out PointPairList filesPoints, out List <string> filesNames)
        {
            filesPoints = new PointPairList();
            filesNames  = new List <string>();
            var matches       = comparer.Matches;
            var matchesByFile = matches.GroupBy(match => match.FileName).OrderBy(group => group.Key);
            int i             = 1;

            foreach (var matchGroup in matchesByFile)
            {
                PointPairList rocPoints;
                var           matchesInGroup = matchGroup.ToList();
                if (comparer.HasNoScores)
                {
                    matchesInGroup.Sort(PeakBoundsMatch.CompareQValue);
                }
                else
                {
                    matchesInGroup.Sort(PeakBoundsMatch.CompareScore);
                }
                RocFromSortedMatches(matchesInGroup, Normalizer, out rocPoints);
                double correctPeaks = GetCurveThreshold(rocPoints, falsePositiveCutoff);
                filesPoints.Add(i++, correctPeaks);
                filesNames.Add(matchGroup.Key);
            }
        }
예제 #2
0
        public static void MakeQValueLists(ComparePeakBoundaries comparer, out PointPairList qqPoints)
        {
            qqPoints = new PointPairList();
            var matches = comparer.Matches;

            matches.Sort(PeakBoundsMatch.CompareQValue);
            int truePositives  = 0;
            int falsePositives = 0;

            foreach (var match in matches)
            {
                if (match.IsFalsePositive)
                {
                    falsePositives++;
                }
                if (match.IsPickedApexBetweenCuratedBoundaries)
                {
                    truePositives++;
                }
                // Null qValues get the worst score
                double qValue  = match.QValue ?? 1.0;
                var    qqPoint = new PointPair(qValue, falsePositives / (double)(truePositives + falsePositives));
                qqPoints.Add(qqPoint);
            }
        }
예제 #3
0
        public void MakeFilesLists(ComparePeakBoundaries comparer, double falsePositiveCutoff, bool observed, out PointPairList filesPoints, out List <string> filesNames)
        {
            filesPoints = new PointPairList();
            filesNames  = new List <string>();
            var matches       = comparer.Matches;
            var matchesByFile = matches.GroupBy(match => match.ReplicateName).OrderBy(group => group.Key);
            int i             = 1;

            foreach (var matchGroup in matchesByFile)
            {
                PointPairList rocPoints;
                var           matchesInGroup = matchGroup.ToList();
                if (comparer.HasNoScores)
                {
                    matchesInGroup.Sort(PeakBoundsMatch.CompareQValue);
                }
                else
                {
                    matchesInGroup.Sort(PeakBoundsMatch.CompareScore);
                }
                RocFromSortedMatches(matchesInGroup, Normalizer, out rocPoints);
                var pointThreshold = GetCurveThreshold(rocPoints, falsePositiveCutoff, observed);
                // Error is 2x the observed error rate, so that wiskers extend above and below bar item
                // by the number of observed false-positives
                filesPoints.Add(MeanErrorBarItem.MakePointPair(i++, pointThreshold.Y, pointThreshold.X * pointThreshold.Y * 2));
                filesNames.Add(matchGroup.Key);
            }
        }
예제 #4
0
        public static void MakeRocLists(ComparePeakBoundaries comparer, NormalizeType normalizer, out PointPairList rocPoints)
        {
            var matches = comparer.Matches;

            if (comparer.HasNoScores)
            {
                matches.Sort(PeakBoundsMatch.CompareQValue);
            }
            else
            {
                matches.Sort(PeakBoundsMatch.CompareScore);
            }
            RocFromSortedMatches(matches, normalizer, out rocPoints);
        }
예제 #5
0
        public AddPeakCompareDlg(SrmDocument document, ComparePeakBoundaries current, IEnumerable <ComparePeakBoundaries> existing)
            : this(document, existing)
        {
            // If second argument is null, treat it as if it wasn't there -- for EditListDlg
            if (current == null)
            {
                return;
            }
            _current = current;
            radioButtonModel.Checked = current.IsModel;
            radioButtonFile.Checked  = !current.IsModel;
            textFilePath.Text        = current.FilePath;
            textName.Text            = current.FileName;
            var model = current.PeakScoringModel;

            _driverPeakScoringModel.LoadList(model != null ? model.Name : null);
        }
예제 #6
0
        public void OkDialog()
        {
            bool isModel = radioButtonModel.Checked;

            if (isModel)
            {
                var model = _driverPeakScoringModel.SelectedItem;
                if (model == null)
                {
                    MessageDlg.Show(this, Resources.PeakBoundaryCompareTest_DoTest_Must_select_a_model_for_comparison_);
                    return;
                }
                if (!model.IsTrained)
                {
                    MessageDlg.Show(this, Resources.AddPeakCompareDlg_OkDialog_Model_must_be_trained_before_it_can_be_used_for_peak_boundary_comparison_);
                    return;
                }
                BoundaryComparer = new ComparePeakBoundaries(model);
            }
            else
            {
                string displayName = textName.Text;
                if (displayName.Length == 0)
                {
                    MessageDlg.Show(this, Resources.AddPeakCompareDlg_OkDialog_Comparison_name_cannot_be_empty_);
                    return;
                }
                string filePath = textFilePath.Text;
                if (filePath.Length == 0)
                {
                    MessageDlg.Show(this, Resources.AddPeakCompareDlg_OkDialog_File_path_cannot_be_empty_);
                    return;
                }
                if (!File.Exists(filePath))
                {
                    MessageDlg.Show(this, Resources.AddPeakCompareDlg_OkDialog_File_path_field_must_contain_a_path_to_a_valid_file_);
                    return;
                }
                BoundaryComparer = new ComparePeakBoundaries(displayName, filePath);
            }
            var compNames = _existing.Select(comp => comp.Name);

            if (compNames.Contains(BoundaryComparer.Name) && (_current == null || _current.Name != BoundaryComparer.Name))
            {
                var message = isModel
                    ? Resources.AddPeakCompareDlg_OkDialog_The_selected_model_is_already_included_in_the_list_of_comparisons__Please_choose_another_model_
                    : Resources.AddPeakCompareDlg_OkDialog_There_is_already_an_imported_file_with_the_current_name___Please_choose_another_name;
                MessageDlg.Show(this, message);
                return;
            }
            using (var longWaitDlg = new LongWaitDlg
            {
                Text = isModel ? Resources.AddPeakCompareDlg_OkDialog_Comparing_Models : Resources.AddPeakCompareDlg_OkDialog_Comparing_Imported_Files
            })
            {
                try
                {
                    longWaitDlg.PerformWork(this, 1000, pm => BoundaryComparer.GenerateComparison(Document, pm));
                    if (BoundaryComparer.Matches.Count == 0)
                    {
                        throw new IOException(Resources.AddPeakCompareDlg_OkDialog_Document_has_no_eligible_chromatograms_for_analysis___Valid_chromatograms_must_not_be_decoys_or_iRT_standards_);
                    }
                    if (BoundaryComparer.Matches.All(match => match.IsMissingPickedPeak))
                    {
                        throw new IOException(Resources.AddPeakCompareDlg_OkDialog_The_selected_file_or_model_does_not_assign_peak_boundaries_to_any_chromatograms_in_the_document___Please_select_a_different_model_or_file_);
                    }
                    if (BoundaryComparer.HasNoQValues && BoundaryComparer.HasNoScores)
                    {
                        throw new IOException(Resources.AddPeakCompareDlg_OkDialog_The_current_file_or_model_has_no_q_values_or_scores_to_analyze___Either_q_values_or_scores_are_necessary_to_compare_peak_picking_tools_);
                    }
                    if (BoundaryComparer.CountMissing > 0)
                    {
                        var missingMessage = string.Format(Resources.AddPeakCompareDlg_OkDialog_The_imported_file_does_not_contain_any_peak_boundaries_for__0__transition_group___file_pairs___These_chromatograms_will_be_treated_as_if_no_boundary_was_selected_,
                                                           BoundaryComparer.CountMissing);
                        var dlgMissing = MultiButtonMsgDlg.Show(this, missingMessage, MultiButtonMsgDlg.BUTTON_OK);
                        if (dlgMissing == DialogResult.Cancel)
                        {
                            return;
                        }
                    }
                    // Show a warning message and give a chance to cancel, if there are unrecognized peptides
                    if (BoundaryComparer.Importer != null && !BoundaryComparer.Importer.UnrecognizedPeptidesCancel(this))
                    {
                        return;
                    }
                }
                catch (Exception x)
                {
                    string initMessage = isModel
                        ? Resources.AddPeakCompareDlg_OkDialog_Error_comparing_model_peak_boundaries___0_
                        : Resources.AddPeakCompareDlg_OkDialog_Error_applying_imported_peak_boundaries___0_;
                    MessageDlg.ShowWithException(this, string.Format(initMessage, x.Message), x);
                    return;
                }
            }
            DialogResult = DialogResult.OK;
        }