Example #1
0
 private ToolStripMenuItem MakeToolStripMenuItem(GroupComparisonDef groupComparisonDef)
 {
     return(new ToolStripMenuItem(groupComparisonDef.Name, null, (sender, args) =>
     {
         SkylineWindow.ShowGroupComparisonWindow(groupComparisonDef.Name);
     }));
 }
Example #2
0
        private void VerifyFoldChanges(SrmDocument testDocument, GroupComparisonDef groupComparisonDef,
                                       IDictionary <string, LinearFitResult> expectedResults)
        {
            var groupComparer = new GroupComparer(groupComparisonDef, testDocument, new QrFactorizationCache());

            foreach (var protein in testDocument.MoleculeGroups)
            {
                var             groupComparisonResult = groupComparer.CalculateFoldChanges(protein, null).FirstOrDefault();
                LinearFitResult expectedResult;
                if (expectedResults.TryGetValue(protein.Name, out expectedResult))
                {
                    Assert.IsNotNull(groupComparisonResult);
                    var foldChange = groupComparisonResult.LinearFitResult;
                    Assert.AreEqual(expectedResult.EstimatedValue, foldChange.EstimatedValue, 1E-5);
                    Assert.AreEqual(expectedResult.DegreesOfFreedom, foldChange.DegreesOfFreedom);
                    Assert.AreEqual(expectedResult.StandardError, foldChange.StandardError, 1E-5);
                    Assert.AreEqual(expectedResult.TValue, foldChange.TValue, 1E-5);
                    Assert.AreEqual(expectedResult.PValue, foldChange.PValue, 1E-5);
                }
                else
                {
                    Assert.IsNull(groupComparisonResult);
                    var standardPeptides = protein.Molecules.Where(mol => !string.IsNullOrEmpty(mol.GlobalStandardType)).ToArray();
                    Assert.AreNotEqual(0, standardPeptides.Length);
                }
            }
        }
Example #3
0
        public void ChangeGroupComparison(Control owner, string name, Action <EditGroupComparisonDlg> action)
        {
            GroupComparisonDef def = null;

            RunDlg <EditGroupComparisonDlg>(() => def = Settings.Default.GroupComparisonDefList.EditItem(owner,
                                                                                                         FindGroupComparison(name),
                                                                                                         Settings.Default.GroupComparisonDefList, SkylineWindow), d =>
            {
                action(d);
                d.OkDialog();
            });

            RunUI(() =>
            {
                int index = Settings.Default.GroupComparisonDefList.ToList().FindIndex(g => g.Name == name);
                if (index >= 0)
                {
                    Settings.Default.GroupComparisonDefList[index] = def;
                    SkylineWindow.ModifyDocument(Resources.SkylineWindow_AddGroupComparison_Add_Fold_Change,
                                                 doc => doc.ChangeSettings(
                                                     doc.Settings.ChangeDataSettings(
                                                         doc.Settings.DataSettings.AddGroupComparisonDef(
                                                             def))));
                }
            });
        }
 protected void comboControlValue_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_inChangeSettings)
     {
         return;
     }
     GroupComparisonDef = GroupComparisonDef.ChangeControlValue(comboControlValue.SelectedItem as string);
 }
 protected void cbxTreatMissingAsZero_CheckedChanged(object sender, EventArgs e)
 {
     if (_inChangeSettings)
     {
         return;
     }
     GroupComparisonDef = GroupComparisonDef.ChangeUseZeroForMissingPeaks(((CheckBox)sender).Checked);
 }
Example #6
0
 private void radioScope_CheckedChanged(object sender, EventArgs e)
 {
     if (_inChangeSettings)
     {
         return;
     }
     GroupComparisonDef = GroupComparisonDef.ChangePerProtein(radioScopeProtein.Checked);
 }
 private void comboSummaryMethod_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_inChangeSettings)
     {
         return;
     }
     GroupComparisonDef = GroupComparisonDef.ChangeSummarizationMethod(
         comboSummaryMethod.SelectedItem as SummarizationMethod ?? SummarizationMethod.DEFAULT);
 }
        protected void comboControlAnnotation_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_inChangeSettings)
            {
                return;
            }
            var comboControlAnnotation = (ComboBox)sender;

            GroupComparisonDef =
                GroupComparisonDef.ChangeControlAnnotation(
                    comboControlAnnotation.SelectedItem as string);
        }
        protected void comboNormalizationMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_inChangeSettings)
            {
                return;
            }
            var normalizationMethod = comboNormalizationMethod.SelectedItem as NormalizationMethod ??
                                      NormalizationMethod.NONE;

            GroupComparisonDef = GroupComparisonDef
                                 .ChangeNormalizationMethod(normalizationMethod);
        }
Example #10
0
        public GroupComparisonDef FindGroupComparison(string name)
        {
            GroupComparisonDef def = null;

            RunUI(() =>
            {
                def = SkylineWindow.DocumentUI.Settings.DataSettings.GroupComparisonDefs.FirstOrDefault(g =>
                                                                                                        g.Name == name);
            });

            return(def);
        }
Example #11
0
 public EditGroupComparisonDlg(IDocumentUIContainer documentContainer,
                               GroupComparisonDef groupComparisonDef, IEnumerable <GroupComparisonDef> existingGroupComparisons)
     : this(new GroupComparisonModel(documentContainer, null) { GroupComparisonDef = groupComparisonDef })
 {
     _originalGroupComparisonDef = groupComparisonDef;
     _existingGroupComparisons   = existingGroupComparisons;
     if (documentContainer == null)
     {
         btnPreview.Visible = false;
     }
     _pushChangesToDocument = false;
     tbxName.Text           = groupComparisonDef.Name ?? string.Empty;
 }
Example #12
0
        protected void comboCaseValue_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_inChangeSettings)
            {
                return;
            }
            string caseValue = comboCaseValue.SelectedItem as string;

            if (string.IsNullOrEmpty(caseValue))
            {
                caseValue = null;
            }
            GroupComparisonDef = GroupComparisonDef.ChangeCaseValue(caseValue);
        }
Example #13
0
        public void TestFoldChangeWithNoNormalization()
        {
            SrmDocument testDocument    = OpenTestDocument();
            var         expectedResults = MsStatsTestUtil.ReadExpectedResults(typeof(MsStatsNormalizationTest),
                                                                              "BrudererSubsetNoNormalization_TestingResult.csv");
            GroupComparisonDef groupComparisonDef = new GroupComparisonDef("test")
                                                    .ChangeControlValue("S2")
                                                    .ChangeCaseValue("S1")
                                                    .ChangeControlAnnotation("Condition")
                                                    .ChangeIdentityAnnotation("BioReplicate")
                                                    .ChangePerProtein(true)
                                                    .ChangeNormalizationMethod(NormalizationMethod.NONE);

            VerifyFoldChanges(testDocument, groupComparisonDef, expectedResults);
        }
Example #14
0
        public DataSettings AddGroupComparisonDef(GroupComparisonDef groupComparisonDef)
        {
            var groupComparisonDefs = GroupComparisonDefs.ToList();
            int index = GroupComparisonDefs.IndexOf(def => def.Name == groupComparisonDef.Name);

            if (index < 0)
            {
                groupComparisonDefs.Add(groupComparisonDef);
            }
            else
            {
                groupComparisonDefs[index] = groupComparisonDef;
            }
            return(ChangeGroupComparisonDefs(groupComparisonDefs));
        }
Example #15
0
        protected void tbxConfidenceLevel_TextChanged(object sender, EventArgs e)
        {
            if (_inChangeSettings)
            {
                return;
            }
            double           confidenceLevel;
            MessageBoxHelper helper = new MessageBoxHelper(this, false);

            if (!helper.ValidateDecimalTextBox(tbxConfidenceLevel, 0, 100, out confidenceLevel))
            {
                return;
            }
            GroupComparisonDef = GroupComparisonDef.ChangeConfidenceLevelTimes100(confidenceLevel);
        }
        public static ViewSpec GetDefaultViewSpec(GroupComparisonDef groupComparisonDef,
                                                  IList <FoldChangeBindingSource.FoldChangeRow> foldChangeRows)
        {
            bool showPeptide;
            bool showLabelType;
            bool showMsLevel;

            if (foldChangeRows.Any())
            {
                showPeptide   = foldChangeRows.Any(row => null != row.Peptide);
                showLabelType = foldChangeRows.Select(row => row.IsotopeLabelType).Distinct().Count() > 1;
                showMsLevel   = foldChangeRows.Select(row => row.MsLevel).Distinct().Count() > 1;
            }
            else
            {
                showPeptide   = !groupComparisonDef.PerProtein;
                showLabelType = false;
                showMsLevel   = false;
            }
            // ReSharper disable NonLocalizedString
            var columns = new List <PropertyPath>
            {
                PropertyPath.Root.Property("Protein")
            };

            if (showPeptide)
            {
                columns.Add(PropertyPath.Root.Property("Peptide"));
            }
            if (showMsLevel)
            {
                columns.Add(PropertyPath.Root.Property("MsLevel"));
            }
            if (showLabelType)
            {
                columns.Add(PropertyPath.Root.Property("IsotopeLabelType"));
            }
            columns.Add(PropertyPath.Root.Property("FoldChangeResult"));
            columns.Add(PropertyPath.Root.Property("FoldChangeResult").Property("AdjustedPValue"));
            // ReSharper restore NonLocalizedString

            var viewSpec = new ViewSpec()
                           .SetName(DefaultViewName)
                           .SetRowType(typeof(FoldChangeBindingSource.FoldChangeRow))
                           .SetColumns(columns.Select(col => new ColumnSpec(col)));

            return(viewSpec);
        }
Example #17
0
        public void RunTestFoldChangeEqualizeMedians(bool asSmallMolecules)
        {
            SrmDocument testDocument = OpenTestDocument();

            if (testDocument == null)
            {
                Assume.IsTrue(asSmallMolecules);
                return;
            }
            var expectedResults = MsStatsTestUtil.ReadExpectedResults(typeof(MsStatsNormalizationTest),
                                                                      "BrudererSubsetEqualizeMedians_TestingResult.csv");
            GroupComparisonDef groupComparisonDef = new GroupComparisonDef("test")
                                                    .ChangeControlValue("S2")
                                                    .ChangeCaseValue("S1")
                                                    .ChangeControlAnnotation("Condition")
                                                    .ChangeIdentityAnnotation("BioReplicate")
                                                    .ChangePerProtein(true)
                                                    .ChangeNormalizationMethod(NormalizationMethod.EQUALIZE_MEDIANS);

            VerifyFoldChanges(testDocument, groupComparisonDef, expectedResults);
        }
Example #18
0
        protected void comboIdentityAnnotation_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_inChangeSettings)
            {
                return;
            }
            string identityAnnotation = comboIdentityAnnotation.SelectedItem as string;

            if (string.IsNullOrEmpty(identityAnnotation))
            {
                GroupComparisonDef = GroupComparisonDef
                                     .ChangeIdentityAnnotation(null)
                                     .ChangeAverageTechnicalReplicates(false);
            }
            else
            {
                GroupComparisonDef = GroupComparisonDef
                                     .ChangeIdentityAnnotation(identityAnnotation)
                                     .ChangeAverageTechnicalReplicates(true);
            }
        }
Example #19
0
 private void tbxQValueCutoff_TextChanged(object sender, EventArgs e)
 {
     if (_inChangeSettings)
     {
         return;
     }
     if (string.IsNullOrEmpty(tbxQValueCutoff.Text.Trim()))
     {
         GroupComparisonDef = GroupComparisonDef.ChangeQValueCutoff(null);
     }
     else
     {
         MessageBoxHelper helper = new MessageBoxHelper(this, false);
         double           qValueCutoff;
         if (!helper.ValidateDecimalTextBox(tbxQValueCutoff, 0, 1, out qValueCutoff))
         {
             return;
         }
         GroupComparisonDef = GroupComparisonDef.ChangeQValueCutoff(qValueCutoff);
     }
 }
Example #20
0
 public EditGroupComparisonDlg(IDocumentContainer documentContainer,
                               GroupComparisonDef groupComparisonDef, IEnumerable <GroupComparisonDef> existingGroupComparisons)
     : base(new GroupComparisonModel(documentContainer, null) { GroupComparisonDef = groupComparisonDef })
 {
     InitializeComponent();
     Icon = Resources.Skyline;
     _originalGroupComparisonDef = groupComparisonDef;
     _existingGroupComparisons   = existingGroupComparisons;
     if (documentContainer == null)
     {
         btnPreview.Visible = false;
     }
     tbxName.Text = groupComparisonDef.Name ?? string.Empty;
     tbxConfidenceLevel.TextChanged += tbxConfidenceLevel_TextChanged;
     comboControlAnnotation.SelectedIndexChanged   += comboControlAnnotation_SelectedIndexChanged;
     comboCaseValue.SelectedIndexChanged           += comboCaseValue_SelectedIndexChanged;
     comboControlValue.SelectedIndexChanged        += comboControlValue_SelectedIndexChanged;
     comboIdentityAnnotation.SelectedIndexChanged  += comboIdentityAnnotation_SelectedIndexChanged;
     comboNormalizationMethod.SelectedIndexChanged += comboNormalizationMethod_SelectedIndexChanged;
     radioScopeProtein.CheckedChanged += radioScope_CheckedChanged;
     radioScopePeptide.CheckedChanged += radioScope_CheckedChanged;
 }
Example #21
0
 private bool RequiresAdvanced(GroupComparisonDef groupComparisonDef)
 {
     return(groupComparisonDef.QValueCutoff.HasValue ||
            groupComparisonDef.SummarizationMethod != SummarizationMethod.AVERAGING ||
            groupComparisonDef.UseZeroForMissingPeaks);
 }
Example #22
0
        public void ShowFormattingDialog()
        {
            var foldChangeRows = _bindingListSource.OfType <RowItem>()
                                 .Select(rowItem => rowItem.Value)
                                 .OfType <FoldChangeBindingSource.FoldChangeRow>()
                                 .ToArray();

            var backup = GroupComparisonDef.ColorRows.Select(r => (MatchRgbHexColor)r.Clone()).ToArray();
            // This list will later be used as a BindingList, so we have to create a mutable clone
            var copy = GroupComparisonDef.ColorRows.Select(r => (MatchRgbHexColor)r.Clone()).ToList();

            using (var form = new VolcanoPlotFormattingDlg(this, copy, foldChangeRows,
                                                           rows =>
            {
                EditGroupComparisonDlg.ChangeGroupComparisonDef(false, GroupComparisonModel, GroupComparisonDef.ChangeColorRows(rows));
                UpdateGraph();
            }))
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    EditGroupComparisonDlg.ChangeGroupComparisonDef(true, GroupComparisonModel, GroupComparisonDef);
                }
                else
                {
                    EditGroupComparisonDlg.ChangeGroupComparisonDef(false, GroupComparisonModel, GroupComparisonDef.ChangeColorRows(backup));
                }

                UpdateGraph();
            }
        }
Example #23
0
        public static void ChangeGroupComparisonDef(bool pushChangesToDocument, GroupComparisonModel model, GroupComparisonDef groupDef)
        {
            if (pushChangesToDocument)
            {
                Program.MainWindow.ModifyDocument(
                    GroupComparisonStrings.GroupComparisonSettingsForm_GroupComparisonDef_Change_Group_Comparison,
                    doc => model.ApplyChangesToDocument(doc, groupDef),
                    AuditLogEntry.SettingsLogFunction
                    );

                Settings.Default.GroupComparisonDefList.Add(groupDef);
            }
            else
            {
                model.GroupComparisonDef = groupDef;
            }
        }