Exemplo n.º 1
0
        /// <summary>
        /// perform an EM clustering over the entire screening data
        /// </summary>
        /// <param name="ClassNumber"></param>
        private string ClusteringEMGlobalScreen(int ClassNumber, FormForEMInfo WindowEMinfo)
        {
            weka.core.Instances Ninsts = cGlobalInfo.CurrentScreening.CreateInstancesWithoutClass();// CreateInstanceWithoutClass(CurrentTable);

            weka.clusterers.EM EMCluster = new EM();
            EMCluster.setNumClusters(ClassNumber);
            EMCluster.setMaxIterations((int)WindowEMinfo.numericUpDownMaxIterations.Value);
            EMCluster.setMinStdDev((double)WindowEMinfo.numericUpDownMinStdev.Value);
            EMCluster.setSeed((int)WindowEMinfo.numericUpDownSeedNumber.Value);

            EMCluster.buildClusterer(Ninsts);
            EMCluster.getClusterModelsNumericAtts();
            if (EMCluster.numberOfClusters() > cGlobalInfo.ListWellClasses.Count)
            {
                richTextBoxInfoClustering.AppendText("\nCluster Number: more than " + cGlobalInfo.ListWellClasses.Count + ", clustering not operated.\n");
                return null;
            }

            richTextBoxInfoClustering.AppendText("\n" + EMCluster.numberOfClusters() + " cluster(s) identified");

            ClusterEvaluation eval = new ClusterEvaluation();
            eval.setClusterer(EMCluster);
            eval.evaluateClusterer(Ninsts);

            cGlobalInfo.CurrentScreening.AssignClass(eval.getClusterAssignments());

            return eval.clusterResultsToString();
        }
Exemplo n.º 2
0
        private string ClusteringEM(bool IsFullScreen, int ClassNumber, FormForEMInfo WindowEMinfo)
        {
            if (IsFullScreen)
            {
                string feedback = ClusteringEMGlobalScreen(ClassNumber, WindowEMinfo);
                richTextBoxInfoClustering.AppendText("\nGlobal EM clustering done !\n");
                return feedback;

            }
            else
            {
                int NumberOfPlates = cGlobalInfo.CurrentScreening.ListPlatesActive.Count;
                for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
                {
                    cPlate CurrentPlateToProcess = cGlobalInfo.CurrentScreening.ListPlatesActive.GetPlate(PlateIdx);
                    if ((ClassNumber == 0) || (ClassNumber == 1)) return null;
                    ClusteringEMSinglePlate(CurrentPlateToProcess, ClassNumber, WindowEMinfo);
                }
                richTextBoxInfoClustering.AppendText("\nPlate by plate EM clustering done !\n");
                return null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Perform an EM clustering on each plate independantely
        /// </summary>
        /// <param name="CurrentPlateToProcess">the plate to process</param>
        /// <param name="ClassNumber">Number of class</param>
        private void ClusteringEMSinglePlate(cPlate CurrentPlateToProcess, int ClassNumber, FormForEMInfo WindowEMinfo)
        {
            weka.core.Instances Ninsts = CurrentPlateToProcess.CreateInstancesWithoutClass();// CreateInstanceWithoutClass(CurrentTable);

            weka.clusterers.EM EMCluster = new EM();
            EMCluster.setNumClusters(ClassNumber);

            EMCluster.setMaxIterations((int)WindowEMinfo.numericUpDownMaxIterations.Value);
            EMCluster.setMinStdDev((double)WindowEMinfo.numericUpDownMinStdev.Value);
            EMCluster.setSeed((int)WindowEMinfo.numericUpDownSeedNumber.Value);

            EMCluster.buildClusterer(Ninsts);
            EMCluster.getClusterModelsNumericAtts();
            if (EMCluster.numberOfClusters() > cGlobalInfo.ListWellClasses.Count)
            {
                richTextBoxInfoClustering.AppendText("\n Plate " + CurrentPlateToProcess.GetName() + ", cluster Number: more than " + cGlobalInfo.ListWellClasses.Count + ", clustering not operated.\n");
                return;
            }
            else
                richTextBoxInfoClustering.AppendText("\n" + CurrentPlateToProcess.GetName() + ": " + EMCluster.numberOfClusters() + " cluster(s)");

            ClusterEvaluation eval = new ClusterEvaluation();
            eval.setClusterer(EMCluster);
            eval.evaluateClusterer(Ninsts);

            CurrentPlateToProcess.AssignClass(eval.getClusterAssignments());
        }
Exemplo n.º 4
0
        private void buttonCluster_Click(object sender, EventArgs e)
        {
            if (CompleteScreening == null) return;

            if (!CompleteScreening.IsSelectedDescriptors())
            {
                MessageBox.Show("You have to check at least one descriptor !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Cursor = Cursors.WaitCursor;
            // -------------- K - Means ---------------------------
            if (comboBoxClusteringMethod.SelectedIndex == 0)
            {
                if (radioButtonClusterPlateByPlate.Checked)
                {
                    int NumberOfPlates = CompleteScreening.ListPlatesActive.Count;
                    // loop on all the plate
                    for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
                    {
                        cPlate CurrentPlateToProcess = CompleteScreening.ListPlatesActive.GetPlate(CompleteScreening.ListPlatesActive[PlateIdx].Name);
                        KMeans((int)numericUpDownClusterNumber.Value, CurrentPlateToProcess);
                    }
                    richTextBoxInfoClustering.AppendText("\nPlate by plate clustering done !");
                }
                else
                {
                    KMeansFullScreen((int)numericUpDownClusterNumber.Value);
                    richTextBoxInfoClustering.AppendText("\nGlobal clustering done !");
                }
            }
            else if (comboBoxClusteringMethod.SelectedIndex == 1)   // ---------------- EM --------------------------
            {
                FormForEMInfo WindowEMinfo = new FormForEMInfo();

                if (WindowEMinfo.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

                if (checkBoxAutomatedClusterNumber.Checked)
                {
                    string feedback = ClusteringEM(radioButtonClusterFullScreen.Checked, -1, WindowEMinfo);
                    if (feedback != null)
                    {
                        FormForCellByCellClusteringResults WindowFormForCellByCellClusteringResults = new FormForCellByCellClusteringResults();
                        WindowFormForCellByCellClusteringResults.richTextBoxResults.Clear();
                        WindowFormForCellByCellClusteringResults.richTextBoxResults.AppendText(feedback);
                        WindowFormForCellByCellClusteringResults.buttonPerformLearning.Text = "Ok";
                        WindowFormForCellByCellClusteringResults.ShowDialog();
                    }
                }
                else
                {
                    string feedback = ClusteringEM(radioButtonClusterFullScreen.Checked, (int)numericUpDownClusterNumber.Value, WindowEMinfo);
                    if (feedback != null)
                    {
                        FormForCellByCellClusteringResults WindowFormForCellByCellClusteringResults = new FormForCellByCellClusteringResults();
                        WindowFormForCellByCellClusteringResults.richTextBoxResults.Clear();
                        WindowFormForCellByCellClusteringResults.richTextBoxResults.AppendText(feedback);
                        WindowFormForCellByCellClusteringResults.buttonPerformLearning.Text = "Ok";
                        WindowFormForCellByCellClusteringResults.ShowDialog();
                    }
                }
            }
            else if (comboBoxClusteringMethod.SelectedIndex == 2)   // ---------------- Hierarchical --------------------------
            {
                if (checkBoxAutomatedClusterNumber.Checked)
                    ClusteringHierarchical(radioButtonClusterFullScreen.Checked, -1);
                else
                    ClusteringHierarchical(radioButtonClusterFullScreen.Checked, (int)numericUpDownClusterNumber.Value);

            }

            //CompleteScreening.GetPlate(CompleteScreening.CurrentDisplayPlate).DisplayClasses(CompleteScreening.PanelForPlate);
            //   tabControlMain.SelectedTab = tabPageDistribution;
            this.Cursor = Cursors.Default;

            CompleteScreening.GetCurrentDisplayPlate().DisplayDistribution(CompleteScreening.ListDescriptors.CurrentSelectedDescriptor, false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Perform an EM clustering on each plate independantely
        /// </summary>
        /// <param name="CurrentPlateToProcess">the plate to process</param>
        /// <param name="ClassNumber">Number of class</param>
        private void ClusteringEMSinglePlate(cPlate CurrentPlateToProcess, int ClassNumber, FormForEMInfo WindowEMinfo)
        {
            weka.core.Instances Ninsts = CurrentPlateToProcess.CreateInstancesWithoutClass();// CreateInstanceWithoutClass(CurrentTable);
            if (Ninsts.numInstances() == 0)
            {
                MessageBox.Show("No active wells !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            weka.clusterers.EM EMCluster = new EM();
            EMCluster.setNumClusters(ClassNumber);

            EMCluster.setMaxIterations((int)WindowEMinfo.numericUpDownMaxIterations.Value);
            EMCluster.setMinStdDev((double)WindowEMinfo.numericUpDownMinStdev.Value);
            EMCluster.setSeed((int)WindowEMinfo.numericUpDownSeedNumber.Value);

            EMCluster.buildClusterer(Ninsts);
            EMCluster.getClusterModelsNumericAtts();
            if (EMCluster.numberOfClusters() > GlobalInfo.GetNumberofDefinedClass())
            {
                richTextBoxInfoClustering.AppendText("\n Plate " + CurrentPlateToProcess.Name + ", cluster Number: more than " + GlobalInfo.GetNumberofDefinedClass() + ", clustering not operated.\n");
                return;
            }
            else
                richTextBoxInfoClustering.AppendText("\n" + CurrentPlateToProcess.Name + ": " + EMCluster.numberOfClusters() + " cluster(s)");

            ClusterEvaluation eval = new ClusterEvaluation();
            eval.setClusterer(EMCluster);
            eval.evaluateClusterer(Ninsts);

            CurrentPlateToProcess.AssignClass(eval.getClusterAssignments());
        }