コード例 #1
0
        public List<ResultsGroup>[] evaluate(OpenFileDialog FileLinks, Feature featureData)
        {
            List<ResultsGroup>[] AllFinalResults = new List<ResultsGroup>[Convert.ToInt32(FileLinks.FileNames.Count())];
            Int32 Count = 0;
            //Each data file is treated separately, hence the for loop.
            foreach (String filename in FileLinks.FileNames)
            {
                //Get the Parameters.
                ParametersForm parameterForm = new ParametersForm();
                ParametersForm.ParameterSettings parameters = parameterForm.GetParameters();

                //Perform the First and second grouping and getting data for the features by the Grouping function.
                List<ResultsGroup> LRLR = new List<ResultsGroup>();
                LRLR = Groupings(filename, parameters);

                //Generate scores.
                SupervisedLearner sl = new SupervisedLearner();
                AllFinalResults[Count] = sl.Scorings(LRLR, featureData, parameters);
                Count++;
            }
            return AllFinalResults;
        }
コード例 #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();
        }
コード例 #4
0
        public List<ResultsGroup>[] run(OpenFileDialog FileLinks)
        {
            List<ResultsGroup>[] AllFinalResults = new List<ResultsGroup>[Convert.ToInt32(FileLinks.FileNames.Count())];
            Int32 Count = 0;
            //Each data file is treated separately, hence the for loop.
            foreach (String filename in FileLinks.FileNames)
            {
                //Get the Parameters.
                ParametersForm parameter = new ParametersForm();
                ParametersForm.ParameterSettings paradata = parameter.GetParameters();

                //Perform the First and second grouping and getting data for the features by the Grouping function.
                List<ResultsGroup> LRLR = new List<ResultsGroup>();
                LRLR = Groupings(filename, paradata);

                //##############Logistic Regression####################
                Features fe = new Features();
                //current features
                Feature featureData = fe.readFeature();
                //default features
                String defaultpath = Application.StartupPath + "\\FeatureDefault.fea";
                Feature defaultData = fe.readFeature(defaultpath);

                //Features that will be used
                Feature finalfeatureData = new Feature();

                //Here are the beta values in logistic regression.
                finalfeatureData.Initial = featureData.Initial * 0.5 + defaultData.Initial * 0.5;
                finalfeatureData.numChargeStates = featureData.numChargeStates * 0.5 + defaultData.numChargeStates * 0.5;
                finalfeatureData.ScanDensity = featureData.ScanDensity * 0.5 + defaultData.ScanDensity * 0.5;
                finalfeatureData.numModiStates = featureData.numModiStates * 0.5 + defaultData.numModiStates * 0.5;
                finalfeatureData.totalVolume = featureData.totalVolume * 0.5 + defaultData.totalVolume * 0.5;
                finalfeatureData.ExpectedA = featureData.ExpectedA * 0.5 + defaultData.ExpectedA * 0.5;
                finalfeatureData.CentroidScan = featureData.CentroidScan * 0.5 + defaultData.CentroidScan * 0.5;
                finalfeatureData.numOfScan = featureData.numOfScan * 0.5 + defaultData.numOfScan * 0.5;
                finalfeatureData.avgSigNoise = featureData.avgSigNoise * 0.5 + defaultData.avgSigNoise * 0.5;

                //Generate scores.
                SupervisedLearner sl = new SupervisedLearner();
                AllFinalResults[Count] = sl.Scorings(LRLR, finalfeatureData, paradata);
                Count++;
            }
            return AllFinalResults;
        }
コード例 #5
0
 private void RunSupervisedLearner()
 {
     SupervisedLearner SL = new SupervisedLearner();
     ResultGroups = SL.Run(DeconData, CompositionHypothesisList);
 }
コード例 #6
0
        //This function draws the ROC curve by the TP and FP rates calculated from the false data set
        private void DecoyDataROC()
        {
            CompositionHypothesisTabbedForm comp = new CompositionHypothesisTabbedForm();
            SupervisedLearner SL = new SupervisedLearner();
            Features featuresMenu = new Features();
            String currentpath = Application.StartupPath + "\\FeatureCurrent.fea";
            Feature currentFeatures = featuresMenu.readFeature(currentpath);
            //Create the list of random composition hypotesis for testing FDR.
            //ObtainTrue Position data.

            falseDataset fD = new falseDataset();
            List<CompositionHypothesisEntry> falseCH = fD.genFalse(oFDcposTest.FileName, CompositionHypothesisList, oFDPPMSD);
            List<ResultsGroup>[] decoyData = SL.EvaluateFeature(DeconData, falseCH, currentFeatures);

            this.drawGraph(decoyData, " ", 0);

            //Checkbox1 is default features.####################################
            List<ResultsGroup>[] DefaultFeature = new List<ResultsGroup>[DeconData.FileNames.Count()];
            String path = Application.StartupPath + "\\FeatureDefault.fea";
            Feature DeFea = featuresMenu.readFeature(path);
            if (checkBox1.Checked == true)
            {
                List<ResultsGroup>[] decoyDataDefault = SL.EvaluateFeature(DeconData, falseCH, DeFea);
                this.drawGraph(decoyDataDefault, " Default Features", 0);
            }

            //################################################
            //Checkbox2 is unsupervised Learning. It is a bit different from supervised learning, so it is hard-coded here.
            UnsupervisedLearner UL = new UnsupervisedLearner();
            if (checkBox2.Checked == true)
            {
                List<ResultsGroup>[] USLFalseDATA = UL.evaluate(DeconData, currentFeatures);
                //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 < DeconData.FileNames.Count(); i++)
                {
                    decoyData[i] = decoyData[i].OrderByDescending(a => a.DeconRow.MonoisotopicMassWeight).ToList();
                    USLFalseDATA[i] = USLFalseDATA[i].OrderByDescending(b => b.DeconRow.MonoisotopicMassWeight).ToList();
                    int USllasttruematch = 0;
                    for (int j = 0; j < decoyData[i].Count; j++)
                    {
                        if (decoyData[i][j].Match == true)
                        {
                            for (int k = USllasttruematch; k < USLFalseDATA[i].Count; k++)
                            {
                                if (USLFalseDATA[i][k].DeconRow.MonoisotopicMassWeight < decoyData[i][j].DeconRow.MonoisotopicMassWeight)
                                {
                                    USllasttruematch = k;
                                    break;
                                }
                                if (USLFalseDATA[i][k].DeconRow.MonoisotopicMassWeight == decoyData[i][j].DeconRow.MonoisotopicMassWeight)
                                {
                                    USLFalseDATA[i][k].Match = true;
                                    USLFalseDATA[i][k].PredictedComposition = decoyData[i][j].PredictedComposition;
                                    USllasttruematch = k + 1;
                                    break;
                                }
                                if (USLFalseDATA[i][k].DeconRow.MonoisotopicMassWeight > decoyData[i][j].DeconRow.MonoisotopicMassWeight)
                                {
                                    USLFalseDATA[i][k].Match = false;
                                }
                            }
                        }
                    }
                }

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

            //Finally populate the Resulting datagridview and the combobox1

            comboBox2.Invoke(new MethodInvoker(delegate
            {
                for (int i = 0; i < TF.Count; i++)
                {
                    comboBox2.Items.Add(TF[i].TableName);
                }
                comboBox2.SelectedIndex = 0;
            }));
            dataGridView2.Invoke(new MethodInvoker(delegate
            {
                dataGridView2.DataSource = TF[0];
            }));
        }