示例#1
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());
        }
示例#2
0
        /// <summary>
        /// Perform an Hierarchical clustering on each plate independantely
        /// </summary>
        /// <param name="CurrentPlateToProcess">the plate to process</param>
        /// <param name="ClassNumber">Number of class</param>
        private void ClusteringHierarchicalSinglePlate(cPlate CurrentPlateToProcess, int ClassNumber)
        {
            weka.core.Instances Ninsts = CurrentPlateToProcess.CreateInstancesWithoutClass();

            weka.clusterers.HierarchicalClusterer HClusterer = new HierarchicalClusterer();

            //string OptionDistance = " -A \"weka.core.";
            string OptionDistance = " -A \"";

            switch (cGlobalInfo.OptionsWindow.comboBoxHierarchicalDistance.SelectedIndex)
            {
                case 0:
                    OptionDistance += "EuclideanDistance";
                    break;
                case 1:
                    OptionDistance += "ManhattanDistance";
                    break;
                case 2:
                    OptionDistance += "ChebyshevDistance";
                    break;
                default:
                    break;
            }

            OptionDistance += " -R first-last\"";

            string[] TAGS_LINK_TYPE = { "SINGLE", "COMPLETE", "AVERAGE", "MEAN", "CENTROID", "WARD", "ADJCOMPLETE" };

            string WekaOption = "-L " + TAGS_LINK_TYPE[cGlobalInfo.OptionsWindow.comboBoxHierarchicalLinkType.SelectedIndex];// + OptionDistance;

            HClusterer.setOptions(weka.core.Utils.splitOptions(WekaOption));
            //EuclideanDistance2 Dist2 = new EuclideanDistance2();

            //HClusterer.setDistanceFunction(Dist2);
            HClusterer.setNumClusters(ClassNumber);
            HClusterer.buildClusterer(Ninsts);

            richTextBoxInfoClustering.AppendText("\n" + CurrentPlateToProcess.GetName() + ": " + HClusterer.numberOfClusters() + " cluster(s)");

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

            CurrentPlateToProcess.AssignClass(eval.getClusterAssignments());
        }
示例#3
0
        /// <summary>
        /// K - Mean clustering procedure
        /// </summary>
        /// <param name="Classes"></param>
        /// <param name="PlateToProcess"></param>
        /// <returns></returns>
        private bool KMeans(int Classes, cPlate PlateToProcess)
        {
            int NumWell = PlateToProcess.GetNumberOfActiveWells();
            int Numdesc = cGlobalInfo.CurrentScreening.GetNumberOfActiveDescriptor();
            double[,] DataForKMeans = new double[NumWell, Numdesc];

            int IdxDesc = 0;
            for (int desc = 0; desc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; desc++)
            {
                if (cGlobalInfo.CurrentScreening.ListDescriptors[desc].IsActive() == false) continue;
                List<double> CurrentDesc = new List<double>();
                double[] NormDesc = null;
                for (int IdxValue = 0; IdxValue < cGlobalInfo.CurrentScreening.Columns; IdxValue++)
                    for (int IdxValue0 = 0; IdxValue0 < cGlobalInfo.CurrentScreening.Rows; IdxValue0++)
                    {
                        cWell TmpWell = PlateToProcess.GetWell(IdxValue, IdxValue0, true);
                        if (TmpWell != null)
                            CurrentDesc.Add(TmpWell.ListSignatures[desc].GetValue());
                    }

                if (CurrentDesc.Count == 0) continue;
                NormDesc = MeanCenteringStdStandarization(CurrentDesc.ToArray());
                for (int row = 0; row < NumWell; row++)
                    DataForKMeans[row, IdxDesc] = NormDesc[row];

                IdxDesc++;
            }
            int Info;
            double[,] CenterPos;
            int[] ClusterIndx;

            try
            {
                alglib.kmeansgenerate(DataForKMeans, NumWell, Numdesc, Classes, 10, out Info, out CenterPos, out ClusterIndx);
                int Idx = 0;
                for (int IdxValue = 0; IdxValue < cGlobalInfo.CurrentScreening.Columns; IdxValue++)
                    for (int IdxValue0 = 0; IdxValue0 < cGlobalInfo.CurrentScreening.Rows; IdxValue0++)
                    {
                        cWell TmpWell = PlateToProcess.GetWell(IdxValue, IdxValue0, true);
                        if (TmpWell != null)
                        {
                            if (ClusterIndx[Idx] == -1)
                                TmpWell.SetAsNoneSelected();
                            else
                                TmpWell.SetClass(ClusterIndx[Idx]);

                            Idx++;
                        }
                    }
            }
            catch
            {
                richTextBoxInfoClustering.AppendText("\nPlate: " + PlateToProcess.GetName() + " skipped: data corrupted (check your descriptor data validity).");

                //MessageBox.Show("Check the data validity", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }
            return true;
        }
示例#4
0
        private void createAveragePlateToolStripMenuItem_Click(object sender, EventArgs e)
        {

            FormForPlateAveraging FFPA = new FormForPlateAveraging();

            PanelForPlatesSelection PlatesSelectionPanel = new PanelForPlatesSelection(true, null, true);
            PlatesSelectionPanel.Height = FFPA.panelForPlateList.Height;

            FFPA.panelForPlateList.Controls.Add(PlatesSelectionPanel);
            if (FFPA.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

            cListPlates LP = PlatesSelectionPanel.GetListSelectedPlates();


            cPlate NewPlate = new cPlate("Average Plate", cGlobalInfo.CurrentScreening);
            cWell TmpWell;

            #region QC report
            cExtendedList TmpReportForQuality = new cExtendedList("Weight");
            TmpReportForQuality.ListTags = new List<object>();
            cExtendedTable TableForQCReport = new cExtendedTable(TmpReportForQuality);
            TableForQCReport.ListRowNames = new List<string>();
            TableForQCReport.ListTags = new List<object>();
            foreach (cPlate TmpPlate in LP)
            {
                object QualityValue = TmpPlate.ListProperties.FindValueByName("Quality");
                if ((QualityValue != null) && (FFPA.checkBoxWeightedSum.Checked))
                    TableForQCReport[0].Add((double)QualityValue);
                else
                {
                    this.richTextBoxConsole.AppendText(TmpPlate.GetName() + " - Quality is NULL. Weight set to 1.\n");
                    TableForQCReport[0].Add(1);
                }

                TableForQCReport.ListRowNames.Add(TmpPlate.GetName());
                TableForQCReport.ListTags.Add(TmpPlate);
                TableForQCReport[0].ListTags.Add(TmpPlate);

            }

            cDisplayExtendedTable DET = new cDisplayExtendedTable();
            DET.SetInputData(TableForQCReport);
            DET.Title = "QC report";
            TableForQCReport.Name = "QC report";
            DET.Run();
            #endregion


            for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                {
                    cListSignature LDesc = new cListSignature();

                    for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++)
                    {
                        double Value = 0;
                        double NormFactor = 0;

                        foreach (cPlate TmpPlate in LP)
                        {
                            double Weight = 1;
                            object QualityValue = TmpPlate.ListProperties.FindValueByName("Quality");
                            if ((QualityValue != null) && (FFPA.checkBoxWeightedSum.Checked))
                                Weight = (double)QualityValue;

                            NormFactor += Weight;
                            TmpWell = TmpPlate.GetWell(X, Y, false);
                            if (TmpWell != null)
                            {
                                Value += Weight * TmpWell.ListSignatures[i].GetValue();
                            }
                        }

                        if (NormFactor > 0)
                        {
                            cSignature Desc = new cSignature(Value / NormFactor, cGlobalInfo.CurrentScreening.ListDescriptors[i], cGlobalInfo.CurrentScreening);
                            LDesc.Add(Desc);
                        }
                    }
                    cWell NewWell = new cWell(LDesc, X + 1, Y + 1, cGlobalInfo.CurrentScreening, NewPlate);
                    NewWell.SetCpdName("Average Well [" + (X + 1) + ":" + (Y + 1) + "]");
                    NewPlate.AddWell(NewWell);

                }

            cGlobalInfo.CurrentScreening.AddPlate(NewPlate);
            cGlobalInfo.CurrentScreening.ListPlatesActive.Add(NewPlate);
            toolStripcomboBoxPlateList.Items.Add(NewPlate.GetName());
            cGlobalInfo.CurrentScreening.ListPlatesActive[cGlobalInfo.CurrentScreening.ListPlatesActive.Count - 1].UpDataMinMax();
            cGlobalInfo.CurrentScreening.CurrentDisplayPlateIdx = 0;
            cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), true);
        }
示例#5
0
        private void hitsDistributionMapToolStripMenuItem_Click(object sender, EventArgs e)
        {

            if (cGlobalInfo.CurrentScreening == null) return;
            List<cPanelForDisplayArray> ListPlates = new List<cPanelForDisplayArray>();

            foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
            {
                ListPlates.Add(new FormToDisplayPlate(CurrentPlate));
            }

            cWindowToDisplayEntireScreening WindowToDisplayArray = new cWindowToDisplayEntireScreening(ListPlates, cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName(), 6);
            WindowToDisplayArray.checkBoxDisplayClasses.Checked = true;
            WindowToDisplayArray.Text = "Generate Hits Distribution Maps";

            WindowToDisplayArray.Show();


            System.Windows.Forms.DialogResult ResWin = MessageBox.Show("By applying this process, the current screening will be entirely updated ! Proceed ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (ResWin == System.Windows.Forms.DialogResult.No)
            {
                WindowToDisplayArray.Close();
                return;
            }

            WindowToDisplayArray.Close();
            if (cGlobalInfo.CurrentScreening != null) cGlobalInfo.CurrentScreening.Close3DView();

            //   CompleteScreening.ListDescriptors.RemoveDesc(CompleteScreening.ListDescriptors[IntToTransfer], CompleteScreening);
            cScreening MergedScreening = new cScreening("Class Screen");
            MergedScreening.PanelForPlate = this.panelForPlate;

            MergedScreening.Rows = cGlobalInfo.CurrentScreening.Rows;
            MergedScreening.Columns = cGlobalInfo.CurrentScreening.Columns;
            MergedScreening.ListPlatesAvailable = new cListPlates();

            // create the descriptor
            MergedScreening.ListDescriptors.Clean();

            List<cDescriptorType> ListDescType = new List<cDescriptorType>();
            List<int[][]> Values = new List<int[][]>();

            for (int i = 0; i < cGlobalInfo.ListWellClasses.Count; i++)
            {
                cDescriptorType DescClass = new cDescriptorType("Class_" + i, true, 1);
                ListDescType.Add(DescClass);
                MergedScreening.ListDescriptors.AddNew(DescClass);

                int[][] TMpVal = new int[MergedScreening.Columns][];
                for (int ii = 0; ii < MergedScreening.Columns; ii++)
                    TMpVal[ii] = new int[MergedScreening.Rows];

                Values.Add(TMpVal);
            }

            MergedScreening.ListDescriptors.CurrentSelectedDescriptorIdx = 0;

            foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
            {
                foreach (cWell TmpWell in CurrentPlate.ListActiveWells)
                {
                    int Class = TmpWell.GetCurrentClassIdx();
                    if (Class >= 0)
                        Values[Class][TmpWell.GetPosX() - 1][TmpWell.GetPosY() - 1]++;
                }
            }

            cPlate NewPlate = new cPlate(cGlobalInfo.CurrentScreening.GetName(), MergedScreening);

            for (int X = 0; X < cGlobalInfo.CurrentScreening.Columns; X++)
                for (int Y = 0; Y < cGlobalInfo.CurrentScreening.Rows; Y++)
                {
                    cListSignature LDesc = new cListSignature();
                    for (int i = 0; i < cGlobalInfo.ListWellClasses.Count; i++)
                    {
                        cSignature Desc = new cSignature(Values[i][X][Y], ListDescType[i], cGlobalInfo.CurrentScreening);
                        LDesc.Add(Desc);

                    }
                    cWell NewWell = new cWell(LDesc, X + 1, Y + 1, MergedScreening, NewPlate);
                   // NewWell.SetCpdName("Well [" + (X + 1) + ":" + (Y + 1) + "]");
                    NewPlate.AddWell(NewWell);

                }

            // check if the plate exist already
            MergedScreening.AddPlate(NewPlate);
            MergedScreening.ListPlatesActive = new cListPlates();

            cGlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.Items.Clear();

            for (int i = 0; i < MergedScreening.ListPlatesAvailable.Count; i++)
            {
                MergedScreening.ListPlatesActive.Add(MergedScreening.ListPlatesAvailable[i]);
                cGlobalInfo.WindowHCSAnalyzer.toolStripcomboBoxPlateList.Items.Add(NewPlate.GetName());
            }

            cGlobalInfo.CurrentScreening.ListDescriptors = MergedScreening.ListDescriptors;
            cGlobalInfo.CurrentScreening.ListPlatesAvailable = MergedScreening.ListPlatesAvailable;
            cGlobalInfo.CurrentScreening.ListPlatesActive = MergedScreening.ListPlatesActive;

            cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate();
            for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++)
                cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax();

            cGlobalInfo.CurrentScreening.CurrentDisplayPlateIdx = 0;
            cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), true);

            ListPlates = new List<cPanelForDisplayArray>();
            for (int DescIdx = 0; DescIdx < cGlobalInfo.CurrentScreening.ListDescriptors.Count; DescIdx++)
            {
                if (cGlobalInfo.CurrentScreening.ListDescriptors[DescIdx].IsActive())
                    ListPlates.Add(new FormToDisplayDescriptorPlate(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate(), cGlobalInfo.CurrentScreening, DescIdx));
            }

            cWindowToDisplayEntireDescriptors WindowToDisplayDesc = new cWindowToDisplayEntireDescriptors(ListPlates, cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().GetName(), cGlobalInfo.ListWellClasses.Count);
            WindowToDisplayDesc.checkBoxGlobalNormalization.Checked = true;

            WindowToDisplayDesc.Show();
        }
示例#6
0
        private Microsoft.Msagl.Drawing.Graph DisplayTheGraph(cPlate PlateForTree)
        {
            FormForClassificationTree WindowForTree = new FormForClassificationTree();

            WindowForTree.Text = PlateForTree.GetName();
            string StringForTree = PlateForTree.GetInfoClassif().StringForTree;
            if ((StringForTree == null) || (StringForTree.Length == 0))
                return null;

            WindowForTree.richTextBoxConsoleForClassification.Clear();
            WindowForTree.richTextBoxConsoleForClassification.AppendText(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().GetInfoClassif().StringForQuality);
            WindowForTree.richTextBoxConsoleForClassification.AppendText(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().GetInfoClassif().ConfusionMatrix);

            return ComputeAndDisplayGraph(StringForTree.Remove(StringForTree.Length - 3, 3), false);
        }
示例#7
0
文件: cWell.cs 项目: cyrenaique/HCSA
        public cWell(cListSignature ListDesc, int Col, int Row, cScreening screenParent, cPlate CurrentPlate)
        {
            // Parent = screenParent;
            this.AssociatedPlate = CurrentPlate;

            this.ListSignatures = new cListSignature();

            this.ListSignatures = ListDesc;

            this.PosX = Col;
            this.PosY = Row;

            //   this.CurrentColor = this.cGlobalInfo.ListClasses[ClassForClassif].ColourForDisplay;

            foreach (var item in this.ListSignatures)
                item.AssociatedWell = this;

            //this.ListClass.Add(this.InitialClass);

            this.ListProperties = new cListWellProperty(this);
            this.ListProperties.UpdateValueByName("Well Class", 2);
            this.ListProperties.UpdateValueByName("Plate Name", CurrentPlate.GetName());
        }
示例#8
0
        public FormToDisplayPlate(cPlate PlateToDisplay)
        {
            //this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            // this.WindowToDisplayEntireScreening = WindowToDisplayEntireScreening;
            this.PlateToDisplay = PlateToDisplay;

              //  this.CompleteScreening = CompleteScreening;
              //  this.CurrentScreening = CompleteScreening;
            this.LUT = cGlobalInfo.CurrentPlateLUT;
            this.AssociatedPlate = PlateToDisplay;
            base.Tag = PlateToDisplay;
            bool ResMiss = false;
            this.MouseDoubleClick += new MouseEventHandler(this.FormToDisplayPlate_MouseDoubleClick);
            this.MouseClick += new MouseEventHandler(this.FormToDisplayPlate_MouseClick);

            ValuesMatrix = PlateToDisplay.GetAverageValueDescTable1(cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx, out ResMiss);
            System.Windows.Forms.ToolTip ToolTip = new System.Windows.Forms.ToolTip();
            ToolTip.SetToolTip(this, PlateToDisplay.GetName() /*+ ". Replicate " + PlateToDisplay.AssociatedReplicateType.Name*/);
            ToolTip.Tag = PlateToDisplay;

            for (int j = 0; j < ValuesMatrix.Length; j++)
                for (int i = 0; i < ValuesMatrix[0].Length; i++)
                {
                    if (double.IsNaN(ValuesMatrix[j][i])) continue;

                    if (ValuesMatrix[j][i] > Max)
                        Max = ValuesMatrix[j][i];
                    if (ValuesMatrix[j][i] < Min)
                        Min = ValuesMatrix[j][i];
                }

            this.SetNewCellSize(5);
            //DisplayMatrix();

            // this.Update();
        }