コード例 #1
0
        //First method, run supervised learning with composition hypothesis.
        public MS1ResultsViewer(OpenFileDialog oFDDeconData, String ComHypoLink)
        {
            InitializeComponent();
            DeconData = oFDDeconData;
            CompositionHypothesisTabbedForm ct = new CompositionHypothesisTabbedForm();
            CompositionHypothesisList = ct.getCompHypo(ComHypoLink);

            //This part is used to show the "Please Wait" box while running the code.
            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += new DoWorkEventHandler(bw_DoWork);
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);

            //set lable and your waiting text in this form
            try
            {
                bw.RunWorkerAsync();//this will run the DoWork code at background thread
                WaitForm.ShowDialog();//show the please wait box
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            var elementsAndMolecules = GroupingResults.GetElementsAndMolecules(ResultGroups[0]);
            ElementIDs = elementsAndMolecules.Item1;
            MoleculeNames = elementsAndMolecules.Item2;
            //ElementIDs.Clear();
            //MoleculeNames.Clear();
            //for (int i = 0; i < ResultGroups[0].Count(); i++)
            //{
            //    if (ResultGroups[0][i].PredictedComposition.ElementNames.Count() > 0)
            //    {
            //        for (int j = 0; j < ResultGroups[0][i].PredictedComposition.ElementNames.Count(); j++)
            //        {
            //            ElementIDs.Add(ResultGroups[0][i].PredictedComposition.ElementNames[j]);
            //        }
            //        for (int j = 0; j < ResultGroups[0][i].PredictedComposition.MoleculeNames.Count(); j++)
            //        {
            //            MoleculeNames.Add(ResultGroups[0][i].PredictedComposition.MoleculeNames[j]);
            //        }
            //    }
            //}

            comboBox1.DataSource = oFDDeconData.FileNames;
            comboBox1.SelectedIndex = 0;
            VolumeHistogramFileSelector.DataSource = oFDDeconData.FileNames;
            VolumeHistogramFileSelector.SelectedIndex = 0;
            ResultsGridView.DataSource = ToDataTable(ResultGroups, 0);
            ResultsGridView.ReadOnly = true;
        }
コード例 #2
0
        //This function draws the ROC curve by the TP and FP rates calculated from the score.
        private void scoreBasedGraph()
        {
            CompositionHypothesisTabbedForm comp = new CompositionHypothesisTabbedForm();
            SupervisedLearner SL = new SupervisedLearner();
            Feature Fea = readFeature(oFDAddFeatureFiles.FileName);
            //Create the list of random composition hypotesis for testing FDR.
            //ObtainTrue Position data.
            List<CompositionHypothesisEntry> CH = comp.getCompHypo(oFDCompositionTest.FileName);
            List<ResultsGroup>[] TrueDATA = SL.EvaluateFeature(oFDTest, CH, Fea);

            this.drawGraph(TrueDATA, " Loaded Features");

            //Checkbox1 is default features.####################################
            List<ResultsGroup>[] DefaultFeature = new List<ResultsGroup>[oFDTest.FileNames.Count()];
            String path = Application.StartupPath + "\\FeatureDefault.fea";
            Feature DeFea = readFeature(path);
            if (checkBox1.Checked == true)
            {
                List<ResultsGroup>[] TrueDATADefault = SL.EvaluateFeature(oFDTest, CH, DeFea);

                this.drawGraph(TrueDATADefault, " Default Features");
            }

            //################################################
            //Checkbox2 is unsupervised Learning. It is a bit different from supervised learning, so it is hard-coded here.

            if (checkBox2.Checked == true)
            {
                UnsupervisedLearner UL = new UnsupervisedLearner();
                List<ResultsGroup>[] USLTrueDATA = UL.evaluate(oFDTest, Fea);
                //ROC curve needs match to perform, so we will use the match list from Supervised learning and apply them to USLDATA.
                for (int i = 0; i < oFDTest.FileNames.Count(); i++)
                {
                    USLTrueDATA[i] = USLTrueDATA[i].OrderByDescending(b => b.DeconRow.MonoisotopicMassWeight).ToList();
                    int USllasttruematch = 0;
                    for (int j = 0; j < TrueDATA[i].Count; j++)
                    {
                        if (TrueDATA[i][j].Match == true)
                        {
                            for (int k = USllasttruematch; k < USLTrueDATA[i].Count; k++)
                            {
                                if (USLTrueDATA[i][k].DeconRow.MonoisotopicMassWeight < TrueDATA[i][j].DeconRow.MonoisotopicMassWeight)
                                {
                                    USllasttruematch = k;
                                    break;
                                }
                                if (USLTrueDATA[i][k].DeconRow.MonoisotopicMassWeight == TrueDATA[i][j].DeconRow.MonoisotopicMassWeight)
                                {
                                    USLTrueDATA[i][k].Match = true;
                                    USLTrueDATA[i][k].PredictedComposition = TrueDATA[i][j].PredictedComposition;
                                    USllasttruematch = k + 1;
                                    break;
                                }
                                if (USLTrueDATA[i][k].DeconRow.MonoisotopicMassWeight > TrueDATA[i][j].DeconRow.MonoisotopicMassWeight)
                                {
                                    USLTrueDATA[i][k].Match = false;
                                }
                            }
                        }
                    }
                }

                //Now that both of the data got their matchs, draw the graph
                this.drawGraph(USLTrueDATA, " Unsupervised Learning + Loaded Features");
            }
            //#############################unsupervised learning part ends#################

            //Finally populate the Resulting datagridview and the combobox1

            comboBox1.Invoke(new MethodInvoker(delegate
            {
                for (int i = 0; i < TF.Count; i++)
                {
                    comboBox1.Items.Add(TF[i].TableName);
                }
                comboBox1.SelectedIndex = 0;
            }));
            dataGridView1.Invoke(new MethodInvoker(delegate
            {
                dataGridView1.DataSource = TF[0];
            }));
        }
コード例 #3
0
        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            //Obtain Feature
            Feature Ans = new Feature();
            SupervisedLearner SL = new SupervisedLearner();
            CompositionHypothesisTabbedForm comp = new CompositionHypothesisTabbedForm();
            List<CompositionHypothesisEntry> comhy = comp.getCompHypo(oFDComposition.FileName);
            Ans = SL.obtainFeatures(oFDTrain, comhy);

            //Write Features to File
            String path = Application.StartupPath + "\\FeatureCurrent.fea";
            FileStream FS = new FileStream(path, FileMode.Create, FileAccess.Write);
            StreamWriter Write1 = new StreamWriter(FS);
            Write1.Write(Ans.Initial + "," + Ans.numChargeStates + "," + Ans.ScanDensity + "," + Ans.numModiStates + "," + Ans.totalVolume + "," + Ans.ExpectedA + "," + Ans.CentroidScan + "," + Ans.numOfScan + "," + Ans.avgSigNoise);
            Write1.Flush();
            Write1.Close();
            FS.Close();
        }