コード例 #1
0
ファイル: CDisplayGraph.cs プロジェクト: cyrenaique/HCS
        public CDisplayGraph(double[] Values)
        {
            SimpleForm NewWindow = new SimpleForm();
            Series SeriesPos = new Series();
            SeriesPos.ShadowOffset = 1;

            for (int IdxValue = 0; IdxValue < Values.Length; IdxValue++)
            {
                SeriesPos.Points.AddY(Values[IdxValue]);
                SeriesPos.Points[IdxValue].Color = Color.Black;
            }

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

            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.AxisX.LabelStyle.Format = "N2";

            NewWindow.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            CurrentChartArea.BackGradientStyle = GradientStyle.TopBottom;
            CurrentChartArea.BackSecondaryColor = Color.White;

            SeriesPos.ChartType = SeriesChartType.Column;
            NewWindow.chartForSimpleForm.Series.Add(SeriesPos);

            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

              //  if (GlobalInfo.OptionsWindow.checkBoxDisplayHistoStats.Checked)
            {
                //StripLine AverageLine = new StripLine();
                //AverageLine.BackColor = Color.Black;
                //AverageLine.IntervalOffset = Pos.Mean();
                //AverageLine.StripWidth = double.Epsilon;
                //CurrentChartArea.AxisX.StripLines.Add(AverageLine);
                //AverageLine.Text = String.Format("{0:0.###}", AverageLine.IntervalOffset);

                //StripLine StdLine = new StripLine();
                //StdLine.BackColor = Color.FromArgb(64, Color.Black);
                //double Std = Pos.Std();
                //StdLine.IntervalOffset = AverageLine.IntervalOffset - 0.5 * Std;
                //StdLine.StripWidth = Std;
                //CurrentChartArea.AxisX.StripLines.Add(StdLine);
                //AverageLine.StripWidth = 0.0001;
            }

            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
            NewWindow.Show();
        }
コード例 #2
0
ファイル: cWell.cs プロジェクト: cyrenaique/HCS
        private void DisplayHisto(object sender, EventArgs e)
        {
            if ((Parent.ListDescriptors == null) || (Parent.ListDescriptors.Count == 0)) return;

            cExtendedList Pos = new cExtendedList();

            cWell TempWell;

            int NumberOfPlates = Parent.GlobalInfo.PlateListWindow.listBoxPlateNameToProcess.Items.Count;

            // loop on all the plate
            for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = Parent.ListPlatesActive.GetPlate((string)Parent.GlobalInfo.PlateListWindow.listBoxPlateNameToProcess.Items[PlateIdx]);

                for (int row = 0; row < Parent.Rows; row++)
                    for (int col = 0; col < Parent.Columns; col++)
                    {
                        TempWell = CurrentPlateToProcess.GetWell(col, row, false);
                        if (TempWell == null) continue;
                        else
                        {
                            if (TempWell.GetClass() == this.ClassForClassif)
                                Pos.Add(TempWell.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetValue());
                        }
                    }
            }

            if (Pos.Count == 0)
            {
                MessageBox.Show("No well of class " + Parent.SelectedClass + " selected !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List<double[]> HistoPos = Pos.CreateHistogram((int)Parent.GlobalInfo.OptionsWindow.numericUpDownHistoBin.Value);
            if (HistoPos == null) return;
            SimpleForm NewWindow = new SimpleForm();

            Series SeriesPos = new Series();
            SeriesPos.ShadowOffset = 1;

            if (HistoPos.Count == 0) return;

            for (int IdxValue = 0; IdxValue < HistoPos[0].Length; IdxValue++)
            {
                SeriesPos.Points.AddXY(HistoPos[0][IdxValue], HistoPos[1][IdxValue]);
                SeriesPos.Points[IdxValue].ToolTip = HistoPos[1][IdxValue].ToString();

                if (this.ClassForClassif == -1)
                    SeriesPos.Points[IdxValue].Color = Color.Black;
                else
                    SeriesPos.Points[IdxValue].Color = Parent.GlobalInfo.GetColor(this.ClassForClassif);
            }

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

            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[0].Title = Parent.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetName();
            CurrentChartArea.Axes[1].Title = "Sum";
            CurrentChartArea.AxisX.LabelStyle.Format = "N2";

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

            SeriesPos.ChartType = SeriesChartType.Column;
            // SeriesPos.Color = Parent.GetColor(1);
            NewWindow.chartForSimpleForm.Series.Add(SeriesPos);

            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

            StripLine AverageLine = new StripLine();
            AverageLine.BackColor = Color.Red;
            AverageLine.IntervalOffset = this.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetValue();
            AverageLine.StripWidth = 0.0001;
            AverageLine.Text = String.Format("{0:0.###}", this.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetValue());
            CurrentChartArea.AxisX.StripLines.Add(AverageLine);

            if (Parent.GlobalInfo.OptionsWindow.checkBoxDisplayHistoStats.Checked)
            {
                StripLine NAverageLine = new StripLine();
                NAverageLine.BackColor = Color.Black;
                NAverageLine.IntervalOffset = Pos.Mean();
                NAverageLine.StripWidth = 0.0001;// double.Epsilon;
                CurrentChartArea.AxisX.StripLines.Add(NAverageLine);
                NAverageLine.Text = String.Format("{0:0.###}", NAverageLine.IntervalOffset);

                StripLine StdLine = new StripLine();
                StdLine.BackColor = Color.FromArgb(64, Color.Black);
                double Std = Pos.Std();
                StdLine.IntervalOffset = NAverageLine.IntervalOffset - 0.5 * Std;
                StdLine.StripWidth = Std;
                CurrentChartArea.AxisX.StripLines.Add(StdLine);
                //NAverageLine.StripWidth = 0.01;
            }

            Title CurrentTitle = new Title(this.StateForClassif + " - " + Parent.ListDescriptors[Parent.ListDescriptors.CurrentSelectedDescriptor].GetName() + " histogram.");
            CurrentTitle.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold);
            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);

            NewWindow.Text = CurrentTitle.Text;
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });

            return;
        }
コード例 #3
0
        private SimpleForm BuildSSMD(int Desc)
        {
            List<double> Pos = new List<double>();
            List<double> Neg = new List<double>();
            List<cSimpleSignature> ZFactorList = new List<cSimpleSignature>();

            cWell TempWell;
            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);

                Pos.Clear();
                Neg.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() == 0)
                                Pos.Add(TempWell.ListDescriptors[Desc].GetValue());
                            if (TempWell.GetClass() == 1)
                                Neg.Add(TempWell.ListDescriptors[Desc].GetValue());
                        }
                    }

                double SSMDScore = (Mean(Pos.ToArray()) - Mean(Neg.ToArray())) / Math.Sqrt(std(Pos.ToArray()) * std(Pos.ToArray()) + std(Neg.ToArray()) * std(Neg.ToArray()));
                GlobalInfo.ConsoleWriteLine(CurrentPlateToProcess.Name + ", SSMD = " + SSMDScore);

                //cDescriptor TmpDesc = new cDescriptor(SSMDScore, CurrentPlateToProcess.Name);
                cSimpleSignature TmpDesc = new cSimpleSignature(CurrentPlateToProcess.Name, SSMDScore);
                ZFactorList.Add(TmpDesc);
            }

            Series CurrentSeries = new Series();
            CurrentSeries.ChartType = SeriesChartType.Column;
            CurrentSeries.ShadowOffset = 1;

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

            int RealIdx = 0;
            for (int IdxValue = 0; IdxValue < ZFactorList.Count; IdxValue++)
            {
                if (ZFactorList[IdxValue].AverageValue.ToString() == "NaN") continue;

                CurrentSeries.Points.Add(ZFactorList[IdxValue].AverageValue);
                CurrentSeries.Points[RealIdx].Label = string.Format("{0:0.###}", ZFactorList[IdxValue].AverageValue);
                CurrentSeries.Points[RealIdx].Font = new Font("Arial", 10);
                CurrentSeries.Points[RealIdx].ToolTip = ZFactorList[IdxValue].Name;
                CurrentSeries.Points[RealIdx].AxisLabel = ZFactorList[IdxValue].Name;

                SeriesLine.Points.Add(ZFactorList[IdxValue].AverageValue);
                SeriesLine.Points[RealIdx].BorderColor = Color.Black;
                SeriesLine.Points[RealIdx].MarkerStyle = MarkerStyle.Circle;
                SeriesLine.Points[RealIdx].MarkerSize = 4;
                RealIdx++;
            }

            SimpleForm NewWindow = new SimpleForm();
            int thisWidth = 200 * RealIdx;
            if (thisWidth > (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value)
                thisWidth = (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value;
            NewWindow.Width = thisWidth;
            NewWindow.Height = 400;
            NewWindow.Text = "SSMD";

            ChartArea CurrentChartArea = new ChartArea();
            CurrentChartArea.BorderColor = Color.Black;
            CurrentChartArea.AxisX.Interval = 1;
            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);
            NewWindow.chartForSimpleForm.Series.Add(SeriesLine);

            CurrentChartArea.AxisX.IsLabelAutoFit = true;
            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);

            // CurrentChartArea.Axes[1].Maximum = 2;
            CurrentChartArea.Axes[1].IsMarksNextToAxis = true;
            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;

            Title CurrentTitle = new Title(CompleteScreening.ListDescriptors[Desc].GetName() + " SSMD");
            CurrentTitle.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold);
            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);

            return NewWindow;
        }
コード例 #4
0
        private void zscoreSinglePlateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List<double> Pos = new List<double>();
            List<double> Neg = new List<double>();
            List<cSimpleSignature> ZFactorList = new List<cSimpleSignature>();

            int NumDesc = CompleteScreening.ListDescriptors.Count;

            cWell TempWell;
            // loop on all the desciptors
            for (int Desc = 0; Desc < NumDesc; Desc++)
            {
                Pos.Clear();
                Neg.Clear();

                if (CompleteScreening.ListDescriptors[Desc].IsActive() == false) continue;

                for (int row = 0; row < CompleteScreening.Rows; row++)
                    for (int col = 0; col < CompleteScreening.Columns; col++)
                    {
                        TempWell = CompleteScreening.GetCurrentDisplayPlate().GetWell(col, row, true);
                        if (TempWell == null) continue;
                        else
                        {
                            if (TempWell.GetClass() == 0)
                                Pos.Add(TempWell.ListDescriptors[Desc].GetValue());
                            if (TempWell.GetClass() == 1)
                                Neg.Add(TempWell.ListDescriptors[Desc].GetValue());
                        }
                    }
                if (Pos.Count < 3)
                {
                    MessageBox.Show("No or not enough positive controls !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (Neg.Count < 3)
                {
                    MessageBox.Show("No or not enough negative controls !", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                double ZScore = 1 - 3 * (std(Pos.ToArray()) + std(Neg.ToArray())) / (Math.Abs(Mean(Pos.ToArray()) - Mean(Neg.ToArray())));
                GlobalInfo.ConsoleWriteLine(CompleteScreening.ListDescriptors[Desc].GetName() + ", Z-Score = " + ZScore);
                cSimpleSignature TmpDesc = new cSimpleSignature(CompleteScreening.ListDescriptors[Desc].GetName(), ZScore);
                ZFactorList.Add(TmpDesc);
            }

            ZFactorList.Sort(delegate(cSimpleSignature p1, cSimpleSignature p2) { return p1.AverageValue.CompareTo(p2.AverageValue); });

            Series CurrentSeries = new Series();
            CurrentSeries.ChartType = SeriesChartType.Column;
            CurrentSeries.ShadowOffset = 1;

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

            int RealIdx = 0;
            for (int IdxValue = 0; IdxValue < ZFactorList.Count; IdxValue++)
            {
                if (double.IsNaN(ZFactorList[IdxValue].AverageValue)) continue;
                if (double.IsInfinity(ZFactorList[IdxValue].AverageValue)) continue;

                CurrentSeries.Points.Add(ZFactorList[IdxValue].AverageValue);
                CurrentSeries.Points[RealIdx].Label = string.Format("{0:0.###}", ZFactorList[IdxValue].AverageValue);
                CurrentSeries.Points[RealIdx].Font = new Font("Arial", 10);
                CurrentSeries.Points[RealIdx].ToolTip = ZFactorList[IdxValue].Name;
                CurrentSeries.Points[RealIdx].AxisLabel = ZFactorList[IdxValue].Name;

                SeriesLine.Points.Add(ZFactorList[IdxValue].AverageValue);
                SeriesLine.Points[RealIdx].BorderColor = Color.Black;
                SeriesLine.Points[RealIdx].MarkerStyle = MarkerStyle.Circle;
                SeriesLine.Points[RealIdx].MarkerSize = 4;
                RealIdx++;
            }

            SimpleForm NewWindow = new SimpleForm(CompleteScreening);
            int thisWidth = 200 * RealIdx;
            if (thisWidth > (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value) thisWidth = (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value;
            NewWindow.Width = thisWidth;
            NewWindow.Height = 400;
            NewWindow.Text = "Z-factors";

            ChartArea CurrentChartArea = new ChartArea();
            CurrentChartArea.BorderColor = Color.Black;
            CurrentChartArea.AxisX.Interval = 1;
            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);
            NewWindow.chartForSimpleForm.Series.Add(SeriesLine);

            CurrentChartArea.AxisX.IsLabelAutoFit = true;
            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);

            CurrentChartArea.Axes[1].Maximum = 2;
            CurrentChartArea.Axes[1].IsMarksNextToAxis = true;
            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;

            Title CurrentTitle = new Title(CompleteScreening.GetCurrentDisplayPlate().Name + " Z-factors");
            CurrentTitle.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold);
            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);

            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
        }
コード例 #5
0
        private void stackedHistogramToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CompleteScreening == null) return;
            if ((CompleteScreening.ListDescriptors == null) || (CompleteScreening.ListDescriptors.Count == 0)) return;

            cExtendedList[] ListValuesForHisto = new cExtendedList[GlobalInfo.GetNumberofDefinedClass()];
            for (int i = 0; i < ListValuesForHisto.Length; i++)
                ListValuesForHisto[i] = new cExtendedList();

            cWell TempWell;

            int NumberOfPlates = CompleteScreening.ListPlatesActive.Count;

            double MinValue = double.MaxValue;
            double MaxValue = double.MinValue;
            double CurrentValue;

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

                for (int row = 0; row < CompleteScreening.Rows; row++)
                    for (int col = 0; col < CompleteScreening.Columns; col++)
                    {
                        TempWell = CurrentPlateToProcess.GetWell(col, row, false);
                        if (TempWell == null) continue;
                        else
                        {
                            if (TempWell.GetClass() >= 0)
                            {
                                CurrentValue = TempWell.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetValue();
                                ListValuesForHisto[TempWell.GetClass()].Add(CurrentValue);
                                if (CurrentValue < MinValue) MinValue = CurrentValue;
                                if (CurrentValue > MaxValue) MaxValue = CurrentValue;
                            }
                        }
                    }
            }
            SimpleForm NewWindow = new SimpleForm();
            List<double[]>[] HistoPos = new List<double[]>[ListValuesForHisto.Length];
            Series[] SeriesPos = new Series[GlobalInfo.GetNumberofDefinedClass()];

            for (int i = 0; i < ListValuesForHisto.Length; i++)
            {
                HistoPos[i] = new List<double[]>();
                HistoPos[i] = ListValuesForHisto[i].CreateHistogram(MinValue, MaxValue, (int)GlobalInfo.OptionsWindow.numericUpDownHistoBin.Value);

                SeriesPos[i] = new Series();
            }

            for (int i = 0; i < SeriesPos.Length; i++)
            {
                int Max = 0;
                if (HistoPos[i].Count > 0)
                    Max = HistoPos[i][0].Length;

                for (int IdxValue = 0; IdxValue < Max; IdxValue++)
                {
                    SeriesPos[i].Points.AddXY(MinValue + ((MaxValue - MinValue) * IdxValue) / Max, HistoPos[i][1][IdxValue]);
                    SeriesPos[i].Points[IdxValue].ToolTip = HistoPos[i][1][IdxValue].ToString();
                    if (CompleteScreening.SelectedClass == -1)
                        SeriesPos[i].Points[IdxValue].Color = Color.Black;
                    else
                        SeriesPos[i].Points[IdxValue].Color = CompleteScreening.GlobalInfo.GetColor(i);

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

            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[0].Title = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName();
            CurrentChartArea.Axes[1].Title = "Sum";
            CurrentChartArea.AxisX.LabelStyle.Format = "N2";

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

            for (int i = 0; i < SeriesPos.Length; i++)
            {
                SeriesPos[i].ChartType = SeriesChartType.StackedColumn;
                // SeriesPos[i].Color = CompleteScreening.GlobalInfo.GetColor(1);
                NewWindow.chartForSimpleForm.Series.Add(SeriesPos[i]);
            }
            //Series SeriesGaussNeg = new Series();
            //SeriesGaussNeg.ChartType = SeriesChartType.Spline;

            //Series SeriesGaussPos = new Series();
            //SeriesGaussPos.ChartType = SeriesChartType.Spline;

            //if (HistoPos.Count != 0)
            //{
            //    double[] HistoGaussPos = CreateGauss(Mean(Pos.ToArray()), std(Pos.ToArray()), HistoPos[0].Length);

            //    SeriesGaussPos.Color = Color.Black;
            //    SeriesGaussPos.BorderWidth = 2;
            //}
            //SeriesGaussNeg.Color = Color.Black;
            //SeriesGaussNeg.BorderWidth = 2;

            //NewWindow.chartForSimpleForm.Series.Add(SeriesGaussNeg);
            //NewWindow.chartForSimpleForm.Series.Add(SeriesGaussPos);
            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

            Title CurrentTitle = null;

            CurrentTitle = new Title(CompleteScreening.GetCurrentDisplayPlate().Name + " - " + CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName() + " Stacked histogram.");

            CurrentTitle.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold);
            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);
            NewWindow.Text = CurrentTitle.Text;
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
            return;
        }
コード例 #6
0
        private void scatterPointsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CompleteScreening == null) return;
            Series CurrentSeries = new Series("ScatterPoints");
            CurrentSeries.ShadowOffset = 1;

            int Idx = 0;
            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);

                for (int IdxValue = 0; IdxValue < CompleteScreening.Columns; IdxValue++)
                    for (int IdxValue0 = 0; IdxValue0 < CompleteScreening.Rows; IdxValue0++)
                    {
                        cWell TmpWell = CurrentPlateToProcess.GetWell(IdxValue, IdxValue0, true);
                        if (TmpWell == null) continue;
                        CurrentSeries.Points.Add(TmpWell.ListDescriptors[comboBoxDescriptorToDisplay.SelectedIndex].GetValue());
                        CurrentSeries.Points[Idx].Color = TmpWell.GetColor();
                        CurrentSeries.Points[Idx].MarkerStyle = MarkerStyle.Circle;
                        CurrentSeries.Points[Idx].MarkerSize = 6;
                        if (!GlobalInfo.OptionsWindow.checkBoxDisplayFastPerformance.Checked) CurrentSeries.Points[Idx].ToolTip = TmpWell.AssociatedPlate.Name + "\n" + TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name;
                        Idx++;
                    }
            }

            SimpleForm NewWindow = new SimpleForm(CompleteScreening);

            if (Idx > (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value)
                NewWindow.Width = (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value;
            else
                NewWindow.Width = Idx;
            NewWindow.Height = 400;

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

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

            CurrentChartArea.Axes[1].Title = CompleteScreening.ListDescriptors[comboBoxDescriptorToDisplay.SelectedIndex].GetName();
            CurrentChartArea.Axes[0].Title = "Index";

            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;

            CurrentSeries.ChartType = SeriesChartType.Point;
            if (GlobalInfo.OptionsWindow.checkBoxDisplayFastPerformance.Checked) CurrentSeries.ChartType = SeriesChartType.FastPoint;

            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);

            double Av = NewWindow.chartForSimpleForm.DataManipulator.Statistics.Mean("ScatterPoints");
            double Std = Math.Sqrt(NewWindow.chartForSimpleForm.DataManipulator.Statistics.Variance("ScatterPoints", true));

            StripLine StdLine = new StripLine();
            StdLine.BackColor = Color.FromArgb(64, Color.BlanchedAlmond);
            StdLine.IntervalOffset = Av - 1.5 * Std;
            StdLine.StripWidth = 3 * Std;

            CurrentChartArea.AxisY.StripLines.Add(StdLine);

            StripLine AverageLine = new StripLine();
            AverageLine.BackColor = Color.Red;
            AverageLine.IntervalOffset = Av;
            AverageLine.StripWidth = 0.0001;
            AverageLine.Text = String.Format("{0:0.###}", Av);
            CurrentChartArea.AxisY.StripLines.Add(AverageLine);

            NewWindow.Text = "Scatter Point / " + Idx + " points";
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
            return;
        }
コード例 #7
0
        private void scatterPointsToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (CompleteScreening == null) return;
            SimpleForm NewWindow = new SimpleForm(CompleteScreening);
            Series CurrentSeries = new Series("ScatterPoints");

            CurrentSeries.ShadowOffset = 1;

            int Idx = 0;
            for (int IdxValue = 0; IdxValue < CompleteScreening.Columns; IdxValue++)
                for (int IdxValue0 = 0; IdxValue0 < CompleteScreening.Rows; IdxValue0++)
                {
                    cWell TmpWell = CompleteScreening.GetCurrentDisplayPlate().GetWell(IdxValue, IdxValue0, true);
                    if (TmpWell != null)
                    {
                        CurrentSeries.Points.Add(TmpWell.ListDescriptors[comboBoxDescriptorToDisplay.SelectedIndex].GetValue());
                        CurrentSeries.Points[Idx].Color = CompleteScreening.GetCurrentDisplayPlate().GetWell(IdxValue, IdxValue0, true).GetColor();
                        CurrentSeries.Points[Idx].ToolTip = TmpWell.GetPosX() + "x" + TmpWell.GetPosY() + " :" + TmpWell.Name;
                        CurrentSeries.Points[Idx].Tag = TmpWell;
                        CurrentSeries.Points[Idx].MarkerStyle = MarkerStyle.Circle;
                        CurrentSeries.Points[Idx].MarkerSize = 8;
                        Idx++;
                    }
                }

            if (CurrentSeries.Points.Count < 2)
            {
                MessageBox.Show("Statistical Analyses - More than one data point needed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;

            }

            ChartArea CurrentChartArea = new ChartArea();
            CurrentChartArea.CursorX.IsUserSelectionEnabled = true;
            CurrentChartArea.BorderColor = Color.Black;

            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);

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

            CurrentChartArea.Axes[1].Title = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName();
            CurrentChartArea.Axes[0].Title = "Index";
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentSeries.ChartType = SeriesChartType.Point;

            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);

            double Av = NewWindow.chartForSimpleForm.DataManipulator.Statistics.Mean("ScatterPoints");
            double Std = Math.Sqrt(NewWindow.chartForSimpleForm.DataManipulator.Statistics.Variance("ScatterPoints", true));

            StripLine StdLine = new StripLine();

            StdLine.BackColor = Color.FromArgb(64, Color.BlanchedAlmond);

            StdLine.IntervalOffset = Av - 1.5 * Std;
            StdLine.StripWidth = 3 * Std;
            CurrentChartArea.AxisY.StripLines.Add(StdLine);

            StripLine AverageLine = new StripLine();
            AverageLine.BackColor = Color.Red;
            AverageLine.IntervalOffset = Av;
            AverageLine.StripWidth = 0.01;
            AverageLine.Text = String.Format("{0:0.###}", Av);
            CurrentChartArea.AxisY.StripLines.Add(AverageLine);

            NewWindow.Text = "Scatter Point / " + CompleteScreening.GetCurrentDisplayPlate().GetNumberOfActiveWells() + " points";
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
            return;
        }
コード例 #8
0
        private void DisplayMatrix(double[,] Matrix, List<string> ListLabelX, List<string> ListLabelY, bool IsDisplayValues, string TitleForGraph, int SquareSize, bool IsToBeDisplayed, string PathName)
        {
            int IdxValue = 0;

            Series CurrentSeries = new Series("Matrix");
            CurrentSeries.ChartType = SeriesChartType.Point;
            // loop on all the desciptors
            for (int iDesc = 0; iDesc < ListLabelX.Count; iDesc++)
            {
                for (int jDesc = 0; jDesc < ListLabelY.Count; jDesc++)
                {
                    CurrentSeries.Points.AddXY(iDesc + 1, jDesc + 1);
                    CurrentSeries.Points[IdxValue].MarkerStyle = MarkerStyle.Square;
                    CurrentSeries.Points[IdxValue].MarkerSize = SquareSize;
                    CurrentSeries.Points[IdxValue].BorderColor = Color.Black;
                    CurrentSeries.Points[IdxValue].BorderWidth = 1;
                    double Value = Matrix[iDesc, jDesc];

                    if (IsDisplayValues) CurrentSeries.Points[IdxValue].Label = string.Format("{0:0.###}", Math.Abs(Value));

                    CurrentSeries.Points[IdxValue].ToolTip = Math.Abs(Value) + " <=> | " + Matrix[iDesc, jDesc].ToString() + " |";

                    int ConvertedValue = (int)(Math.Abs(Value) * (CompleteScreening.GlobalInfo.LUT[0].Length - 1));

                    CurrentSeries.Points[IdxValue++].Color = Color.FromArgb(CompleteScreening.GlobalInfo.LUT[0][ConvertedValue], CompleteScreening.GlobalInfo.LUT[1][ConvertedValue], CompleteScreening.GlobalInfo.LUT[2][ConvertedValue]);
                }
            }

            for (int iDesc = 0; iDesc < ListLabelX.Count * ListLabelX.Count; iDesc++)
                CurrentSeries.Points[iDesc].AxisLabel = CompleteScreening.ListDescriptors.GetListNameActives()[iDesc / ListLabelX.Count];

            SmartLabelStyle SStyle = new SmartLabelStyle();

            SimpleForm NewWindow = new SimpleForm();
            NewWindow.Height = SquareSize * ListLabelY.Count + 220;
            NewWindow.Width = SquareSize * ListLabelX.Count + 245;

            ChartArea CurrentChartArea = new ChartArea("Default");
            for (int i = 0; i < CompleteScreening.ListDescriptors.GetListNameActives().Count; i++)
            {
                CustomLabel lblY = new CustomLabel();
                lblY.ToPosition = i * 2 + 2;
                lblY.Text = ListLabelY[i];
                CurrentChartArea.AxisY.CustomLabels.Add(lblY);
            }

            CurrentChartArea.AxisY.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep30;
            CurrentChartArea.BorderColor = Color.Black;
            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            CurrentSeries.SmartLabelStyle.Enabled = true;

            NewWindow.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);

            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[0].Minimum = 0;
            CurrentChartArea.Axes[0].Maximum = ListLabelX.Count + 1;
            CurrentChartArea.Axes[1].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[1].Minimum = 0;
            CurrentChartArea.Axes[1].Maximum = ListLabelY.Count + 1;
            CurrentChartArea.AxisX.Interval = 1;
            CurrentChartArea.AxisY.Interval = 1;

            Title CurrentTitle = new Title(TitleForGraph);
            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);
            NewWindow.chartForSimpleForm.Titles[0].Font = new Font("Arial", 9);

            if (IsToBeDisplayed) NewWindow.Show();
            else
                NewWindow.chartForSimpleForm.SaveImage(PathName + "_Matrix.emf", ChartImageFormat.Emf);
            NewWindow.Text = TitleForGraph;
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
        }
コード例 #9
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;
        }
コード例 #10
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 });
        }
コード例 #11
0
        private void ComputeAndDisplayMormalProbabilityPlot(bool IsFullScreen)
        {
            if (CompleteScreening == null) return;

            int CurrentDescSel = comboBoxDescriptorToDisplay.SelectedIndex;

            //if(CurrentDes
            if (CompleteScreening.SelectedClass < 0) return;

            int NumberOfPlates = CompleteScreening.ListPlatesActive.Count;
            List<cPlate> PlatesToProcess = new List<cPlate>();
            if (IsFullScreen)
            {
                for (int PlateIdx = 0; PlateIdx < NumberOfPlates; PlateIdx++)
                {
                    cPlate CurrentPlateToProcess = CompleteScreening.ListPlatesActive.GetPlate(CompleteScreening.ListPlatesActive[PlateIdx].Name);
                    PlatesToProcess.Add(CurrentPlateToProcess);
                }
            }
            else
            {
                PlatesToProcess.Add(CompleteScreening.GetCurrentDisplayPlate());
            }

            List<double> CurrentDesc = new List<double>();

            // loop on all the plate
            for (int PlateIdx = 0; PlateIdx < PlatesToProcess.Count; PlateIdx++)
            {
                cPlate CurrentPlateToProcess = PlatesToProcess[PlateIdx];

                for (int IdxValue = 0; IdxValue < CompleteScreening.Columns; IdxValue++)
                    for (int IdxValue0 = 0; IdxValue0 < CompleteScreening.Rows; IdxValue0++)
                    {
                        cWell TmpWell = CompleteScreening.GetCurrentDisplayPlate().GetWell(IdxValue, IdxValue0, true);
                        if (TmpWell != null)
                        {
                            if (TmpWell.GetClass() == CompleteScreening.SelectedClass)
                                CurrentDesc.Add(TmpWell.ListDescriptors[CurrentDescSel].GetValue());
                        }
                    }
            }

            if (CurrentDesc.Count < 3)
            {
                MessageBox.Show("Not enough data of class " + CompleteScreening.SelectedClass, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            CurrentDesc.Sort();
            double[] CenterNormDesc = new double[CurrentDesc.Count];
            CenterNormDesc = MeanCenteringStdStandarization(CurrentDesc.ToArray());

            int N = CurrentDesc.Count;
            double[] CumulativeProba = new double[CurrentDesc.Count];
            for (int i = 1; i < N - 1; i++)
                CumulativeProba[i] = (i - 0.3175) / (N + 0.365);

            CumulativeProba[N - 1] = Math.Pow(0.5, 1.0 / N);
            CumulativeProba[0] = 1 - CumulativeProba[N - 1];

            double[] PercentPointFunction = new double[CurrentDesc.Count];

            for (int i = 0; i < N; i++)
                PercentPointFunction[i] = alglib.normaldistr.invnormaldistribution(CumulativeProba[i]);

            SimpleForm NewWindow = new SimpleForm();
            NewWindow.Width = 600;
            NewWindow.Height = 600;

            NewWindow.Name = CompleteScreening.ListDescriptors[CurrentDescSel].GetName() + " normality plot : " + CompleteScreening.GetCurrentDisplayPlate().GetNumberOfActiveWells() + " points";
            Series CurrentSeries = new Series();
            CurrentSeries.ShadowOffset = 1;
            for (int Pt = 0; Pt < CurrentDesc.Count; Pt++)
            {
                CurrentSeries.Points.AddXY(PercentPointFunction[Pt], CenterNormDesc[Pt]);
                CurrentSeries.Points[Pt].Color = CompleteScreening.GlobalInfo.GetColor(CompleteScreening.SelectedClass);
                CurrentSeries.Points[Pt].MarkerStyle = MarkerStyle.Circle;
                CurrentSeries.Points[Pt].MarkerSize = 6;
            }

            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);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = true;
            CurrentChartArea.Axes[1].MajorGrid.Enabled = true;
            CurrentChartArea.AxisY.Minimum = CenterNormDesc[0];
            CurrentChartArea.AxisY.Maximum = CenterNormDesc[CurrentDesc.Count - 1];
            CurrentChartArea.AxisX.Minimum = -3;
            CurrentChartArea.AxisX.Maximum = 3;
            CurrentChartArea.AxisY.LabelStyle.Format = "N1";
            CurrentChartArea.AxisX.LabelStyle.Format = "N1";

            CurrentSeries.ChartType = SeriesChartType.Point;
            NewWindow.chartForSimpleForm.Series.Add(CurrentSeries);

            double Anderson_DarlingValue = Anderson_Darling(CurrentDesc.ToArray());
            GlobalInfo.ConsoleWriteLine("Anderson-Darling Test: " + Anderson_DarlingValue);

            Title AndersonLegend = new Title();
            if (CurrentDesc.Count >= 5)
            {
                double Jarque_BeraValue;
                alglib.jarqueberatest(CurrentDesc.ToArray(), CurrentDesc.Count, out Jarque_BeraValue);
                GlobalInfo.ConsoleWriteLine("Jarque-Bera Test: " + Jarque_BeraValue);
                //  AndersonLegend.Text = "Jarque-Bera: " + String.Format("{0:0.####}", Jarque_BeraValue);
            }

            AndersonLegend.Text += "Anderson-Darling: " + String.Format("{0:0.##}", Anderson_DarlingValue);
            AndersonLegend.Alignment = ContentAlignment.MiddleCenter;
            AndersonLegend.Docking = Docking.Bottom;
            AndersonLegend.TextOrientation = TextOrientation.Horizontal;

            NewWindow.chartForSimpleForm.Titles.Add(AndersonLegend);

            Title MainLegend = new Title();
            MainLegend.Text = CompleteScreening.ListDescriptors[CurrentDescSel].GetName();
            MainLegend.Docking = Docking.Top;
            MainLegend.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold);
            NewWindow.chartForSimpleForm.Titles.Add(MainLegend);

            NewWindow.chartForSimpleForm.Series.Add("TrendLine");
            NewWindow.chartForSimpleForm.Series["TrendLine"].ChartType = SeriesChartType.Line;
            NewWindow.chartForSimpleForm.Series["TrendLine"].BorderWidth = 1;
            NewWindow.chartForSimpleForm.Series["TrendLine"].Color = Color.Red;
            // Line of best fit is linear
            string typeRegression = "Linear";//"Exponential";//
            // The number of days for Forecasting
            string forecasting = "1";
            // Show Error as a range chart.
            string error = "false";
            // Show Forecasting Error as a range chart.
            string forecastingError = "false";
            // Formula parameters
            string parameters = typeRegression + ',' + forecasting + ',' + error + ',' + forecastingError;
            NewWindow.chartForSimpleForm.Series[0].Sort(PointSortOrder.Ascending, "X");
            // Create Forecasting Series.
            NewWindow.chartForSimpleForm.DataManipulator.FinancialFormula(FinancialFormula.Forecasting, parameters, NewWindow.chartForSimpleForm.Series[0], NewWindow.chartForSimpleForm.Series["TrendLine"]);

            //  NewWindow.Text = "Normal Probability Plot / " +;
            NewWindow.Show();

            if (IsFullScreen)
            {
                NewWindow.Text = CurrentDesc.Count + " points";
            }
            else
            {
                NewWindow.Text = CompleteScreening.GetCurrentDisplayPlate().Name + " : " + CurrentDesc.Count + " points";
            }
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
        }
コード例 #12
0
        public void DisplayHistogram(bool IsFullScreen)
        {
            if (CompleteScreening == null) return;
            if ((CompleteScreening.ListDescriptors == null) || (CompleteScreening.ListDescriptors.Count == 0)) return;

            cExtendedList Pos = new cExtendedList();
            cWell TempWell;

            if (IsFullScreen == false)
            {
                for (int row = 0; row < CompleteScreening.Rows; row++)
                    for (int col = 0; col < CompleteScreening.Columns; col++)
                    {
                        TempWell = CompleteScreening.GetCurrentDisplayPlate().GetWell(col, row, false);
                        if (TempWell == null) continue;
                        else
                        {
                            if (TempWell.GetClass() == CompleteScreening.SelectedClass)
                                Pos.Add(TempWell.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetValue());
                        }
                    }
            }
            else
            {
                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);

                    for (int row = 0; row < CompleteScreening.Rows; row++)
                        for (int col = 0; col < CompleteScreening.Columns; col++)
                        {
                            TempWell = CurrentPlateToProcess.GetWell(col, row, false);
                            if (TempWell == null) continue;
                            else
                            {
                                if (TempWell.GetClass() == CompleteScreening.SelectedClass)
                                    Pos.Add(TempWell.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetValue());
                            }
                        }
                }
            }

            if (Pos.Count == 0)
            {
                MessageBox.Show("No well of class " + CompleteScreening.SelectedClass + " selected !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List<double[]> HistoPos = CreateHistogram(Pos.ToArray(), (int)GlobalInfo.OptionsWindow.numericUpDownHistoBin.Value);
            SimpleForm NewWindow = new SimpleForm();

            Series SeriesPos = new Series();
            SeriesPos.ShadowOffset = 1;

            if (HistoPos.Count == 0) return;

            for (int IdxValue = 0; IdxValue < HistoPos[0].Length; IdxValue++)
            {
                SeriesPos.Points.AddXY(HistoPos[0][IdxValue], HistoPos[1][IdxValue]);
                SeriesPos.Points[IdxValue].ToolTip = HistoPos[1][IdxValue].ToString();
                if (CompleteScreening.SelectedClass == -1)
                    SeriesPos.Points[IdxValue].Color = Color.Black;
                else
                    SeriesPos.Points[IdxValue].Color = CompleteScreening.GlobalInfo.GetColor(CompleteScreening.SelectedClass);

            }

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

            NewWindow.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea.Axes[0].Title = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName();
            CurrentChartArea.Axes[1].Title = "Sum";
            CurrentChartArea.AxisX.LabelStyle.Format = "N2";

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

            SeriesPos.ChartType = SeriesChartType.Column;
            SeriesPos.Color = CompleteScreening.GlobalInfo.GetColor(1);
            NewWindow.chartForSimpleForm.Series.Add(SeriesPos);

            //Series SeriesGaussNeg = new Series();
            //SeriesGaussNeg.ChartType = SeriesChartType.Spline;

            //Series SeriesGaussPos = new Series();
            //SeriesGaussPos.ChartType = SeriesChartType.Spline;

            //if (HistoPos.Count != 0)
            //{
            //    double[] HistoGaussPos = CreateGauss(Mean(Pos.ToArray()), std(Pos.ToArray()), HistoPos[0].Length);

            //    SeriesGaussPos.Color = Color.Black;
            //    SeriesGaussPos.BorderWidth = 2;
            //}
            //SeriesGaussNeg.Color = Color.Black;
            //SeriesGaussNeg.BorderWidth = 2;

            //NewWindow.chartForSimpleForm.Series.Add(SeriesGaussNeg);
            // NewWindow.chartForSimpleForm.Series.Add(SeriesGaussPos);
            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScaleView.Zoomable = true;
            NewWindow.chartForSimpleForm.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;

            if (GlobalInfo.OptionsWindow.checkBoxDisplayHistoStats.Checked)
            {
                StripLine AverageLine = new StripLine();
                AverageLine.BackColor = Color.Black;
                AverageLine.IntervalOffset = Pos.Mean();
                AverageLine.StripWidth = double.Epsilon;
                CurrentChartArea.AxisX.StripLines.Add(AverageLine);
                AverageLine.Text = String.Format("{0:0.###}", AverageLine.IntervalOffset);

                StripLine StdLine = new StripLine();
                StdLine.BackColor = Color.FromArgb(64, Color.Black);
                double Std = Pos.Std();
                StdLine.IntervalOffset = AverageLine.IntervalOffset - 0.5 * Std;
                StdLine.StripWidth = Std;
                CurrentChartArea.AxisX.StripLines.Add(StdLine);
                AverageLine.StripWidth = 0.0001;
            }

            Title CurrentTitle = null;

            if (IsFullScreen)
                CurrentTitle = new Title("Class " + CompleteScreening.SelectedClass + " - " + CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName() + " histogram.");
            else
                CurrentTitle = new Title("Class " + CompleteScreening.SelectedClass + " - " + CompleteScreening.GetCurrentDisplayPlate().Name + " - " + CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor].GetName() + " histogram.");

            CurrentTitle.Font = new System.Drawing.Font("Arial", 11, FontStyle.Bold);
            NewWindow.chartForSimpleForm.Titles.Add(CurrentTitle);
            NewWindow.Text = CurrentTitle.Text;
            NewWindow.Show();
            NewWindow.chartForSimpleForm.Update();
            NewWindow.chartForSimpleForm.Show();
            NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
            return;
        }
コード例 #13
0
        private void ComputeAndDisplayCorrelationMatrix(bool IsFullScreen, bool IsToBeDisplayed, string PathForImage)
        {
            if (CompleteScreening == null) return;

            bool IsDisplayRanking = CompleteScreening.GlobalInfo.OptionsWindow.checkBoxCorrelationMatrixDisplayRanking.Checked;
            //bool IsPearson = CompleteScreening.GlobalInfo.OptionsWindow.radioButtonPearson.Checked;
            Boolean IsDisplayValues = false;

            List<double>[] ListValueDesc = ExtractDesciptorAverageValuesList(IsFullScreen);
            double[,] CorrelationMatrix = ComputeCorrelationMatrix(ListValueDesc);

            if (CorrelationMatrix == null)
            {
                MessageBox.Show("Data error, correlation computation impossible !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //   return;
            List<string> NameX = CompleteScreening.ListDescriptors.GetListNameActives();
            List<string> NameY = CompleteScreening.ListDescriptors.GetListNameActives();

            string TitleForGraph = "";
            if (GlobalInfo.OptionsWindow.radioButtonPearson.Checked) TitleForGraph = "Pearson ";
            else if
                (GlobalInfo.OptionsWindow.radioButtonSpearman.Checked) TitleForGraph = "Spearman's ";
            else if
                (GlobalInfo.OptionsWindow.radioButtonMIC.Checked) TitleForGraph = "MIC's ";
            TitleForGraph += " correlation matrix.";

            int SquareSize;

            if (NameX.Count > 20)
                SquareSize = 5;
            else
                SquareSize = 100 - ((10 * NameX.Count) / 3);
            DisplayMatrix(CorrelationMatrix, NameX, NameY, IsDisplayValues, TitleForGraph, SquareSize, IsToBeDisplayed, PathForImage);
            //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            if (IsDisplayRanking == false) return;

            Series CurrentSeries1 = new Series("Data1");
            CurrentSeries1.ShadowOffset = 1;
            CurrentSeries1.ChartType = SeriesChartType.Column;

            int RealPosSelectedDesc = -1;

            int realPos = 0;
            for (int i = 0; i < CompleteScreening.ListDescriptors.Count; i++)
            {
                if (CompleteScreening.ListDescriptors[i].IsActive()) realPos++;
                if (i == CompleteScreening.ListDescriptors.CurrentSelectedDescriptor)
                {
                    RealPosSelectedDesc = i - 2;
                    break;
                }
            }

            // loop on all the desciptors
            int IdxValue = 0;
            for (int iDesc = 0; iDesc < ListValueDesc.Length; iDesc++)
                for (int jDesc = 0; jDesc < ListValueDesc.Length; jDesc++)
                {
                    if (iDesc <= jDesc) continue;
                    CurrentSeries1.Points.Add(Math.Abs(CorrelationMatrix[iDesc, jDesc]));

                    if (GlobalInfo.OptionsWindow.checkBoxCorrelationRankChangeColorForActiveDesc.Checked)
                    {
                        if (CompleteScreening.ListDescriptors.CurrentSelectedDescriptor < CompleteScreening.ListDescriptors.GetListNameActives().Count)
                        {
                            if ((CompleteScreening.ListDescriptors.GetListNameActives()[iDesc] == CompleteScreening.ListDescriptors.GetListNameActives()[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor]) ||
                                (CompleteScreening.ListDescriptors.GetListNameActives()[jDesc] == CompleteScreening.ListDescriptors.GetListNameActives()[CompleteScreening.ListDescriptors.CurrentSelectedDescriptor]))
                                CurrentSeries1.Points[IdxValue].Color = Color.LightGreen;
                        }
                    }
                    CurrentSeries1.Points[IdxValue].Label = string.Format("{0:0.###}", CorrelationMatrix[iDesc, jDesc]);
                    CurrentSeries1.Points[IdxValue].ToolTip = CompleteScreening.ListDescriptors.GetListNameActives()[iDesc] + "\n vs. \n" + CompleteScreening.ListDescriptors.GetListNameActives()[jDesc];
                    CurrentSeries1.Points[IdxValue].AxisLabel = CurrentSeries1.Points[IdxValue++].ToolTip;
                }

            SimpleForm NewWindow1 = new SimpleForm();
            int thisWidth = CurrentSeries1.Points.Count * 100 + 200;
            if (thisWidth > (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value)
                thisWidth = (int)GlobalInfo.OptionsWindow.numericUpDownMaximumWidth.Value;
            NewWindow1.Width = thisWidth;
            //NewWindow1.Width = CurrentSeries1.Points.Count * 100 + 200;

            ChartArea CurrentChartArea1 = new ChartArea("Default1");
            CurrentChartArea1.BackGradientStyle = GradientStyle.TopBottom;
            CurrentChartArea1.BackColor = CompleteScreening.GlobalInfo.OptionsWindow.panel1.BackColor;
            CurrentChartArea1.BackSecondaryColor = Color.White;
            CurrentChartArea1.BorderColor = Color.Black;

            NewWindow1.chartForSimpleForm.ChartAreas.Add(CurrentChartArea1);
            CurrentSeries1.SmartLabelStyle.Enabled = true;
            CurrentChartArea1.AxisY.Title = "Absolute Correlation Coeff.";

            NewWindow1.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            NewWindow1.chartForSimpleForm.Series.Add(CurrentSeries1);

            CurrentChartArea1.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea1.Axes[1].MajorGrid.Enabled = false;
            CurrentChartArea1.Axes[1].Minimum = 0;
            CurrentChartArea1.Axes[1].Maximum = 1.2;

            CurrentChartArea1.AxisX.Interval = 1;
            NewWindow1.chartForSimpleForm.Series[0].Sort(PointSortOrder.Ascending, "Y");

            if (GlobalInfo.OptionsWindow.radioButtonPearson.Checked) TitleForGraph = "Pearson's ";
            else if (GlobalInfo.OptionsWindow.radioButtonPearson.Checked) TitleForGraph = "Spearman's ";
            else if (GlobalInfo.OptionsWindow.radioButtonMIC.Checked) TitleForGraph = "MIC's ";

            TitleForGraph += "correlation ranking";

            Title CurrentTitle1 = new Title(TitleForGraph);

            if (IsToBeDisplayed) NewWindow1.Show();
            else
                NewWindow1.chartForSimpleForm.SaveImage(PathForImage + "_Ranking.png", ChartImageFormat.Png);

            NewWindow1.chartForSimpleForm.Titles.Add(CurrentTitle1);
            NewWindow1.Text = "Quality Control: Corr. ranking";
            NewWindow1.chartForSimpleForm.Update();
            NewWindow1.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow1.chartForSimpleForm });

            return;
        }
コード例 #14
0
ファイル: HCSAnalyzer2.cs プロジェクト: cyrenaique/HCSA
        public void DisplayCorrelationRanking(List<double>[] ListValueDesc, double[,] CorrelationMatrix)
        {
            string TitleForGraph;
            Series CurrentSeries1 = new Series("Data1");
            CurrentSeries1.ShadowOffset = 1;
            CurrentSeries1.ChartType = SeriesChartType.Column;

            int RealPosSelectedDesc = -1;

            int realPos = 0;
            for (int i = 0; i < cGlobalInfo.CurrentScreening.ListDescriptors.Count; i++)
            {
                if (cGlobalInfo.CurrentScreening.ListDescriptors[i].IsActive()) realPos++;
                if (i == cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx)
                {
                    RealPosSelectedDesc = i - 2;
                    break;
                }
            }

            // loop on all the desciptors
            int IdxValue = 0;
            for (int iDesc = 0; iDesc < ListValueDesc.Length; iDesc++)
                for (int jDesc = 0; jDesc < ListValueDesc.Length; jDesc++)
                {
                    if (iDesc <= jDesc) continue;
                    CurrentSeries1.Points.Add(Math.Abs(CorrelationMatrix[iDesc, jDesc]));

                    if (cGlobalInfo.OptionsWindow.checkBoxCorrelationRankChangeColorForActiveDesc.Checked)
                    {
                        if (cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx < cGlobalInfo.CurrentScreening.ListDescriptors.GetListNameActives().Count)
                        {
                            if ((cGlobalInfo.CurrentScreening.ListDescriptors.GetListNameActives()[iDesc] == cGlobalInfo.CurrentScreening.ListDescriptors.GetListNameActives()[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx]) ||
                                (cGlobalInfo.CurrentScreening.ListDescriptors.GetListNameActives()[jDesc] == cGlobalInfo.CurrentScreening.ListDescriptors.GetListNameActives()[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx]))
                                CurrentSeries1.Points[IdxValue].Color = Color.LightGreen;
                        }
                    }
                    CurrentSeries1.Points[IdxValue].Label = string.Format("{0:0.###}", CorrelationMatrix[iDesc, jDesc]);
                    CurrentSeries1.Points[IdxValue].ToolTip = cGlobalInfo.CurrentScreening.ListDescriptors.GetListNameActives()[iDesc] + "\n vs. \n" + cGlobalInfo.CurrentScreening.ListDescriptors.GetListNameActives()[jDesc];
                    CurrentSeries1.Points[IdxValue].AxisLabel = CurrentSeries1.Points[IdxValue++].ToolTip;
                }

            SimpleForm NewWindow1 = new SimpleForm();
            int thisWidth = CurrentSeries1.Points.Count * 100 + 200;
            NewWindow1.Width = thisWidth;
            //NewWindow1.Width = CurrentSeries1.Points.Count * 100 + 200;

            ChartArea CurrentChartArea1 = new ChartArea("Default1");
            CurrentChartArea1.BackColor = Color.White;
            CurrentChartArea1.BorderColor = Color.Black;

            NewWindow1.chartForSimpleForm.ChartAreas.Add(CurrentChartArea1);
            CurrentSeries1.SmartLabelStyle.Enabled = true;
            CurrentChartArea1.AxisY.Title = "Absolute Correlation Coeff.";

            NewWindow1.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;
            NewWindow1.chartForSimpleForm.Series.Add(CurrentSeries1);

            CurrentChartArea1.Axes[0].MajorGrid.Enabled = false;
            CurrentChartArea1.Axes[1].MajorGrid.Enabled = false;
            CurrentChartArea1.Axes[1].Minimum = 0;
            CurrentChartArea1.Axes[1].Maximum = 1.2;

            CurrentChartArea1.AxisX.Interval = 1;
            NewWindow1.chartForSimpleForm.Series[0].Sort(PointSortOrder.Ascending, "Y");

            if (cGlobalInfo.OptionsWindow.radioButtonPearson.Checked) TitleForGraph = "Pearson's ";
            else if (cGlobalInfo.OptionsWindow.radioButtonPearson.Checked) TitleForGraph = "Spearman's ";
            else TitleForGraph = "MIC's ";

            TitleForGraph += "correlation ranking";

            Title CurrentTitle1 = new Title(TitleForGraph);

            /* if (IsToBeDisplayed) */
            NewWindow1.Show();
            //else
            //    NewWindow1.chartForSimpleForm.SaveImage(PathForImage + "_Ranking.png", ChartImageFormat.Png);

            NewWindow1.chartForSimpleForm.Titles.Add(CurrentTitle1);
            NewWindow1.Text = "Quality Control: Corr. ranking";
            NewWindow1.chartForSimpleForm.Update();
            NewWindow1.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow1.chartForSimpleForm });

            return;
        }