Exemplo n.º 1
0
        private void extractPhenotypesOfInterestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CompleteScreening == null) return;

            FormClassification WindowClassification = new FormClassification(CompleteScreening);
            WindowClassification.label1.Text = "Class";
            WindowClassification.Text = "Phenotypes of Interest";
            WindowClassification.buttonClassification.Text = "Display";

            if (WindowClassification.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
            int SelectedClass = WindowClassification.comboBoxForNeutralClass.SelectedIndex;

            List<string> ListDescName = new List<string>();
            ListDescName.Add("Idx");
            ListDescName.Add("Plate");
            ListDescName.Add("Pos X");
            ListDescName.Add("Pos Y");

            ListDescName.AddRange(CompleteScreening.ListDescriptors.GetListNameActives());

            List<string[]> ListValues = new List<string[]>();
            int Idx = 0;

            foreach (cPlate TmpPlate in CompleteScreening.ListPlatesActive)
            {
                foreach (cWell TmpWell in TmpPlate.ListActiveWells)
                {
                    if (TmpWell.GetClass() == SelectedClass)
                    {
                        List<string> LValues = new List<string>();
                        LValues.Add(Idx.ToString());
                        LValues.Add(TmpPlate.Name);
                        LValues.Add(TmpWell.GetPosX().ToString());
                        LValues.Add(TmpWell.GetPosY().ToString());

                        for (int IdxDesc = 0; IdxDesc < CompleteScreening.ListDescriptors.Count; IdxDesc++)
                        {
                            if (CompleteScreening.ListDescriptors[IdxDesc].IsActive())
                            {
                                double Value = TmpWell.GetAverageValuesList(false)[IdxDesc];
                                LValues.Add(Value.ToString());

                            }

                        }

                        ListValues.Add(LValues.ToArray());

                        Idx++;
                    }
                }

            }
            cDisplayTable WindowDisplayTable = new cDisplayTable("Phenotypes of Interest. Class " + SelectedClass, ListDescName.ToArray(), ListValues, GlobalInfo, false);
            WindowDisplayTable.Show();
        }
Exemplo n.º 2
0
        private void ComputeAndDisplayPCA(cExtendPlateList PlatesToProcess)
        {
            if (CompleteScreening == null) return;
            FormClassification WindowClassification = new FormClassification(CompleteScreening);
            WindowClassification.label1.Text = "Class of interest";
            WindowClassification.Text = "PCA";
            WindowClassification.buttonClassification.Text = "Process";

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

            int NeutralClass = WindowClassification.comboBoxForNeutralClass.SelectedIndex;

            int NumWell = 0;
            int NumWellForLearning = 0;
            foreach (cPlate CurrentPlate in PlatesToProcess)
            {
                foreach (cWell CurrentWell in CurrentPlate.ListActiveWells)
                {
                    if (CurrentWell.GetClass() == NeutralClass)
                        NumWellForLearning++;
                }
                NumWell += CurrentPlate.GetNumberOfActiveWells();
            }

            if (NumWellForLearning == 0)
            {
                MessageBox.Show("No well of the selected class identified", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int NumDesc = CompleteScreening.GetNumberOfActiveDescriptor();

            if (NumDesc <= 1)
            {
                MessageBox.Show("More than one descriptor are required for this operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            double[,] DataForPCA = new double[NumWellForLearning, CompleteScreening.GetNumberOfActiveDescriptor() + 1];

            //   return;
            Matrix EigenVectors = PCAComputation(DataForPCA, NumWellForLearning, NumWell, NumDesc, NeutralClass, PlatesToProcess);
            if (EigenVectors == null) return;

            SimpleForm NewWindow = new SimpleForm(CompleteScreening);
            Series CurrentSeries = new Series();
            CurrentSeries.ShadowOffset = 1;

            Matrix CurrentPt = new Matrix(NumWell, NumDesc);
            DataForPCA = new double[NumWell, NumDesc + 1];

            for (int desc = 0; desc < NumDesc; desc++)
            {
                if (CompleteScreening.ListDescriptors[desc].IsActive() == false) continue;
                List<double> CurrentDesc = new List<double>();
                foreach (cPlate CurrentPlate in PlatesToProcess)
                {
                    for (int IdxValue = 0; IdxValue < CompleteScreening.Columns; IdxValue++)
                        for (int IdxValue0 = 0; IdxValue0 < CompleteScreening.Rows; IdxValue0++)
                        {
                            cWell TmpWell = CurrentPlate.GetWell(IdxValue, IdxValue0, true);
                            if (TmpWell == null) continue;
                            CurrentDesc.Add(TmpWell.ListDescriptors[desc].GetValue());
                        }
                }
                for (int i = 0; i < NumWell; i++)
                    DataForPCA[i, desc] = CurrentDesc[i];
            }

            int IDx = 0;
            foreach (cPlate CurrentPlate in PlatesToProcess)
            {
                for (int IdxValue = 0; IdxValue < CompleteScreening.Columns; IdxValue++)
                    for (int IdxValue0 = 0; IdxValue0 < CompleteScreening.Rows; IdxValue0++)
                    {
                        cWell TmpWell = CurrentPlate.GetWell(IdxValue, IdxValue0, true);
                        if (TmpWell == null) continue;
                        DataForPCA[IDx++, NumDesc] = TmpWell.GetClass();
                    }
            }

            for (int i = 0; i < NumWell; i++)
                for (int j = 0; j < NumDesc; j++) CurrentPt.addElement(i, j, DataForPCA[i, j]);

            Matrix NewPt = new Matrix(NumWell, NumDesc);

            NewPt = CurrentPt.multiply(EigenVectors);

            double MinY = double.MaxValue, MaxY = double.MinValue;

            for (int IdxValue0 = 0; IdxValue0 < NumWell; IdxValue0++)
            {
                double CurrentY = NewPt.getElement(IdxValue0, 1);

                if (CurrentY < MinY) MinY = CurrentY;
                if (CurrentY > MaxY) MaxY = CurrentY;

                CurrentSeries.Points.AddXY(NewPt.getElement(IdxValue0, 0), CurrentY);

                CurrentSeries.Points[IdxValue0].Color = CompleteScreening.GlobalInfo.GetColor((int)DataForPCA[IdxValue0, NumDesc]);
                CurrentSeries.Points[IdxValue0].MarkerStyle = MarkerStyle.Circle;
                CurrentSeries.Points[IdxValue0].MarkerSize = 8;
            }

            ChartArea CurrentChartArea = new ChartArea();
            CurrentChartArea.BorderColor = Color.Black;

            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            NewWindow.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            CurrentChartArea.BackColor = Color.FromArgb(164, 164, 164);

            string AxeName = "";
            int IDxDesc = 0;
            for (int Desc = 0; Desc < CompleteScreening.ListDescriptors.Count; Desc++)
            {
                if (CompleteScreening.ListDescriptors[Desc].IsActive() == false) continue;
                AxeName += String.Format("{0:0.###}", EigenVectors.getElement(IDxDesc++, 0)) + "x" + CompleteScreening.ListDescriptors[Desc].GetName() + " + ";
                //   AxeName += String.Format("{0:0.##}", EigenVectors.getElement(CompleteScreening.ListDescriptors.Count - 1, 0)) + "x" + CompleteScreening.ListDescriptorName[CompleteScreening.ListDescriptors.Count - 1];
            }
            CurrentChartArea.Axes[0].Title = AxeName.Remove(AxeName.Length - 3);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = true;

            AxeName = "";
            IDxDesc = 0;
            for (int Desc = 0; Desc < CompleteScreening.ListDescriptors.Count; Desc++)
            {
                if (CompleteScreening.ListDescriptors[Desc].IsActive() == false) continue;
                AxeName += String.Format("{0:0.###}", EigenVectors.getElement(IDxDesc++, 1)) + "x" + CompleteScreening.ListDescriptors[Desc].GetName() + " + ";
            }
            //AxeName += String.Format("{0:0.##}", EigenVectors.getElement(CompleteScreening.ListDescriptors.Count - 1, 0)) + "x" + CompleteScreening.ListDescriptorName[CompleteScreening.ListDescriptors.Count - 1];

            CurrentChartArea.Axes[1].Title = AxeName.Remove(AxeName.Length - 3);
            CurrentChartArea.Axes[1].MajorGrid.Enabled = true;
            CurrentChartArea.Axes[1].Minimum = MinY;
            CurrentChartArea.Axes[1].Maximum = MaxY;
            CurrentChartArea.AxisX.LabelStyle.Format = "N2";
            CurrentChartArea.AxisY.LabelStyle.Format = "N2";

            CurrentSeries.ChartType = SeriesChartType.Point;
            if (GlobalInfo.OptionsWindow.checkBoxDisplayFastPerformance.Checked) CurrentSeries.ChartType = SeriesChartType.FastPoint;
            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);

            NewWindow.Text = "PCA";
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
        }
Exemplo n.º 3
0
        /// <summary>
        /// This function displays the evolution of the average value of a certain descriptor through the plates, for a specified class
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void descriptorEvolutionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CompleteScreening == null) return;

            FormClassification WindowClassification = new FormClassification(CompleteScreening);
            WindowClassification.label1.Text = "Class";
            WindowClassification.Text = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName() + " evolution";
            WindowClassification.buttonClassification.Text = "Display";

            if (WindowClassification.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
            int SelectedClass = WindowClassification.comboBoxForNeutralClass.SelectedIndex;
            cExtendedList ListValuePerWell = new cExtendedList();
            List<cDescriptor> List_Averages = new List<cDescriptor>();

            cWell TempWell;
            int Desc = this.comboBoxDescriptorToDisplay.SelectedIndex;

            int NumberOfPlates = CompleteScreening.ListPlatesActive.Count;
            Series CurrentSeries = new Series();
            CurrentSeries.Name = "Series1";

            CurrentSeries.ChartType = SeriesChartType.ErrorBar;
            CurrentSeries.ShadowOffset = 1;

            Series SeriesLine = new Series();
            SeriesLine.Name = "SeriesLine";
            SeriesLine.ShadowOffset = 1;
            SeriesLine.ChartType = SeriesChartType.Line;

            int RealPlateIdx = 0;

            // loop on all the plates
            for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = CompleteScreening.ListPlatesActive.GetPlate(CompleteScreening.ListPlatesActive[PlateIdx].Name);
                ListValuePerWell.Clear();

                for (int row = 0; row < CompleteScreening.Rows; row++)
                    for (int col = 0; col < CompleteScreening.Columns; col++)
                    {
                        TempWell = CurrentPlateToProcess.GetWell(col, row, true);
                        if (TempWell == null) continue;
                        else
                        {
                            if (TempWell.GetClass() == SelectedClass)
                            {
                                double Val = TempWell.ListDescriptors[Desc].GetValue();
                                if (double.IsNaN(Val)) continue;

                                ListValuePerWell.Add(Val);
                            }
                        }
                    }

                if (ListValuePerWell.Count >= 1)
                {
                    DataPoint CurrentPt = new DataPoint();
                    CurrentPt.XValue = RealPlateIdx;

                    double[] Values = new double[3];
                    Values[0] = ListValuePerWell.Mean();
                    double Std = ListValuePerWell.Std();
                    if (double.IsInfinity(Std) || (double.IsNaN(Std))) Std = 0;
                    Values[1] = Values[0] - Std;
                    Values[2] = Values[0] + Std;
                    CurrentPt.YValues = Values;//ListValuePerWell.ToArray();
                    CurrentSeries.Points.Add(CurrentPt);

                    CurrentSeries.Points[RealPlateIdx].AxisLabel = CurrentPlateToProcess.Name;
                    CurrentSeries.Points[RealPlateIdx].Font = new Font("Arial", 8);
                    CurrentSeries.Points[RealPlateIdx].Color = CompleteScreening.GlobalInfo.GetColor(SelectedClass);

                    SeriesLine.Points.AddXY(RealPlateIdx, Values[0]);

                    SeriesLine.Points[RealPlateIdx].ToolTip = "Plate name: " + CurrentPlateToProcess.Name + "\nAverage: " + string.Format("{0:0.###}", Values[0]) + "\nStdev: " + string.Format("{0:0.###}", Std);
                    SeriesLine.Points[RealPlateIdx].Font = new Font("Arial", 8);
                    SeriesLine.Points[RealPlateIdx].BorderColor = Color.Black;
                    SeriesLine.Points[RealPlateIdx].MarkerStyle = MarkerStyle.Circle;
                    SeriesLine.Points[RealPlateIdx].MarkerSize = 8;

                    RealPlateIdx++;
                }
            }

            SimpleForm NewWindow = new SimpleForm(CompleteScreening);
            int thisWidth = 200 * SeriesLine.Points.Count;
            if (thisWidth > 1500) thisWidth = 1500;
            NewWindow.Width = thisWidth;
            NewWindow.Height = 400;

            ChartArea CurrentChartArea = new ChartArea();
            CurrentChartArea.BorderColor = Color.Black;
            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);

            CurrentChartArea.AxisX.Interval = 1;
            CurrentChartArea.Axes[1].IsMarksNextToAxis = true;
            CurrentChartArea.Axes[1].Title = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName();
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[1].MajorGrid.Enabled = false;

            NewWindow.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            CurrentChartArea.BackGradientStyle = GradientStyle.TopBottom;
            CurrentChartArea.BackColor = CompleteScreening.GlobalInfo.OptionsWindow.panel1.BackColor;
            CurrentChartArea.BackSecondaryColor = Color.White;

            CurrentSeries["BoxPlotWhiskerPercentile"] = "false";
            CurrentSeries["BoxPlotShowMedian"] = "false";
            CurrentSeries["BoxPlotWhiskerPercentile"] = "false";
            CurrentSeries["BoxPlotShowAverage"] = "false";
            CurrentSeries["BoxPlotPercentile"] = "false";

            CurrentChartArea.AxisX.IsLabelAutoFit = true;
            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);
            NewWindow.chartForSimpleForm.Series.Add(SeriesLine);

            Title CurrentTitle = new Title("Class " + SelectedClass + " " + CurrentChartArea.Axes[1].Title + " evolution");

            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);
            NewWindow.chartForSimpleForm.Titles[0].Font = new Font("Arial", 9);
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
            return;
        }
Exemplo n.º 4
0
        private void coeffOfVariationEvolutionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CompleteScreening == null) return;

            FormClassification WinForClass = new FormClassification(CompleteScreening);
            WinForClass.buttonClassification.Text = "Display";
            WinForClass.Text = "Select the class of interest";
            WinForClass.label1.Text = "Class";

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

            BuildCV(this.comboBoxDescriptorToDisplay.SelectedIndex, WinForClass.comboBoxForNeutralClass.SelectedIndex).Show();
        }