Exemplo n.º 1
0
        public cFeedBackMessage Run()
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }

            OutPutList = new cExtendedList();
            OutPutList.ListTags = new List<object>();
            for (int i = 0; i < this.Input.Count; i++)
            {
                for (int j = 0; j < this.Input[0].Count; j++)
                {
                    OutPutList.Add(this.Input[i][j]);
                }
                if (this.Input[i].ListTags != null)
                {

                    for (int j = 0; j < this.Input[i].Count; j++)
                        OutPutList.ListTags.Add(this.Input[i].ListTags[j]);
                }
            }

            this.OutPut = new cExtendedTable(OutPutList);
            this.OutPut.Name = "Linearize(" + this.Input.Name + ")";

            return FeedBackMessage;
        }
Exemplo n.º 2
0
        private void Process()
        {
            this.OutPut = new cExtendedTable();
            double Value = double.NaN;
            this.OutPut.ListRowNames = new List<string>();

            this.OutPut.Name = "Z-Factor(s)";

            for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++)
            {
                this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name);
                cExtendedList NewResult = new cExtendedList();
                NewResult.Name = this.Input[IdxCol].Name;
                for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++)
                {
                    if (IdxCol != IdxColBis)
                        Value = this.Input[IdxCol].ZFactor(this.Input[IdxColBis], this.IsRobust);
                    else
                        Value = double.NaN;

                    //if (double.IsInfinity(Value)) Value = 1;

                    NewResult.Add(Value);
                }
                this.OutPut.Add(NewResult);
            }

            base.Info = "Z-Factor (";
            if (IsRobust) base.Info +=  "Robust) - ";
            else
                base.Info += "Regular) - ";

            base.Info += this.Input[0].Count + " vs. " + this.Input[1].Count + " values.";
        }
Exemplo n.º 3
0
 public cHisto(cExtendedList OriginalValues, int NumBin)
 {
     List<double[]> Res = this.CreateHistogram(OriginalValues.ToArray(), NumBin);// OriginalValues.CreateHistogram(NumBin);
     ListValuesX = Res[0];
     ListValuesY = Res[1];
       //  this.Step = (Res[0].Max() - Res[0].Min()) / NumBin;
 }
        public cExtendedList GetListValues()
        {
            if (ValuesMatrix == null) return null;
            cExtendedList ToReturn = new cExtendedList();

            for (int j = 0; j < ValuesMatrix.Length; j++)
                for (int i = 0; i < ValuesMatrix[0].Length; i++)
                {
                    if (ValuesMatrix[j][i] != null) ToReturn.Add(ValuesMatrix[j][i]);

                }
            return ToReturn;
        }
Exemplo n.º 5
0
        public double Anderson_Darling(cExtendedList tab)
        {
            //double A = 0;
            //    double Mean1 = Mean(tab);
            //    double STD = std(tab);
            //    double[] norm = new double[tab.Length];

            //    for (int i = 0; i < tab.Length; i++)
            //        norm[i] = (tab[i] - Mean1) / STD;

            //tab.Normalize(eNormalizationType.STANDARDIZE);

            return Asquare(tab.Normalize(eNormalizationType.STANDARDIZE));
        }
Exemplo n.º 6
0
        public cFeedBackMessage Run()
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }

            // ------------- now proceed -------------
            this.OutPut = new cExtendedTable();
            this.OutPut.ListRowNames = new List<string>();

            this.OutPut.Name = "Mann-Withney Test";

            if (FTestTails == eFTestTails.BOTH)
                this.OutPut.Name += " (both tails)";
            else if (FTestTails == eFTestTails.LEFT)
                this.OutPut.Name += " (left tail)";
            else if (FTestTails == eFTestTails.RIGHT)
                this.OutPut.Name += " (right tail)";

            for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++)
            {
                this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name);
                cExtendedList NewResult = new cExtendedList();
                NewResult.Name = this.Input[IdxCol].Name;
                for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++)
                {
                    double bothtails;
                    double lefttail;
                    double righttail;

                    alglib.mannwhitneyutest(this.Input[IdxCol].ToArray(), this.Input[IdxCol].Count, this.Input[IdxColBis].ToArray(), this.Input[IdxColBis].Count, out bothtails, out lefttail, out righttail);

                    if (FTestTails == eFTestTails.BOTH)
                        NewResult.Add(bothtails);
                    else if (FTestTails == eFTestTails.LEFT)
                        NewResult.Add(lefttail);
                    else if (FTestTails == eFTestTails.RIGHT)
                        NewResult.Add(righttail);

                }
                this.OutPut.Add(NewResult);
            }

               return FeedBackMessage;
        }
Exemplo n.º 7
0
        public cExtendedTable GetPropertyTable()
        {
            cExtendedTable ToReturn = new cExtendedTable();
            ToReturn.Name = this.Name + " - Properties";

            cExtendedList Properties = new cExtendedList("Properties");

            ToReturn.Add(Properties);
            ToReturn.ListRowNames = new List<string>();


            ToReturn.ListRowNames.Add("Dimension X");
            Properties.Add(this.Width);
            ToReturn.ListRowNames.Add("Dimension Y");
            Properties.Add(this.Height);
            ToReturn.ListRowNames.Add("Dimension Z");
            Properties.Add(this.Depth);

            ToReturn.ListRowNames.Add("Voxel Size X");
            Properties.Add(this.Resolution.X);
            ToReturn.ListRowNames.Add("Voxel Size Y");
            Properties.Add(this.Resolution.Y);
            ToReturn.ListRowNames.Add("Voxel Size Z");
            Properties.Add(this.Resolution.Z);

            ToReturn.ListRowNames.Add("Position X");
            Properties.Add(this.Position.X);
            ToReturn.ListRowNames.Add("Position Y");
            Properties.Add(this.Position.Y);
            ToReturn.ListRowNames.Add("Position Z");
            Properties.Add(this.Position.Z);


            ToReturn.ListRowNames.Add("Channel Numbers");
            Properties.Add(this.GetNumChannels());

            for (int i = 0; i < this.GetNumChannels(); i++)
            {
                ToReturn.ListRowNames.Add(this.SingleChannelImage[i].Name + " - Wavelenght");
                Properties.Add(i);
            }



            return ToReturn;

        }
Exemplo n.º 8
0
        public double Asquare(cExtendedList data)
        {
            double A = 0;
            double Mean1 = data.Mean();
            double STD = data.Std();
            double varianceb = Math.Sqrt(2 * STD * STD);
            double err = 0;
            int cpt = 0;
            for (int i = 0; i < data.Count; i++)
            {
                cpt++;
                err += ((2 * cpt - 1) * (Math.Log(CDF(data[i], Mean1, varianceb)) + Math.Log(1 - CDF(data[data.Count - 1 - i], Mean1, varianceb))));
            }
            A = -data.Count - err / data.Count;

            return A;
        }
Exemplo n.º 9
0
        void DisplayGraphItem(object sender, EventArgs e)
        {
            FormForDisplay TMPWin = new FormForDisplay();
            Panel Pan = new Panel();
            Pan.Show();

            cExtendedList ListValue = new cExtendedList();
            for (int Idx = 0; Idx < this.listViewForClassifHistory.Items.Count; Idx++)
            {
               // this.listViewForCellPopulations.Items[Idx];
                ListValue.Add(double.Parse(this.listViewForClassifHistory.Items[Idx].SubItems[2].Text));
            }

             //   ListValue.Name = this.dt.Columns[e.ColumnIndex].ColumnName;

            cPanelHisto PanelHisto = new cPanelHisto(ListValue, eGraphType.LINE, eOrientation.HORIZONTAL);
            TMPWin.Controls.Add(PanelHisto.WindowForPanelHisto.panelForGraphContainer);
            TMPWin.Show();
        }
Exemplo n.º 10
0
        private void Process()
        {
            this.OutPut = new cExtendedTable();
            double Value = double.NaN;
            this.OutPut.ListRowNames = new List<string>();

            this.OutPut.Name = "Mahalanobis";
            for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++)
            {
                this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name);
                cExtendedList NewResult = new cExtendedList();
                NewResult.Name = this.Input[IdxCol].Name;
                for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++)
                {
                    Value = this.Input[IdxCol].Dist_Euclidean(this.Input[IdxColBis]);
                    NewResult.Add(Value);
                }
                this.OutPut.Add(NewResult);
            }
        }
Exemplo n.º 11
0
        private void Process()
        {
            this.OutPut = new cExtendedTable();
            double Value = double.NaN;
            this.OutPut.ListRowNames = new List<string>();

                this.OutPut.Name = "Covariance Matrix";
                for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++)
                {
                    this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name);
                    cExtendedList NewResult = new cExtendedList();
                    NewResult.Name = this.Input[IdxCol].Name;
                    for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++)
                    {
                        Value = alglib.cov2(this.Input[IdxCol].ToArray(), this.Input[IdxColBis].ToArray());
                        NewResult.Add(Value);
                    }
                    this.OutPut.Add(NewResult);
                }
        }
Exemplo n.º 12
0
        private void Process()
        {
            this.OutPut = new cExtendedTable();
            double Value = double.NaN;
            this.OutPut.ListRowNames = new List<string>();

                this.OutPut.Name = "dot product(s)";
                for (int IdxCol = 0; IdxCol < this.Input.Count; IdxCol++)
                {
                    this.OutPut.ListRowNames.Add(this.Input[IdxCol].Name);
                    cExtendedList NewResult = new cExtendedList();
                    NewResult.Name = this.Input[IdxCol].Name;
                    for (int IdxColBis = 0; IdxColBis < this.Input.Count; IdxColBis++)
                    {
                        //if (IdxCol != IdxColBis)
                        Value = this.Input[IdxCol].DotProduct(this.Input[IdxColBis], IsNormalized);

                        NewResult.Add(Value);
                    }
                    this.OutPut.Add(NewResult);
                }
        }
Exemplo n.º 13
0
        private void Process()
        {
            base.Output = new cExtendedTable();
            double Value = double.NaN;
            base.Output.ListRowNames = new List<string>();
            base.Output.ListRowNames.Add(base.Input1.Name);

            if (this.CorrelationType == eCorrelationType.PEARSON)
            {
                base.Output.Name = "Pearson Correlation Coefficient";
                Value = alglib.pearsoncorr2(base.Input1.ToArray(), base.Input2.ToArray());
            }
            else if (this.CorrelationType == eCorrelationType.SPEARMAN)
            {
                base.Output.Name = "Spearman Correlation Coefficient";
                Value = alglib.spearmancorr2(base.Input1.ToArray(), base.Input2.ToArray());
            }

            cExtendedList Result = new cExtendedList();
            Result.Add(Value);
            base.Output.Add(Result);
            base.Output[0].Name = base.Input2.Name;
        }
Exemplo n.º 14
0
        public cFeedBackMessage Run()
        {
            if (base.Start() == false)
            {
                base.FeedBackMessage.IsSucceed = false;
                return base.FeedBackMessage;
            }

            #region parameters initilization
            object _firstValue = base.ListProperties.FindByName("Kernel size");
            int KernelSize = 0;
            if (_firstValue == null)
            {
                base.GenerateError("Kernel size not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                KernelSize = (int)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("Kernel size cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Image width");
            int ImWidth = 0;
            if (_firstValue == null)
            {
                base.GenerateError("Image width not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                ImWidth = (int)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("Image width cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Image height");
            int ImHeight = 0;
            if (_firstValue == null)
            {
                base.GenerateError("Image height not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                ImHeight = (int)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("Image height cast didn't work");
                return base.FeedBackMessage;
            }

            _firstValue = base.ListProperties.FindByName("Image depth");
            int ImDepth = 0;
            if (_firstValue == null)
            {
                base.GenerateError("Image depth not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                ImDepth = (int)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("Image depth cast didn't work");
                return base.FeedBackMessage;
            }
            #endregion

            if (this.Input[0].Count == 2) ImDepth = 1;
            if (this.Input[0].Count == 1)
            {
                ImDepth = 1;
                ImHeight = 1;
            }

            this.Output = new cImage(ImWidth, ImHeight, ImDepth, this.Input.Count);

            cImageDrawKernel GK = new cImageDrawKernel();
            GK.sigma_x = KernelSize;
            GK.sigma_y = KernelSize;
            GK.sigma_z = KernelSize;
            GK.Run();

            cImage K = GK.GetOutPut();

            for (int IdxChannel = 0; IdxChannel < this.Input.Count; IdxChannel++)
            {
                cExtendedTable CurrentTable = this.Input[IdxChannel];
                cExtendedList ListVolumes = new cExtendedList();

                double MaxX = CurrentTable[0].Max();
                double MinX = CurrentTable[0].Min();

                double MaxY = CurrentTable[1].Max();
                double MinY = CurrentTable[1].Min();

                double MaxZ = 0;
                double MinZ = 0;

                if (CurrentTable.Count>2)
                {
                    MaxZ = CurrentTable[2].Max();
                    MinZ = CurrentTable[2].Min();
                }

                this.Output.SingleChannelImage[IdxChannel].Resolution.X = (MaxX - MinX) / (double)ImWidth;
                this.Output.SingleChannelImage[IdxChannel].Resolution.Y = (MaxY - MinY) / (double)ImHeight;
                this.Output.SingleChannelImage[IdxChannel].Resolution.Z = (MaxZ - MinZ) / (double)ImDepth;

                if (CurrentTable.Count > 2)
                {
                    for (int j = 0; j < CurrentTable[0].Count; j++)
                    {
                        double TmpValueX = (ImWidth * (CurrentTable[0][j] - MinX)) / (MaxX - MinX) - K.Width / 2;
                        double TmpValueY = (ImHeight * (CurrentTable[1][j] - MinY)) / (MaxY - MinY) - K.Height / 2;
                        double TmpValueZ = (ImDepth * (CurrentTable[2][j] - MinZ)) / (MaxZ - MinZ) - K.Depth / 2;

                        this.Output.AddInto(K, (int)TmpValueX,  (int)TmpValueY, (int)TmpValueZ, IdxChannel);
                    }
                }
                else
                {
                    for (int j = 0; j < CurrentTable[0].Count; j++)
                    {
                        double TmpValueX = (ImWidth * (CurrentTable[0][j] - MinX)) / (MaxX - MinX) - K.Width / 2;
                        double TmpValueY = ImHeight - (ImHeight * (CurrentTable[1][j] - MinY)) / (MaxY - MinY) - K.Height / 2;

                        this.Output.AddInto(K, (int)TmpValueX, (int)TmpValueY, 0, IdxChannel);
                    }
                }
                cListExtendedTable TablesForDensity = new cListExtendedTable(this.Output);

                for (int idxChannel = 0; idxChannel < this.Output.GetNumChannels(); idxChannel++)
                {
                    this.Output.SingleChannelImage[idxChannel].Name = this.Input.Name;//cGlobalInfo.ListCellularPhenotypes[idxChannel].Name;
                    float Sum = 1;
                    if (IsNormalized)
                    {
                        Sum = (float)TablesForDensity[idxChannel].Sum();
                        if (Sum <= 0.0) continue;
                        for (int i = 0; i < this.Output.SingleChannelImage[idxChannel].Data.Length; i++)
                        {
                            this.Output.SingleChannelImage[idxChannel].Data[i] = (10000000 * this.Output.SingleChannelImage[idxChannel].Data[i]) / Sum;
                        }
                    }
                    //else
                    //{
                    //    for (int i = 0; i < this.Output.SingleChannelImage[idxChannel].Data.Length; i++)
                    //    {
                    //        // if (ClassPopulations[idxChannel] > 0)
                    //        this.Output.SingleChannelImage[idxChannel].Data[i] = this.Output.SingleChannelImage[idxChannel].Data[i];
                    //    }
                    //}
                }
            }

            this.Output.SingleChannelImage[0].UpDateMax();
            this.Output.SingleChannelImage[0].UpDateMin();
            base.End();
            return FeedBackMessage;
        }
Exemplo n.º 15
0
        public cWindowToDisplayHisto(cScreening CompleteScreening0, cExtendedList RawValues0)
        {
            this.CompleteScreening = CompleteScreening0;

            this.parametersToolStripMenuItem.Click += new System.EventHandler(this.parametersToolStripMenuItem_Click);

            RequestWindow.label3.Text = "Bin Number";

            this.RawValues = RawValues0;

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

            this.chartForSimpleForm.ChartAreas.Add(CurrentChartArea);
            CurrentChartArea.Axes[0].MajorGrid.Enabled = false;
            if(CompleteScreening!=null)
                CurrentChartArea.Axes[0].Title = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();
            CurrentChartArea.Axes[1].Title = "Sum";
            CurrentChartArea.AxisX.LabelStyle.Format = "N2";

            this.chartForSimpleForm.TextAntiAliasingQuality = TextAntiAliasingQuality.High;

            if (CompleteScreening != null)
                CurrentChartArea.BackColor = Color.White;

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

            if ((CompleteScreening != null) && (cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxHistoDisplayStats.Checked))
            {
                StripLine AverageLine = new StripLine();
                AverageLine.BackColor = Color.Black;
                AverageLine.IntervalOffset = RawValues.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 = RawValues.Std();
                StdLine.IntervalOffset = AverageLine.IntervalOffset - 0.5 * Std;
                StdLine.StripWidth = Std;
                CurrentChartArea.AxisX.StripLines.Add(StdLine);
                AverageLine.StripWidth = 0.0001;
            }

            SerieForHisto = new Series();
            SerieForHisto.ShadowOffset = 1;
            SerieForHisto.ChartType = SeriesChartType.Column;
            if (CompleteScreening != null)
            SerieForHisto.Color = cGlobalInfo.ListWellClasses[1].ColourForDisplay;

            List<double[]> HistoPos = RawValues.CreateHistogram(this.BinNumber, false);
            if (HistoPos.Count == 0) return;

            for (int IdxValue = 0; IdxValue < HistoPos[0].Length; IdxValue++)
            {
                SerieForHisto.Points.AddXY(HistoPos[0][IdxValue], HistoPos[1][IdxValue]);
                SerieForHisto.Points[IdxValue].ToolTip = HistoPos[1][IdxValue].ToString();
                if (CompleteScreening != null)
                {
                    if (CompleteScreening.SelectedClass == -1)
                        SerieForHisto.Points[IdxValue].Color = Color.Black;
                    else
                        SerieForHisto.Points[IdxValue].Color = cGlobalInfo.ListWellClasses[CompleteScreening.SelectedClass].ColourForDisplay;
                }
            }
            this.chartForSimpleForm.Series.Add(SerieForHisto);
        }
Exemplo n.º 16
0
        private void Process()
        {
            double[,] DataForLDA = Input.CopyToArray();

            //double[,] Basis;
            //double[] s2;
            int Info;
            /*************************************************************************
            Linear least squares fitting.

            QR decomposition is used to reduce task to MxM, then triangular solver  or
            SVD-based solver is used depending on condition number of the  system.  It
            allows to maximize speed and retain decent accuracy.

            INPUT PARAMETERS:
                Y       -   array[0..N-1] Function values in  N  points.
                FMatrix -   a table of basis functions values, array[0..N-1, 0..M-1].
                            FMatrix[I, J] - value of J-th basis function in I-th point.
                N       -   number of points used. N>=1.
                M       -   number of basis functions, M>=1.

            OUTPUT PARAMETERS:
                Info    -   error code:
                            * -4    internal SVD decomposition subroutine failed (very
                                    rare and for degenerate systems only)
                            *  1    task is solved
                C       -   decomposition coefficients, array[0..M-1]
                Rep     -   fitting report. Following fields are set:
                            * Rep.TaskRCond     reciprocal of condition number
                            * R2                non-adjusted coefficient of determination
                                                (non-weighted)
                            * RMSError          rms error on the (X,Y).
                            * AvgError          average error on the (X,Y).
                            * AvgRelError       average relative error on the non-zero Y
                            * MaxError          maximum error
                                                NON-WEIGHTED ERRORS ARE CALCULATED

            ERRORS IN PARAMETERS

            This  solver  also  calculates different kinds of errors in parameters and
            fills corresponding fields of report:
            * Rep.CovPar        covariance matrix for parameters, array[K,K].
            * Rep.ErrPar        errors in parameters, array[K],
                                errpar = sqrt(diag(CovPar))
            * Rep.ErrCurve      vector of fit errors - standard deviations of empirical
                                best-fit curve from "ideal" best-fit curve built  with
                                infinite number of samples, array[N].
                                errcurve = sqrt(diag(F*CovPar*F')),
                                where F is functions matrix.
            * Rep.Noise         vector of per-point estimates of noise, array[N]

            NOTE:       noise in the data is estimated as follows:
                        * for fitting without user-supplied  weights  all  points  are
                          assumed to have same level of noise, which is estimated from
                          the data
                        * for fitting with user-supplied weights we assume that  noise
                          level in I-th point is inversely proportional to Ith weight.
                          Coefficient of proportionality is estimated from the data.

            NOTE:       we apply small amount of regularization when we invert squared
                        Jacobian and calculate covariance matrix. It  guarantees  that
                        algorithm won't divide by zero  during  inversion,  but  skews
                        error estimates a bit (fractional error is about 10^-9).

                        However, we believe that this difference is insignificant  for
                        all practical purposes except for the situation when you  want
                        to compare ALGLIB results with "reference"  implementation  up
                        to the last significant digit.

              -- ALGLIB --
                 Copyright 17.08.2009 by Bochkanov Sergey
            *************************************************************************/

            double[] weights = null;
            int fitResult = 0;
            double[] resultData = new double[this.Input[0].Count];

            //alglib.lsfit.lsfitreport rep = new alglib.lsfit.lsfitreport();
            //alglib.lsfit.lsfitlinear(resultData, DataForLDA, this.Input[0].Count, this.Input.Count, ref fitResult, ref weights, rep);

            //alglib.lsfitstate state;
            int info;
            //double[] c = new double[] { 0, 0, 0, 0 };

            //alglib.lsfitreport Nrep;
            //alglib.lsfitresults(state, out info, out c, out Nrep);

               // alglib.fisherldan(DataForLDA, this.Input[0].Count, this.Input.Count - 1, (int)this.Input[this.Input.Count - 1].Max() + 1, out Info, out Basis);
            //Output = new cExtendedTable(Basis);
            alglib.linearmodel LM = null;
            alglib.lrreport Lreport = null;
            alglib.lrbuild(DataForLDA, this.Input[0].Count, this.Input.Count-1, out info, out LM, out Lreport);

                //RelativeError = rep.avgrelerror;
            //LM.innerobj.w[0] = 1;

            double[] Coeff = null;
            int NVars;

            alglib.lrunpack(LM, out Coeff, out NVars);

            cExtendedList CL = new  cExtendedList();
            CL.AddRange(Coeff);
            CL.Name = "Coefficients";

            this.Output = new cExtendedTable(CL);

            this.Output.ListRowNames = new List<string>();

            for (int i = 0; i < this.Output[0].Count; i++)
                this.Output.ListRowNames.Add("Coeff_" + i);

            double RelativeError = Lreport.avgrelerror;
            this.Output.ListRowNames.Add("Relative Error");
            CL.Add(RelativeError);

            Output.Name = "Linear regression coeff. of (" + this.Input.Name + ")";

            //foreach (var item in Output)
            //{
            //    item.ListTags = new List<object>();
            //    for (int i = 0; i < Output[0].Count; i++)
            //        item.ListTags.Add(this.Input[i].Tag);
            //}

            //for (int IdxLDA = 0; IdxLDA < Output.Count; IdxLDA++)
            //{
            //    Output[IdxLDA].Name = "LDA_" + (IdxLDA + 1);
            //    Output.ListRowNames.Add(this.Input[IdxLDA].Name);
            //}
        }
Exemplo n.º 17
0
        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;
        }
Exemplo n.º 18
0
 public cHisto(cExtendedList OriginalValues, int NumBin)
 {
     List<double[]> Res= OriginalValues.CreateHistogram(NumBin, false);
     ListValuesX = Res[0];
     ListValuesY = Res[1];
 }
Exemplo n.º 19
0
 public cExtendedList GetYvalues()
 {
     cExtendedList List = new cExtendedList();
     List.AddRange(ListValuesY);
     return List;
 }
Exemplo n.º 20
0
        private void createAveragePlateToolStripMenuItem_Click(object sender, EventArgs e)
        {

            FormForPlateAveraging FFPA = new FormForPlateAveraging();

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

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

            cListPlates LP = PlatesSelectionPanel.GetListSelectedPlates();


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

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

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

            }

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


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

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

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

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

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

                }

            cGlobalInfo.CurrentScreening.AddPlate(NewPlate);
            cGlobalInfo.CurrentScreening.ListPlatesActive.Add(NewPlate);
            toolStripcomboBoxPlateList.Items.Add(NewPlate.GetName());
            cGlobalInfo.CurrentScreening.ListPlatesActive[cGlobalInfo.CurrentScreening.ListPlatesActive.Count - 1].UpDataMinMax();
            cGlobalInfo.CurrentScreening.CurrentDisplayPlateIdx = 0;
            cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().DisplayDistribution(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor(), true);
        }
Exemplo n.º 21
0
        private void drawSingleDRCToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int NumberOfReplicate = 4;
            int DRCNumberofPoints = 20;

            cExtendedTable FullResults = new cExtendedTable();
            FullResults.ListRowNames = new List<string>();



            cExtendedList ListPValues = new cExtendedList("DRC");


            cDataGeneratorTitration GT = new cDataGeneratorTitration();
            GT.NumberOfPoint = DRCNumberofPoints;
            GT.Start = 100;
            GT.DilutionFactor = 3;
            GT.Run();


            Random RND = new Random();

            cExtendedTable FinalTable = new cExtendedTable();

            cDataGeneratorSigmoid DGS = null;
            DGS = new cDataGeneratorSigmoid();
            DGS.SetInputData(GT.GetOutPut()[0]);
            DGS.EC50 = 0.01;
            DGS.Bottom = 10;
            DGS.Top = 110;
            DGS.Slope = 1;
            DGS.Run();

            // cAddNoise AN = new cAddNoise();
            // AN.DistributionType = eRandDistributionType.GAUSSIAN;

            double NoiseLevel = 10;
            //   EXT[0].Add(NoiseLevel);
            //   EXT[1].Add(DGS.EC50);

            #region loop over the replicates
            for (int NumReplic = 0; NumReplic < NumberOfReplicate; NumReplic++)
            {

                cExtendedList NewL = DGS.GetOutPut()[1];
                for (int k = 0; k < NewL.Count; k++)
                {
                    NewL[k] += RND.NextDouble() * NoiseLevel;
                }

                cExtendedTable TmpTable = new cExtendedTable();
                TmpTable.Add(GT.GetOutPut()[0]);
                TmpTable.Add(NewL);

                if (NumReplic >= 1)
                {
                    cMerge M = new cMerge();
                    M.IsHorizontal = false;
                    M.SetInputData(TmpTable, FinalTable);
                    M.Run();
                    FinalTable = M.GetOutPut();
                }
                else
                    FinalTable = new cExtendedTable(TmpTable);

            }
            #endregion


            cSigmoidFitting SF = new cSigmoidFitting();
            SF.SetInputData(FinalTable);
            SF.Run();

            cGlobalInfo.ConsoleWriteLine("Slope :" + DGS.Slope + " - Evaluated:" + SF.GetOutPut()[0][3]);
            cGlobalInfo.ConsoleWriteLine("Top :" + DGS.Top + " - Evaluated:" + SF.GetOutPut()[0][1]);
            cGlobalInfo.ConsoleWriteLine("Bottom :" + DGS.Bottom + " - Evaluated:" + SF.GetOutPut()[0][0]);
            cGlobalInfo.ConsoleWriteLine("EC50 :" + DGS.EC50 + " - Evaluated:" + SF.GetOutPut()[0][2]);


            // return;


            cCurveForGraph CFG = new cCurveForGraph();
            CFG.SetInputData(FinalTable);
            CFG.Run();

            cExtendedTable Sigmoid = SF.GetFittedRawValues(GT.GetOutPut()[0]);
            FinalTable[0] = Sigmoid[1];


            cViewerGraph1D VS1 = new cViewerGraph1D();
            VS1.SetInputData(new cExtendedTable(Sigmoid[1]));
            VS1.AddCurve(CFG);
            VS1.Chart.X_AxisValues = Sigmoid[0];//DGS.GetOutPut()[0];
            VS1.Chart.IsLogAxis = true;
            VS1.Chart.IsLine = true;
            VS1.Chart.IsShadow = true;
            VS1.Chart.Opacity = 210;
            VS1.Chart.LineWidth = 3;
            VS1.Chart.LabelAxisX = "Concentration";
            VS1.Chart.LabelAxisY = "Readout";
            VS1.Chart.XAxisFormatDigitNumber = -1;
            VS1.Chart.IsZoomableX = true;
            VS1.Chart.IsZoomableY = true;
            VS1.Run();

            cDesignerSinglePanel CD = new cDesignerSinglePanel();
            CD.SetInputData(VS1.GetOutPut());
            CD.Run();

            cDisplayToWindow DTW = new cDisplayToWindow();
            DTW.SetInputData(CD.GetOutPut());//DS.GetOutPut());
            DTW.Run();
            DTW.Display();

        }
Exemplo n.º 22
0
        private void mahalanobisDistanceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormForMahalanobisDistance MainWindow = new FormForMahalanobisDistance();

            PanelForClassSelection ClassSelectionPanel = new PanelForClassSelection(true, eClassType.WELL);
            ClassSelectionPanel.Height = MainWindow.panelForSourceCloud.Height;
            MainWindow.panelForSourceCloud.Controls.Add(ClassSelectionPanel);

            PanelForClassSelection HitClassSelectionPanel = new PanelForClassSelection(false, eClassType.WELL);
            HitClassSelectionPanel.Height = MainWindow.panelHitClass.Height;
            HitClassSelectionPanel.ListRadioButtons[1].Checked = true;
            MainWindow.panelHitClass.Controls.Add(HitClassSelectionPanel);

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

            cExtendedList ListClassSelected = new cExtendedList();
            for (int i = 0; i < ClassSelectionPanel.ListCheckBoxes.Count; i++)
                if (ClassSelectionPanel.ListCheckBoxes[i].Checked) ListClassSelected.Add(1);
                else
                    ListClassSelected.Add(0);

            int IdxClassForOutliers = 0;
            for (int i = 0; i < HitClassSelectionPanel.ListRadioButtons.Count; i++)
                if (HitClassSelectionPanel.ListRadioButtons[i].Checked)
                {
                    IdxClassForOutliers = i;
                    break;
                }

            if (ListClassSelected.Sum() < 1)
            {
                MessageBox.Show("At least one classe has to be selected.", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // start by computing the inversed covariance matrix
            //if (checkedListBoxActiveDescriptors.CheckedItems.Count <= 1)
            //{
            //    MessageBox.Show("At least two descriptors have to be selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return;
            //}


            cCovarianceMatrix CM = new cCovarianceMatrix();
            cExtendedTable NewTable = null;

            if (this.ProcessModeplateByPlateToolStripMenuItem.Checked)
            {
                //foreach (cPlate TmpPlate in CompleteScreening.ListPlatesActive)
                //{
                //    cListWells ListWellsToProcess = new cListWells(null);
                //    foreach (cWell item in TmpPlate.ListActiveWells)
                //        if ((item.GetClassIdx() != -1) && (ListClassSelected[item.GetClassIdx()] == 1)) ListWellsToProcess.Add(item);

                //    cExtendedTable NewTable = new cExtendedTable(ListWellsToProcess, true);

                //    CM.SetInputData(NewTable);
                //}
            }
            else if (this.ProcessModeEntireScreeningToolStripMenuItem.Checked)
            {
                cListWells ListWellsToProcess = new cListWells(null);

                foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                    foreach (cWell item in TmpPlate.ListActiveWells)
                        if ((item.GetCurrentClassIdx() != -1) && (ListClassSelected[item.GetCurrentClassIdx()] == 1)) ListWellsToProcess.Add(item);

                NewTable = new cExtendedTable(ListWellsToProcess, true);

                //  cTwoSampleFTest CM = new cTwoSampleFTest();
                CM.SetInputData(NewTable);
            }
            else
            {
                cListWells ListWellsToProcess = new cListWells(null);

                foreach (cWell item in cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate().ListActiveWells)
                    if ((item.GetCurrentClassIdx() != -1) && (ListClassSelected[item.GetCurrentClassIdx()] == 1)) ListWellsToProcess.Add(item);

                NewTable = new cExtendedTable(ListWellsToProcess, true);

                // cTwoSampleFTest CM = new cTwoSampleFTest();
                CM.SetInputData(NewTable);
            }

            CM.Run();

            cInverse cI = new cInverse();
            cI.SetInputData(CM.GetOutPut());
            cI.Run();

            // get the cloud center
            cStatistics cstat = new cStatistics();
            cstat.UnselectAll();
            cstat.IsMean = true;
            cstat.SetInputData(NewTable);
            cstat.Run();

            if (cstat.GetOutPut() == null) return;

            cExtendedList ListMeans = cstat.GetOutPut().GetRow(0);
            cDescriptorType MahalanobisType = new cDescriptorType("Mahalanobis Distance", true, 1);

            #region Compute the Threshold
            int DegreeOfFreedom = cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors().Count;
            cExtendedTable T = new cExtendedTable();
            T.Add(new cExtendedList());

            T[0].Add((double)MainWindow.numericUpDownPValue.Value);

            cFunctions F = new cFunctions();
            F.SetInputData(T);
            F.IsInverse = true;
            F.DegreeOfFreedom = DegreeOfFreedom;
            F.Run();

            double ThresholdForMahalanobis = Math.Sqrt(F.GetOutPut()[1][0]);

            #endregion


            int IdxClassForNonOutliers = 1;

            foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesAvailable)
            {
                for (int Col = 0; Col < cGlobalInfo.CurrentScreening.Columns; Col++)
                    for (int Row = 0; Row < cGlobalInfo.CurrentScreening.Rows; Row++)
                    {
                        cWell TmpWell = TmpPlate.GetWell(Col, Row, false);
                        if (TmpWell == null) continue;

                        double ValueDistance = TmpWell.GetAverageValuesList(true)[0].Dist_Mahalanobis(ListMeans, cI.GetOutPut());
                        if (ValueDistance > ThresholdForMahalanobis || double.IsNaN(ValueDistance) )        // that's an outlier
                        {
                            TmpWell.SetClass(IdxClassForOutliers);
                        }
                        else
                        {
                            TmpWell.SetClass(IdxClassForNonOutliers);
                        }

                        if (MainWindow.checkBoxDistAsDesc.Checked)
                        {
                            cListSignature LDesc = new cListSignature();
                            cSignature NewDesc = new cSignature(ValueDistance, MahalanobisType, cGlobalInfo.CurrentScreening);
                            LDesc.Add(NewDesc);
                            TmpWell.AddSignatures(LDesc);
                        }
                    }
            }

            if (MainWindow.checkBoxDistAsDesc.Checked)
            {
                cGlobalInfo.CurrentScreening.ListDescriptors.AddNew(MahalanobisType);
            }

            cGlobalInfo.CurrentScreening.ListDescriptors.UpDateDisplay();
            cGlobalInfo.CurrentScreening.UpDatePlateListWithFullAvailablePlate();

            for (int idxP = 0; idxP < cGlobalInfo.CurrentScreening.ListPlatesActive.Count; idxP++)
                cGlobalInfo.CurrentScreening.ListPlatesActive[idxP].UpDataMinMax();
        }
Exemplo n.º 23
0
        private void sigmoidFittToolStripMenuItem_Click(object sender, EventArgs e)
        {

            int NumberOfReplicate = 4;
            int NumberOfCurves = 30;
            int DRCNumberofPoints = 12;

            cExtendedTable FullResults = new cExtendedTable();
            FullResults.ListRowNames = new List<string>();

            double RealEC50 = 0.0001;
            int NumberOfDiffEC50 = 20;
            int NumberOfSlopes = 100;

            //  for (int EC50 = 0; EC50 < NumberOfDiffEC50; EC50++)
            {




                //double TmpSlopeValue = 0.0;
                for (int EC50 = 0; EC50 < NumberOfDiffEC50; EC50++)
                //for (int SlopeTmp = 0; SlopeTmp < NumberOfSlopes; SlopeTmp++)
                {
                    RealEC50 *= 2;
                    //TmpSlopeValue += 0.1;
                    cExtendedList ListPValues = new cExtendedList("EC50 - " + RealEC50/*TmpSlopeValue*/);


                    cDesignerTab DT = new cDesignerTab();
                    DT.IsMultiline = false;

                    cDataGeneratorTitration GT = new cDataGeneratorTitration();
                    GT.NumberOfPoint = DRCNumberofPoints;
                    GT.Start = 5;
                    GT.DilutionFactor = 2;
                    GT.Run();


                    Random RND = new Random();

                    //cExtendedTable EXT = new cExtendedTable();
                    //EXT.ListRowNames = new List<string>();
                    //EXT.Name = "Quality fitting Report";
                    //EXT.Add(new cExtendedList("Noise Level"));
                    //EXT.Add(new cExtendedList("Original EC50"));
                    //EXT.Add(new cExtendedList("Estimated EC50"));
                    //EXT.Add(new cExtendedList("p-Value"));

                    for (int i = 0; i < NumberOfCurves; i++)
                    {
                        cExtendedTable FinalTable = new cExtendedTable();

                        cDataGeneratorSigmoid DGS = null;
                        DGS = new cDataGeneratorSigmoid();
                        DGS.SetInputData(GT.GetOutPut()[0]);
                        DGS.EC50 = RealEC50;// 0.01;// 1;// 0.1;// Math.Pow((double)10, -2);
                        DGS.Bottom = 0;
                        DGS.Top = 100;
                        DGS.Slope = 2;// TmpSlopeValue;//1;
                        DGS.Run();

                        cAddNoise AN = new cAddNoise();
                        AN.DistributionType = eRandDistributionType.GAUSSIAN;

                        double NoiseLevel = (i + 1) * 5;
                        //   EXT[0].Add(NoiseLevel);
                        //   EXT[1].Add(DGS.EC50);

                        #region loop over the replicates
                        for (int NumReplic = 0; NumReplic < NumberOfReplicate; NumReplic++)
                        {
                            //AN.Mean = 0;
                            //AN.Stdv = 10;

                            //AN.SetInputData(DGS.GetOutPut());
                            //AN.Run();

                            cExtendedList NewL = DGS.GetOutPut()[1];
                            for (int k = 0; k < NewL.Count; k++)
                            {
                                NewL[k] += RND.NextDouble() * NoiseLevel;
                            }

                            cExtendedTable TmpTable = new cExtendedTable();
                            TmpTable.Add(GT.GetOutPut()[0]);
                            TmpTable.Add(/*AN.GetOutPut()[1]*/NewL);

                            if (NumReplic >= 1)
                            {
                                cMerge M = new cMerge();
                                M.IsHorizontal = false;
                                M.SetInputData(TmpTable, FinalTable);
                                M.Run();
                                FinalTable = M.GetOutPut();
                            }
                            else
                                FinalTable = new cExtendedTable(TmpTable);

                        }
                        #endregion

                        //cListWell LW = new cListWell(null);
                        //foreach (cWell item in CompleteScreening.GetCurrentDisplayPlate().ListActiveWells)
                        //{
                        //    if (item.GetClassIdx() == 0)
                        //        LW.Add(item);
                        //}
                        //cExtendedTable ET = LW.GetDescriptorValues(CompleteScreening.ListDescriptors.GetActiveDescriptors(), true);


                        cCurveForGraph CFG = new cCurveForGraph();
                        CFG.SetInputData(FinalTable);
                        CFG.Run();

                        // compute ANOVA
                        cANOVA S = new cANOVA();
                        cExtendedTable NewTable = CFG.ListPtValues.Crop(0, CFG.ListPtValues.Count - 1, 1, CFG.ListPtValues[0].Count - 1);
                        S.SignificanceThreshold = 1E-11;
                        S.SetInputData(NewTable);
                        S.Run();

                        //cLinearRegression LR = new cLinearRegression();
                        //LR.SetInputData(FinalTable);
                        //LR.Run();

                        cSigmoidFitting SF = new cSigmoidFitting();
                        SF.SetInputData(FinalTable);
                        if (SF.Run().IsSucceed == false) continue;

                        // double Ratio = LR.GetOutPut()[0][LR.GetOutPut().Count - 1] / SF.GetOutPut()[0][SF.GetOutPut().Count - 1];


                        cExtendedTable Sigmoid = SF.GetFittedRawValues(GT.GetOutPut()[0]);
                        FinalTable[0] = Sigmoid[1];

                        cDesignerSplitter DS = new cDesignerSplitter();

                        ////cViewerTableAsRichText VT = new cViewerTableAsRichText();
                        cViewerTable VT = new cViewerTable();
                        cExtendedTable TableResults = SF.GetOutPut();
                        TableResults[0].Add(S.GetOutPut()[0][0]);

                        ListPValues.Add(S.GetOutPut()[0][0]);

                        TableResults[0].Add(S.GetOutPut()[0][1]);
                        TableResults.ListRowNames.Add("p-Value");
                        TableResults.ListRowNames.Add("Null hyp. rejected?");

                        VT.SetInputData(TableResults);
                        VT.DigitNumber = -1;
                        VT.Run();

                        cViewerGraph1D VS1 = new cViewerGraph1D();

                        VS1.SetInputData(new cExtendedTable(Sigmoid[1]));

                        VS1.AddCurve(CFG);

                        VS1.Chart.X_AxisValues = Sigmoid[0];//DGS.GetOutPut()[0];
                        VS1.Chart.IsLogAxis = true;
                        VS1.Chart.IsLine = true;
                        VS1.Chart.IsShadow = true;
                        VS1.Chart.Opacity = 210;
                        VS1.Chart.LineWidth = 3;

                        VS1.Chart.LabelAxisX = "Concentration";
                        VS1.Chart.LabelAxisY = "Readout";
                        VS1.Chart.XAxisFormatDigitNumber = -1;
                        VS1.Chart.IsZoomableX = true;

                        //Classes.Base_Classes.General.cLineVerticalForGraph VLForEC50 = new Classes.Base_Classes.General.cLineVerticalForGraph(SF.GetOutPut()[0][2]);
                        //VLForEC50.AddText("EC50: " + SF.GetOutPut()[0][2].ToString("e3")/* + "\nError Ratio:" + Ratio.ToString("N4")*/);
                        //VS1.Chart.ListVerticalLines.Add(VLForEC50);
                        //VS1.Chart.ArraySeriesInfo = new cSerieInfoDesign[FinalTable.Count];

                        //EXT[2].Add(SF.GetOutPut()[0][2]);
                        //EXT[3].Add(S.GetOutPut()[0][0]);

                        //for (int IdxCurve = 0; IdxCurve < FinalTable.Count; IdxCurve++)
                        //{
                        //    cSerieInfoDesign TmpSerieInfo = new cSerieInfoDesign();
                        //    TmpSerieInfo.color = Color.FromArgb(100, GlobalInfo.ListCellularPhenotypes[IdxCurve % GlobalInfo.ListCellularPhenotypes.Count].ColourForDisplay);

                        //    TmpSerieInfo.markerStyle = MarkerStyle.Circle;

                        //    VS1.Chart.ArraySeriesInfo[IdxCurve] = TmpSerieInfo;
                        //}

                        VS1.Run();

                        DS.SetInputData(VS1.GetOutPut());
                        DS.SetInputData(VT.GetOutPut());
                        DS.Orientation = Orientation.Horizontal;
                        DS.Title = "Noise Stdev " + NoiseLevel;
                        DS.Run();
                        DT.SetInputData(DS.GetOutPut());


                        //  EXT.ListRowNames.Add(DS.Title);

                    }

                    DT.Run();

                    //cDisplayToWindow DTW = new cDisplayToWindow();
                    //DTW.SetInputData(DT.GetOutPut());
                    //DTW.Run();
                    //DTW.Display();

                    //cDisplayExtendedTable DET = new cDisplayExtendedTable();
                    //DET.SetInputData(EXT);
                    //DET.DigitNumber = -1;
                    //DET.Run();  


                    FullResults.Add(ListPValues);
                }

            }

            cDisplayExtendedTable DET = new cDisplayExtendedTable();
            DET.SetInputData(FullResults);
            DET.DigitNumber = -1;
            DET.Run();

        }
Exemplo n.º 24
0
        private void aNOVAToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            cGUI_ListClasses GUI_ListClasses = new cGUI_ListClasses();
            GUI_ListClasses.IsCheckBoxes = true;
            GUI_ListClasses.IsSelectAll = true;


            if (GUI_ListClasses.Run().IsSucceed == false) return;
            cExtendedTable ListClassSelected = GUI_ListClasses.GetOutPut();

            string SubTitle = "ANOVA (One-Way)";


            #region single plate and plate by plate

            cDesignerTab DT = new cDesignerTab();
            if ((ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) || (ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                if ((ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
                {
                    foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                        ListPlatesToProcess.Add(TmpPlate);
                }
                else
                    ListPlatesToProcess.Add(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate());

                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cExtendedTable NewTable1 = new cExtendedTable();
                    List<cListWells> ListListWells = new List<cListWells>();


                    int NumWells = 0;

                    for (int IdxClassWell = 0; IdxClassWell < ListClassSelected[0].Count; IdxClassWell++)
                    {
                        if (ListClassSelected[0][IdxClassWell] >= 1)
                        {
                            List<cWellClassType> LCT = new List<cWellClassType>();
                            LCT.Add(cGlobalInfo.ListWellClasses[IdxClassWell]);

                            cListWells TmpList = TmpPlate.ListWells.Filter(LCT);

                            if (TmpList.Count >= 3)
                            {
                                ListListWells.Add(TmpList);
                                NumWells += TmpList.Count;
                            }
                        }
                    }

                    if (ListListWells.Count <= 1)
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }


                    cExtendedTable CompleteReport = null;
                    cExtendedList ListZ = new cExtendedList();
                    List<cDescriptorType> ListDescForZFactor = new List<cDescriptorType>();
                    List<string> ListNames = new List<string>();
                    int RealIdx = 0;
                    for (int IDxDesc = 0; IDxDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; IDxDesc++)
                    {
                        if (!cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc].IsActive()) continue;

                        cExtendedTable TableForZ = new cExtendedTable();

                        foreach (var item in ListListWells)
                        {
                            List<cDescriptorType> LType = new List<cDescriptorType>();
                            LType.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]);
                            cExtendedTable TTable = item.GetAverageDescriptorValues(LType, false, false);
                            TableForZ.Add(TTable[0]);
                        }
                        RealIdx++;

                        cANOVA ZF = new cANOVA();
                        ZF.SetInputData(TableForZ);
                        ZF.Run();
                        ListZ.Add(ZF.GetOutPut()[0][0]);

                        ZF.GetOutPut()[0].Name = cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc].GetName();

                        if (CompleteReport == null)
                            CompleteReport = new cExtendedTable(ZF.GetOutPut());
                        else
                        {
                            cMerge M = new cMerge();
                            M.IsHorizontal = true;
                            M.SetInputData(CompleteReport, ZF.GetOutPut());
                            M.Run();
                            CompleteReport = M.GetOutPut();
                        }

                        ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]);
                    }

                    cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
                    ET[0].ListTags = new List<object>();
                    ET[0].ListTags.AddRange(ListDescForZFactor);
                    ET.Name = TmpPlate.GetName() + "\n" + SubTitle + " - " + NumWells + " wells";// +" - " +cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " +cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[0].Count + " wells)";
                    ET[0].Name = ET.Name;

                    cSort S = new cSort();
                    S.SetInputData(ET);
                    S.IsAscending = false;
                    S.ColumnIndexForSorting = 0;
                    S.Run();

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

                    cViewerGraph1D VG1 = new cViewerGraph1D();
                    VG1.SetInputData(S.GetOutPut());

                    VG1.Chart.LabelAxisY = SubTitle;
                    VG1.Chart.LabelAxisX = "Descriptor";
                    VG1.Chart.IsZoomableX = true;
                    VG1.Chart.IsBar = true;
                    VG1.Chart.IsBorder = true;
                    VG1.Chart.IsDisplayValues = true;
                    VG1.Chart.IsShadow = true;
                    VG1.Chart.MarkerSize = 4;

                    //VG1.Chart.Max
                    VG1.Title = TmpPlate.GetName();

                    // Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.05);
                    // VLZ05.IsAllowMoving = true;
                    //  VG1.Chart.ListHorizontalLines.Add(VLZ05);

                    VG1.Run();

                    cDesignerSplitter DS = new cDesignerSplitter();
                    DS.Orientation = Orientation.Vertical;
                    DS.SetInputData(VG1.GetOutPut());


                    cTranspose T = new cTranspose();
                    T.SetInputData(CompleteReport);
                    T.Run();
                    CompleteReport = T.GetOutPut();
                    CompleteReport[0].Name = "P-Value";
                    CompleteReport[1].Name = "Is significant ?";

                    cSort S1 = new cSort();
                    S1.SetInputData(CompleteReport);
                    S1.ColumnIndexForSorting = 0;
                    S1.IsAscending = true;
                    S1.Run();



                    cViewerTable VT = new cViewerTable();
                    VT.SetInputData(S1.GetOutPut());
                    VT.DigitNumber = -1;
                    VT.Run();

                    DS.SetInputData(VT.GetOutPut());
                    DS.Title = TmpPlate.GetName();
                    DS.Run();

                    DT.SetInputData(DS.GetOutPut());
                }
                DT.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut());


                if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                    CDW.Title = SubTitle + " - " + ListPlatesToProcess[0].GetName();
                else
                    CDW.Title = SubTitle + " - " + ListPlatesToProcess.Count + " plates";

                CDW.Run();
                CDW.Display();
            }
            #endregion

            #region entire screening
            else if (ProcessModeEntireScreeningToolStripMenuItem.Checked)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                    ListPlatesToProcess.Add(TmpPlate);

                cExtendedList ListZ = new cExtendedList();
                List<cPlate> ListPlatesForZFactor = new List<cPlate>();
                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);
                    cListWells ListWellsToProcess2 = new cListWells(null);

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);
                            if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess2.Add(item);
                        }
                    }

                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor()));
                    cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor()));
                    //cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, false);

                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }

                    cExtendedTable TableForZ = new cExtendedTable();

                    TableForZ.Add(NewTable1[0]);
                    TableForZ.Add(NewTable2[0]);

                    cStudent_tTest ZF = new cStudent_tTest();
                    ZF.SetInputData(TableForZ);
                    ZF.Run();
                    double Zfactor = ZF.GetOutPut()[0][1];
                    ListZ.Add(Zfactor);

                    // update plate quality
                    //TmpPlate.ListProperties.UpdateValueByName("Quality", Math.Exp(Zfactor - 1));
                    //cProperty Prop = TmpPlate.ListProperties.FindByName("Quality");
                    //Prop.Info = ZF.GetInfo();

                    ListPlatesForZFactor.Add(TmpPlate);
                }


                cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
                ET[0].ListTags = new List<object>();
                ET[0].ListTags.AddRange(ListPlatesForZFactor);
                ET.Name = SubTitle + " - " + cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();// +" - " +cGlobalInfo.ListWellClasses[IdxClassNeg].Name + /*" (" + NewTable1[0].Count + " wells)*/ " vs. " +cGlobalInfo.ListWellClasses[IdxClassPos].Name;// +" (" + NewTable2[0].Count + " wells)";
                ET[0].Name = ET.Name;

                cViewerGraph1D VG1 = new cViewerGraph1D();
                VG1.SetInputData(ET);

                VG1.Chart.LabelAxisY = SubTitle;
                VG1.Chart.LabelAxisX = "Plate";
                VG1.Chart.IsZoomableX = true;
                VG1.Chart.IsBar = true;
                VG1.Chart.IsBorder = true;
                VG1.Chart.IsDisplayValues = true;
                VG1.Chart.IsShadow = true;
                VG1.Chart.MarkerSize = 4;



                VG1.Title = cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();
                VG1.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(VG1.GetOutPut());
                CDW.Title = SubTitle + " - " + ListPlatesToProcess.Count + " plates";
                CDW.Run();
                CDW.Display();
            #endregion
            }

        }
Exemplo n.º 25
0
        //public FormToDisplayTable()
        //{
        //    InitializeComponent();
        //}
        private void ReDraw()
        {
            cExtendedList ListX = new cExtendedList();
            cExtendedList ListY = new cExtendedList();

            if (this.comboBoxAxeY.SelectedIndex == -1) return;
            if (this.comboBoxVolume.SelectedIndex == -1) return;

            cExtendedList ListVolumes = new cExtendedList();

            for (int j = 0; j < dt.Rows.Count; j++)
            {

                ListX.Add(double.Parse(dt.Rows[j][this.comboBoxAxeX.SelectedIndex].ToString()));
                ListY.Add(double.Parse(dt.Rows[j][this.comboBoxAxeY.SelectedIndex].ToString()));
                ListVolumes.Add(double.Parse(dt.Rows[j][this.comboBoxVolume.SelectedIndex].ToString()));

            }

            this.chartForPoints.ChartAreas[0].AxisX.Title = this.comboBoxAxeX.SelectedItem.ToString();
            this.chartForPoints.ChartAreas[0].AxisY.Title = this.comboBoxAxeY.SelectedItem.ToString();

            this.chartForPoints.Series[0].Points.DataBindXY(ListX, ListY);

            if (!checkBoxIsVolumeConstant.Checked)
            {
                double MaxVolume = ListVolumes.Max();
                double MinVolume = ListVolumes.Min();

                for (int j = 0; j < dt.Rows.Count; j++)
                {

                    int MarkerArea = (int)((50 * (ListVolumes[j] - MinVolume)) / (MaxVolume - MinVolume));
                    this.chartForPoints.Series[0].Points[j].MarkerSize = MarkerArea;

                }
            }
        }
Exemplo n.º 26
0
        private void lDAToolStripMenuItem_Click(object sender, EventArgs e)
        {
            cGUI_ListClasses GUI_ListClasses = new cGUI_ListClasses();
            if (GUI_ListClasses.Run().IsSucceed == false) return;
            cExtendedList ListClassSelected = GUI_ListClasses.GetOutPut()[0];

            if (ListClassSelected.Sum() < 2)
            {
                MessageBox.Show("At least two classes have to be selected to perfom a LDA.", "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            cDisplayToWindow vD = new cDisplayToWindow();

            if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
            {
                cPlate TmpPlate = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate();
                cListWells ListWellsToProcess = new cListWells(null);
                cExtendedList ListClasses = new cExtendedList();
                ListClasses.Name = "Classes";
                foreach (cWell item in TmpPlate.ListActiveWells)
                    if ((item.GetCurrentClassIdx() != -1) && (ListClassSelected[item.GetCurrentClassIdx()] == 1))
                    {
                        ListWellsToProcess.Add(item);
                        ListClasses.Add(item.GetCurrentClassIdx());
                    }

                cExtendedTable NewTable = new cExtendedTable(ListWellsToProcess, true);
                NewTable.Add(ListClasses);

                cProjectorLDA LDA = new cProjectorLDA();
                LDA.SetInputData(NewTable);
                cFeedBackMessage FM = LDA.Run();
                if (!FM.IsSucceed)
                {
                    MessageBox.Show(FM.Message, "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                cViewerTable VHM = new cViewerTable();
                cExtendedTable CT = LDA.GetOutPut();

                foreach (var item in CT)
                {
                    cDescriptorsLinearCombination DLC = new cDescriptorsLinearCombination(item);
                    foreach (cDescriptorType Desc in item.ListTags)
                        DLC.Add(Desc);
                    item.Tag = DLC;
                }
                VHM.SetInputData(CT);
                VHM.Run();

                vD.SetInputData(VHM.GetOutPut());
                vD.Title = "LDA - " + TmpPlate.GetName() + " : " + ListWellsToProcess.Count + " wells";
            }
            else if (ProcessModeEntireScreeningToolStripMenuItem.Checked)
            {
                cListWells ListWellsToProcess = new cListWells(null);
                cExtendedList ListClasses = new cExtendedList();
                ListClasses.Name = "Classes";

                foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                {
                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[item.GetCurrentClassIdx()] == 1)
                            {
                                ListWellsToProcess.Add(item);
                                ListClasses.Add(item.GetCurrentClassIdx());
                            }
                        }
                    }
                }

                cExtendedTable NewTable = new cExtendedTable(ListWellsToProcess, true);
                NewTable.Add(ListClasses);
                cProjectorLDA LDA = new cProjectorLDA();
                LDA.SetInputData(NewTable);
                cFeedBackMessage FM = LDA.Run();
                if (!FM.IsSucceed)
                {
                    MessageBox.Show(FM.Message, "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                cExtendedTable CT = LDA.GetOutPut();

                foreach (var item in CT)
                {
                    cDescriptorsLinearCombination DLC = new cDescriptorsLinearCombination(item);

                    foreach (cDescriptorType Desc in item.ListTags)
                        DLC.Add(Desc);

                    item.Tag = DLC;
                }

                cViewerTable VHM = new cViewerTable();
                VHM.SetInputData(CT);

                VHM.Run();

                vD.SetInputData(VHM.GetOutPut());
                vD.Title = "LDA - " + ListWellsToProcess.Count + " wells.";
            }
            else if (ProcessModeplateByPlateToolStripMenuItem.Checked)
            {
                cDesignerTab CDT = new cDesignerTab();

                foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                {
                    cListWells ListWellsToProcess = new cListWells(null);
                    cExtendedList ListClasses = new cExtendedList();
                    ListClasses.Name = "Classes";


                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[item.GetCurrentClassIdx()] == 1)
                            {
                                ListWellsToProcess.Add(item);
                                ListClasses.Add(item.GetCurrentClassIdx());
                            }
                        }
                    }

                    cExtendedTable NewTable = new cExtendedTable(ListWellsToProcess, true);
                    NewTable.Add(ListClasses);
                    NewTable.Name = TmpPlate.GetName();

                    cProjectorLDA LDA = new cProjectorLDA();
                    LDA.SetInputData(NewTable);
                    cFeedBackMessage FM = LDA.Run();
                    if (!FM.IsSucceed)
                    {
                        MessageBox.Show(FM.Message, "Error !", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    cExtendedTable CT = LDA.GetOutPut();

                    foreach (var item in CT)
                    {
                        cDescriptorsLinearCombination DLC = new cDescriptorsLinearCombination(item);

                        foreach (cDescriptorType Desc in item.ListTags)
                            DLC.Add(Desc);

                        item.Tag = DLC;
                    }

                    cViewerTable VHM = new cViewerTable();
                    VHM.SetInputData(CT);
                    VHM.Run();
                    CDT.SetInputData(VHM.GetOutPut());
                }
                CDT.Run();
                vD.SetInputData(CDT.GetOutPut());
            }
            else
                return;

            vD.Run();
            vD.Display();
        }
Exemplo n.º 27
0
        private void zScoreToolStripMenuItem_Click(object sender, EventArgs e)
        {
            #region obsolete
            //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.GetClassIdx() == 0)
            //                    Pos.Add(TempWell.ListDescriptors[Desc].GetValue());
            //                if (TempWell.GetClassIdx() == 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 = ZFactorList[IdxValue].AverageValue.ToString("N2");
            //    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;

            //CurrentChartArea.AxisX.ScaleView.Zoomable = true;
            //CurrentChartArea.AxisY.ScaleView.Zoomable = true;

            //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.AutoScroll = true;
            //NewWindow.Controls.AddRange(new System.Windows.Forms.Control[] { NewWindow.chartForSimpleForm });
            #endregion


            cGUI_2ClassesSelection GUI_ListClasses = new cGUI_2ClassesSelection();
            if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
            {
                GUI_ListClasses.PanelRight_IsCheckBoxes = true;
            }


            if (GUI_ListClasses.Run(this.GlobalInfo).IsSucceed == false) return;
            cExtendedTable ListClassSelected = GUI_ListClasses.GetOutPut();

            int IdxClassNeg = -1;
            int IdxClassPos = -1;
            for (int IdxC = 0; IdxC < ListClassSelected[0].Count; IdxC++)
            {
                if (ListClassSelected[0][IdxC] == 1) IdxClassNeg = IdxC;
                if (ListClassSelected[1][IdxC] == 1) IdxClassPos = IdxC;
            }

            string SubTitle = "Z-Factor";

            if (_QCZRobustItem.Checked)
                SubTitle += " (Robust)";


            #region Single plate
            cDesignerTab DT = new cDesignerTab();
            //   cDesignerMultiChoices DT = new cDesignerMultiChoices();
            if ((ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();

                cPlate TmpPlate = cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate();

                // foreach (cPlate TmpPlate in ListPlatesToProcess)
                // GUI_ListClasses.Get
                // ListClassSelected

                List<int> ListCheckBoxes = new List<int>();
                for (int i = 0; i < ListClassSelected[1].Count; i++)
                {
                    if (ListClassSelected[1][i] > 0)
                        ListCheckBoxes.Add(i);
                }

                for (int IdxClassSelected = 0; IdxClassSelected < ListCheckBoxes.Count; IdxClassSelected++)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);
                    cListWells ListWellsToProcess2 = new cListWells(null);

                    int CurrentClassTobeProcessed = ListCheckBoxes[IdxClassSelected];

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);

                            if (item.GetCurrentClassIdx() == CurrentClassTobeProcessed)
                                //                            if (ListClassSelected[1][ListCheckBoxes[IdxClassSelected]] == 1)
                                ListWellsToProcess2.Add(item);
                        }
                    }

                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true);
                    cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, true);

                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        //else
                        //    continue;
                    }

                    cExtendedList ListZ = new cExtendedList();
                    List<cDescriptorType> ListDescForZFactor = new List<cDescriptorType>();
                    List<string> ListNames = new List<string>();
                    int RealIdx = 0;
                    for (int IDxDesc = 0; IDxDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; IDxDesc++)
                    {
                        if (!cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc].IsActive()) continue;

                        cExtendedTable TableForZ = new cExtendedTable();

                        TableForZ.Add(NewTable1[RealIdx]);
                        TableForZ.Add(NewTable2[RealIdx]);
                        RealIdx++;

                        cZFactor ZF = new cZFactor();
                        ZF.SetInputData(TableForZ);
                        ZF.IsRobust = _QCZRobustItem.Checked;
                        ZF.Run();
                        ListZ.Add(ZF.GetOutPut()[0][1]);

                        ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]);

                    }

                    cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
                    ET[0].ListTags = new List<object>();
                    ET[0].ListTags.AddRange(ListDescForZFactor);
                    ET.Name = TmpPlate.GetName() + "\n" + SubTitle + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " + cGlobalInfo.ListWellClasses[CurrentClassTobeProcessed].Name + " (" + NewTable2[0].Count + " wells)";
                    ET[0].Name = ET.Name;

                    cSort S = new cSort();
                    S.SetInputData(ET);
                    S.ColumnIndexForSorting = 0;
                    S.Run();

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

                    cViewerGraph1D VG1 = new cViewerGraph1D();
                    VG1.SetInputData(S.GetOutPut());

                    VG1.Chart.LabelAxisY = SubTitle;
                    VG1.Chart.LabelAxisX = "Descriptor";
                    VG1.Chart.IsZoomableX = true;
                    VG1.Chart.IsBar = true;
                    VG1.Chart.IsBorder = true;
                    VG1.Chart.IsDisplayValues = true;
                    VG1.Chart.IsShadow = true;
                    VG1.Chart.MarkerSize = 4;
                    VG1.Chart.DefaultAxisYMax = new cExtendedList();
                    VG1.Chart.DefaultAxisYMax.Add(1);

                    if (!cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxZscoreMinValueAutomated.Checked)
                    {
                        VG1.Chart.DefaultAxisYMin = new cExtendedList();
                        VG1.Chart.DefaultAxisYMin.Add((double)cGlobalInfo.OptionsWindow.FFAllOptions.numericUpDownZscoreMinValue.Value);
                    }

                    VG1.Title = TmpPlate.GetName();

                    Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.5);
                    VLZ05.IsAllowMoving = true;
                    VG1.Chart.ListHorizontalLines.Add(VLZ05);

                    VG1.Run();

                    cDesignerSplitter DS = new cDesignerSplitter();
                    DS.Orientation = Orientation.Vertical;
                    DS.SetInputData(VG1.GetOutPut());

                    cSort S1 = new cSort();
                    S1.SetInputData(ET);
                    S1.ColumnIndexForSorting = 0;
                    S1.IsAscending = false;
                    S1.Run();

                    cViewerTable VT = new cViewerTable();
                    VT.SetInputData(S1.GetOutPut());
                    VT.Run();

                    DS.SetInputData(VT.GetOutPut());
                    DS.Title = cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " vs. " + cGlobalInfo.ListWellClasses[CurrentClassTobeProcessed].Name;
                    DS.Run();

                    DT.SetInputData(DS.GetOutPut());
                }
                DT.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut());



                CDW.Title = SubTitle + " - " + TmpPlate.GetName();


                CDW.Run();
                CDW.Display();
            }

            #endregion

            #region plate by plate

            DT = new cDesignerTab();
            //   cDesignerMultiChoices DT = new cDesignerMultiChoices();
            if ((ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                if ((ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
                {
                    foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                        ListPlatesToProcess.Add(TmpPlate);
                }


                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);
                    cListWells ListWellsToProcess2 = new cListWells(null);

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);
                            if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess2.Add(item);
                        }
                    }

                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true);
                    cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, true);

                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }

                    cExtendedList ListZ = new cExtendedList();
                    List<cDescriptorType> ListDescForZFactor = new List<cDescriptorType>();
                    List<string> ListNames = new List<string>();
                    int RealIdx = 0;
                    for (int IDxDesc = 0; IDxDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; IDxDesc++)
                    {
                        if (!cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc].IsActive()) continue;

                        cExtendedTable TableForZ = new cExtendedTable();

                        TableForZ.Add(NewTable1[RealIdx]);
                        TableForZ.Add(NewTable2[RealIdx]);
                        RealIdx++;

                        cZFactor ZF = new cZFactor();
                        ZF.SetInputData(TableForZ);
                        ZF.IsRobust = _QCZRobustItem.Checked;
                        ZF.Run();
                        ListZ.Add(ZF.GetOutPut()[0][1]);

                        ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]);

                    }

                    cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
                    ET[0].ListTags = new List<object>();
                    ET[0].ListTags.AddRange(ListDescForZFactor);
                    ET.Name = TmpPlate.GetName() + "\n" + SubTitle + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " + cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[0].Count + " wells)";
                    ET[0].Name = ET.Name;

                    cSort S = new cSort();
                    S.SetInputData(ET);
                    S.ColumnIndexForSorting = 0;
                    S.Run();

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

                    cViewerGraph1D VG1 = new cViewerGraph1D();
                    VG1.SetInputData(S.GetOutPut());

                    VG1.Chart.LabelAxisY = SubTitle;
                    VG1.Chart.LabelAxisX = "Descriptor";
                    VG1.Chart.IsZoomableX = true;
                    VG1.Chart.IsBar = true;
                    VG1.Chart.IsBorder = true;
                    VG1.Chart.IsDisplayValues = true;
                    VG1.Chart.IsShadow = true;
                    VG1.Chart.MarkerSize = 4;
                    VG1.Chart.DefaultAxisYMax = new cExtendedList();
                    VG1.Chart.DefaultAxisYMax.Add(1);

                    if (!cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxZscoreMinValueAutomated.Checked)
                    {
                        VG1.Chart.DefaultAxisYMin = new cExtendedList();
                        VG1.Chart.DefaultAxisYMin.Add((double)cGlobalInfo.OptionsWindow.FFAllOptions.numericUpDownZscoreMinValue.Value);
                    }

                    VG1.Title = TmpPlate.GetName();

                    Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.5);
                    VLZ05.IsAllowMoving = true;
                    VG1.Chart.ListHorizontalLines.Add(VLZ05);

                    VG1.Run();

                    cDesignerSplitter DS = new cDesignerSplitter();
                    DS.Orientation = Orientation.Vertical;
                    DS.SetInputData(VG1.GetOutPut());

                    cSort S1 = new cSort();
                    S1.SetInputData(ET);
                    S1.ColumnIndexForSorting = 0;
                    S1.IsAscending = false;
                    S1.Run();

                    cViewerTable VT = new cViewerTable();
                    VT.SetInputData(S1.GetOutPut());
                    VT.Run();

                    DS.SetInputData(VT.GetOutPut());
                    DS.Title = TmpPlate.GetName();
                    DS.Run();

                    DT.SetInputData(DS.GetOutPut());
                }
                DT.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut());



                CDW.Title = SubTitle + " - " + ListPlatesToProcess.Count + " plates";

                CDW.Run();
                CDW.Display();
            }
            #endregion

            #region entire screening
            else if (ProcessModeEntireScreeningToolStripMenuItem.Checked)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                    ListPlatesToProcess.Add(TmpPlate);

                cExtendedList ListZ = new cExtendedList();
                List<cPlate> ListPlatesForZFactor = new List<cPlate>();
                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);
                    cListWells ListWellsToProcess2 = new cListWells(null);

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);
                            if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess2.Add(item);
                        }
                    }

                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor()));
                    cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor()));
                    //cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, false);

                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }

                    cExtendedTable TableForZ = new cExtendedTable();

                    TableForZ.Add(NewTable1[0]);
                    TableForZ.Add(NewTable2[0]);

                    cZFactor ZF = new cZFactor();
                    ZF.IsRobust = _QCZRobustItem.Checked;
                    ZF.SetInputData(TableForZ);
                    ZF.Run();
                    double Zfactor = ZF.GetOutPut()[0][1];
                    ListZ.Add(Zfactor);

                    // update plate quality
                    TmpPlate.ListProperties.UpdateValueByName("Quality", Math.Exp(Zfactor - 1));
                    cProperty Prop = TmpPlate.ListProperties.FindByName("Quality");
                    Prop.Info = ZF.GetInfo();

                    ListPlatesForZFactor.Add(TmpPlate);
                }


                cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
                ET[0].ListTags = new List<object>();
                ET[0].ListTags.AddRange(ListPlatesForZFactor);
                ET.Name = SubTitle + " - " + cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName() + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + /*" (" + NewTable1[0].Count + " wells)*/ " vs. " + cGlobalInfo.ListWellClasses[IdxClassPos].Name;// +" (" + NewTable2[0].Count + " wells)";
                ET[0].Name = ET.Name;

                cViewerGraph1D VG1 = new cViewerGraph1D();
                VG1.SetInputData(ET);

                VG1.Chart.LabelAxisY = SubTitle;
                VG1.Chart.LabelAxisX = "Plate";
                VG1.Chart.IsZoomableX = true;
                VG1.Chart.IsBar = true;
                VG1.Chart.IsBorder = true;
                VG1.Chart.IsDisplayValues = true;
                VG1.Chart.IsShadow = true;
                VG1.Chart.MarkerSize = 4;
                VG1.Chart.DefaultAxisYMax = new cExtendedList();
                VG1.Chart.DefaultAxisYMax.Add(1);

                if (!cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxZscoreMinValueAutomated.Checked)
                {
                    VG1.Chart.DefaultAxisYMin = new cExtendedList();
                    VG1.Chart.DefaultAxisYMin.Add((double)cGlobalInfo.OptionsWindow.FFAllOptions.numericUpDownZscoreMinValue.Value);
                }


                Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.5);
                VLZ05.IsAllowMoving = true;
                VG1.Chart.ListHorizontalLines.Add(VLZ05);

                VG1.Title = cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();
                VG1.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(VG1.GetOutPut());
                CDW.Title = SubTitle + " - " + ListPlatesToProcess.Count + " plates";
                CDW.Run();
                CDW.Display();
            #endregion
            }
        }
Exemplo n.º 28
0
        private void ToolStripMenuItem_ZFactor(object sender, EventArgs e)
        {
            cGUI_2ClassesSelection GUI_ListClasses = new cGUI_2ClassesSelection();

            if (GUI_ListClasses.Run(this.GlobalInfo).IsSucceed == false) return;
            cExtendedTable ListClassSelected = GUI_ListClasses.GetOutPut();

            int IdxClassNeg = -1;
            int IdxClassPos = -1;
            for (int IdxC = 0; IdxC < ListClassSelected[0].Count; IdxC++)
            {
                if (ListClassSelected[0][IdxC] == 1) IdxClassNeg = IdxC;
                if (ListClassSelected[1][IdxC] == 1) IdxClassPos = IdxC;
            }

            string SubTitle = "Z-Factor";
            cListWells ListWellsToProcess1 = new cListWells(null);
            cListWells ListWellsToProcess2 = new cListWells(null);

            foreach (cWell item in cGlobalInfo.ListSelectedWell)
            {
                if (item.GetCurrentClassIdx() != -1)
                {
                    if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                        ListWellsToProcess1.Add(item);
                    if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1)
                        ListWellsToProcess2.Add(item);
                }
            }

            cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true);
            cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, true);

            if ((NewTable1.Count == 0) || (NewTable1[0].Count < 2) || (NewTable2.Count == 0) || (NewTable2[0].Count < 2))
            {
                if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                {
                    MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            cExtendedList ListZ = new cExtendedList();
            List<cDescriptorType> ListDescForZFactor = new List<cDescriptorType>();
            List<string> ListNames = new List<string>();
            int RealIdx = 0;
            for (int IDxDesc = 0; IDxDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; IDxDesc++)
            {
                if (!cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc].IsActive()) continue;

                cExtendedTable TableForZ = new cExtendedTable();

                TableForZ.Add(NewTable1[RealIdx]);
                TableForZ.Add(NewTable2[RealIdx]);
                RealIdx++;

                cZFactor ZF = new cZFactor();
                ZF.SetInputData(TableForZ);
                ZF.IsRobust = _QCZRobustItem.Checked;
                ZF.Run();
                ListZ.Add(ZF.GetOutPut()[0][1]);

                ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]);
            }

            cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
            ET[0].ListTags = new List<object>();
            ET[0].ListTags.AddRange(ListDescForZFactor);
            ET.Name = SubTitle + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " + cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[0].Count + " wells)";
            ET[0].Name = ET.Name;

            cSort S = new cSort();
            S.SetInputData(ET);
            S.ColumnIndexForSorting = 0;
            S.Run();

            cViewerGraph1D VG1 = new cViewerGraph1D();
            VG1.SetInputData(S.GetOutPut());

            VG1.Chart.LabelAxisY = SubTitle;
            VG1.Chart.LabelAxisX = "Descriptor";
            VG1.Chart.IsZoomableX = true;
            VG1.Chart.IsBar = true;
            VG1.Chart.IsBorder = true;
            VG1.Chart.IsDisplayValues = true;
            VG1.Chart.IsShadow = true;
            VG1.Chart.MarkerSize = 4;
            VG1.Chart.DefaultAxisYMax = new cExtendedList();
            VG1.Chart.DefaultAxisYMax.Add(1);
            //VG1.Title = TmpPlate.Name;

            Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.5);
            VLZ05.IsAllowMoving = true;
            VG1.Chart.ListHorizontalLines.Add(VLZ05);

            VG1.Run();

            cDesignerSplitter DS = new cDesignerSplitter();
            DS.Orientation = Orientation.Vertical;
            DS.SetInputData(VG1.GetOutPut());

            cSort S1 = new cSort();
            S1.SetInputData(ET);
            S1.ColumnIndexForSorting = 0;
            S1.IsAscending = false;
            S1.Run();

            cViewerTable VT = new cViewerTable();
            VT.SetInputData(S1.GetOutPut());
            VT.Run();

            DS.SetInputData(VT.GetOutPut());
            DS.Run();

            cDisplayToWindow CDW = new cDisplayToWindow();
            CDW.SetInputData(DS.GetOutPut());//VG1.GetOutPut());

            CDW.Title = "List Wells - Z Factor";
            CDW.Run();
            CDW.Display();
        }
Exemplo n.º 29
0
        private void statisticsToolStripMenuItem1_Click_1(object sender, EventArgs e)
        {
            string NameFunction = "";

            if (_StatCVItem.Checked)
                NameFunction = "Coeff. of Variation";
            else if (_StatMeanItem.Checked)
                NameFunction = "Mean";
            else if (_StatSumItem.Checked)
                NameFunction = "Sum";
            else if (_StatJarqueBeraItem.Checked)
                NameFunction = "Jarque-Bera";

            cGUI_ListClasses GUI_ListClasses = new cGUI_ListClasses();

            GUI_ListClasses.IsCheckBoxes = true;
            GUI_ListClasses.IsSelectAll = true;

            if (GUI_ListClasses.Run().IsSucceed == false) return;
            cExtendedTable ListClassSelected = new cExtendedTable(GUI_ListClasses.GetOutPut());// GetOutPut();


            int IdxClass = -1;
            for (int IdxC = 0; IdxC < ListClassSelected[0].Count; IdxC++)
            {
                if (ListClassSelected[0][IdxC] == 1) IdxClass = IdxC;
            }

            #region single plate and plate by plate

            cDesignerTab DT = new cDesignerTab();
            if ((ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) || (ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                if ((ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
                {
                    foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                        ListPlatesToProcess.Add(TmpPlate);
                }
                else
                    ListPlatesToProcess.Add(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate());

                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);
                        }
                    }

                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true);

                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 3))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }

                    cExtendedList ListValues = new cExtendedList();
                    List<cDescriptorType> ListDescs = new List<cDescriptorType>();
                    List<string> ListNames = new List<string>();
                    int RealIdx = 0;
                    for (int IDxDesc = 0; IDxDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; IDxDesc++)
                    {
                        if (!cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc].IsActive()) continue;

                        cExtendedTable TableForValues = new cExtendedTable();

                        TableForValues.Add(NewTable1[RealIdx]);

                        RealIdx++;

                        if (_StatJarqueBeraItem.Checked)
                        {
                            cNormalityJarqueBera JB = new cNormalityJarqueBera();
                            JB.SetInputData(TableForValues);
                            JB.Run();
                            ListValues.Add(JB.GetOutPut()[0][0]);
                        }
                        else
                        {
                            cStatistics CS = new cStatistics();
                            CS.UnselectAll();

                            if (_StatCVItem.Checked)
                                CS.IsCV = true;
                            else if (_StatMeanItem.Checked)
                                CS.IsMean = true;
                            else if (_StatSumItem.Checked)
                                CS.IsSum = true;

                            CS.SetInputData(TableForValues);
                            CS.Run();
                            ListValues.Add(CS.GetOutPut()[0][0]);
                        }

                        ListDescs.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]);

                    }

                    cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListValues));
                    ET[0].ListTags = new List<object>();
                    ET[0].ListTags.AddRange(ListDescs);
                    ET.Name = TmpPlate.GetName() + "\n" + NameFunction + " - " + cGlobalInfo.ListWellClasses[IdxClass].Name + " (" + NewTable1[0].Count + " wells)";
                    ET[0].Name = ET.Name;

                    cSort S = new cSort();
                    S.SetInputData(ET);
                    S.ColumnIndexForSorting = 0;
                    S.Run();

                    //ZFactorList.Sort(delegate(cSimpleSignature p1, cSimpleSignature p2) { return p1.AverageValue.CompareTo(p2.AverageValue); });
                    cViewerGraph1D VG1 = new cViewerGraph1D();
                    VG1.SetInputData(S.GetOutPut());

                    VG1.Chart.LabelAxisY = NameFunction;
                    VG1.Chart.LabelAxisX = "Descriptor";
                    VG1.Chart.IsZoomableX = true;
                    VG1.Chart.IsBar = true;
                    VG1.Chart.IsBorder = true;
                    VG1.Chart.IsDisplayValues = true;
                    VG1.Chart.IsShadow = true;
                    VG1.Chart.MarkerSize = 4;
                    VG1.Title = TmpPlate.GetName();
                    VG1.Run();

                    DT.SetInputData(VG1.GetOutPut());
                }
                DT.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut());


                if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                    CDW.Title = NameFunction + " - " + ListPlatesToProcess[0].GetName();
                else
                    CDW.Title = NameFunction + " - " + ListPlatesToProcess.Count + " plates";

                CDW.Run();
                CDW.Display();
            }
            #endregion
            #region entire screening
            else if (ProcessModeEntireScreeningToolStripMenuItem.Checked)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                    ListPlatesToProcess.Add(TmpPlate);

                cExtendedList ListZ = new cExtendedList();
                List<cPlate> ListPlatesForZFactor = new List<cPlate>();
                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);
                        }
                    }


                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor()));


                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 3))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }


                    if (_StatJarqueBeraItem.Checked)
                    {
                        cNormalityJarqueBera JB = new cNormalityJarqueBera();
                        JB.SetInputData(NewTable1);
                        JB.Run();
                        ListZ.Add(JB.GetOutPut()[0][0]);
                    }
                    else
                    {
                        cStatistics CS = new cStatistics();
                        CS.UnselectAll();

                        if (_StatCVItem.Checked)
                            CS.IsCV = true;
                        else if (_StatMeanItem.Checked)
                            CS.IsMean = true;
                        else if (_StatSumItem.Checked)
                            CS.IsSum = true;

                        CS.SetInputData(NewTable1);
                        CS.Run();
                        ListZ.Add(CS.GetOutPut()[0][0]);
                    }
                    ListPlatesForZFactor.Add(TmpPlate);
                }
            #endregion

                cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
                ET[0].ListTags = new List<object>();
                ET[0].ListTags.AddRange(ListPlatesForZFactor);
                ET.Name = NameFunction + " - " + cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();// +" - " +cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " +cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[0].Count + " wells)";
                ET[0].Name = ET.Name;

                cViewerGraph1D VG1 = new cViewerGraph1D();
                VG1.SetInputData(ET);

                VG1.Chart.LabelAxisY = NameFunction;
                VG1.Chart.LabelAxisX = "Plate";
                VG1.Chart.IsZoomableX = true;
                VG1.Chart.IsBar = true;
                VG1.Chart.IsBorder = true;
                VG1.Chart.IsDisplayValues = true;
                VG1.Chart.IsShadow = true;
                VG1.Chart.MarkerSize = 4;
                VG1.Title = cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();
                VG1.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(VG1.GetOutPut());
                CDW.Title = NameFunction + " - " + ListPlatesToProcess.Count + " plates";
                CDW.Run();
                CDW.Display();
            }
        }
Exemplo n.º 30
0
        private void mannWithneyTestToolStripMenuItem_Click(object sender, EventArgs e)
        {
            cGUI_2ClassesSelection GUI_ListClasses = new cGUI_2ClassesSelection();

            if (GUI_ListClasses.Run(this.GlobalInfo).IsSucceed == false) return;
            cExtendedTable ListClassSelected = GUI_ListClasses.GetOutPut();

            int IdxClassNeg = -1;
            int IdxClassPos = -1;
            for (int IdxC = 0; IdxC < ListClassSelected[0].Count; IdxC++)
            {
                if (ListClassSelected[0][IdxC] == 1) IdxClassNeg = IdxC;
                if (ListClassSelected[1][IdxC] == 1) IdxClassPos = IdxC;
            }

            string SubTitle = "Mann-Withney (both tails)";


            #region single plate and plate by plate

            cDesignerTab DT = new cDesignerTab();
            if ((ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked) || (ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                if ((ProcessModeplateByPlateToolStripMenuItem.Checked)/*||(ProcessModeEntireScreeningToolStripMenuItem.Checked)*/)
                {
                    foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                        ListPlatesToProcess.Add(TmpPlate);
                }
                else
                    ListPlatesToProcess.Add(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate());

                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);
                    cListWells ListWellsToProcess2 = new cListWells(null);

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);
                            if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess2.Add(item);
                        }
                    }

                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, true);
                    cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, true);

                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 5) || (NewTable2.Count == 0) || (NewTable2[0].Count < 5))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }

                    cExtendedList ListZ = new cExtendedList();
                    List<cDescriptorType> ListDescForZFactor = new List<cDescriptorType>();
                    List<string> ListNames = new List<string>();
                    int RealIdx = 0;
                    for (int IDxDesc = 0; IDxDesc < cGlobalInfo.CurrentScreening.ListDescriptors.Count; IDxDesc++)
                    {
                        if (!cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc].IsActive()) continue;

                        cExtendedTable TableForZ = new cExtendedTable();

                        TableForZ.Add(NewTable1[RealIdx]);
                        TableForZ.Add(NewTable2[RealIdx]);
                        RealIdx++;

                        cMannWithneyTest ZF = new cMannWithneyTest();
                        ZF.SetInputData(TableForZ);
                        ZF.Run();
                        ListZ.Add(ZF.GetOutPut()[0][1]);

                        ListDescForZFactor.Add(cGlobalInfo.CurrentScreening.ListDescriptors[IDxDesc]);

                    }

                    cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
                    ET[0].ListTags = new List<object>();
                    ET[0].ListTags.AddRange(ListDescForZFactor);
                    ET.Name = TmpPlate.GetName() + "\n" + SubTitle + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + " (" + NewTable1[0].Count + " wells) vs. " + cGlobalInfo.ListWellClasses[IdxClassPos].Name + " (" + NewTable2[0].Count + " wells)";
                    ET[0].Name = ET.Name;

                    cSort S = new cSort();
                    S.SetInputData(ET);
                    S.ColumnIndexForSorting = 0;
                    S.Run();

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

                    cViewerGraph1D VG1 = new cViewerGraph1D();
                    VG1.SetInputData(S.GetOutPut());

                    VG1.Chart.LabelAxisY = SubTitle;
                    VG1.Chart.LabelAxisX = "Descriptor";
                    VG1.Chart.IsZoomableX = true;
                    VG1.Chart.IsBar = true;
                    VG1.Chart.IsBorder = true;
                    VG1.Chart.IsDisplayValues = true;
                    VG1.Chart.IsShadow = true;
                    VG1.Chart.MarkerSize = 4;

                    //VG1.Chart.Max
                    VG1.Title = TmpPlate.GetName();

                    Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.05);
                    VLZ05.IsAllowMoving = true;
                    VG1.Chart.ListHorizontalLines.Add(VLZ05);

                    VG1.Run();

                    cDesignerSplitter DS = new cDesignerSplitter();
                    DS.Orientation = Orientation.Vertical;
                    DS.SetInputData(VG1.GetOutPut());

                    cSort S1 = new cSort();
                    S1.SetInputData(ET);
                    S1.ColumnIndexForSorting = 0;
                    S1.IsAscending = false;
                    S1.Run();

                    cViewerTable VT = new cViewerTable();
                    VT.SetInputData(S1.GetOutPut());
                    VT.DigitNumber = -1;
                    VT.Run();

                    DS.SetInputData(VT.GetOutPut());
                    DS.Title = TmpPlate.GetName();
                    DS.Run();

                    DT.SetInputData(DS.GetOutPut());
                }
                DT.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(DT.GetOutPut());//VG1.GetOutPut());


                if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                    CDW.Title = SubTitle + " - " + ListPlatesToProcess[0].GetName();
                else
                    CDW.Title = SubTitle + " - " + ListPlatesToProcess.Count + " plates";

                CDW.Run();
                CDW.Display();
            }
            #endregion

            #region entire screening
            else if (ProcessModeEntireScreeningToolStripMenuItem.Checked)
            {
                List<cPlate> ListPlatesToProcess = new List<cPlate>();
                foreach (cPlate TmpPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                    ListPlatesToProcess.Add(TmpPlate);

                cExtendedList ListZ = new cExtendedList();
                List<cPlate> ListPlatesForZFactor = new List<cPlate>();
                foreach (cPlate TmpPlate in ListPlatesToProcess)
                {
                    cListWells ListWellsToProcess1 = new cListWells(null);
                    cListWells ListWellsToProcess2 = new cListWells(null);

                    foreach (cWell item in TmpPlate.ListActiveWells)
                    {
                        if (item.GetCurrentClassIdx() != -1)
                        {
                            if (ListClassSelected[0][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess1.Add(item);
                            if (ListClassSelected[1][item.GetCurrentClassIdx()] == 1)
                                ListWellsToProcess2.Add(item);
                        }
                    }

                    cExtendedTable NewTable1 = new cExtendedTable(ListWellsToProcess1, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor()));
                    cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, cGlobalInfo.CurrentScreening.ListDescriptors.GetDescriptorIndex(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor()));
                    //cExtendedTable NewTable2 = new cExtendedTable(ListWellsToProcess2, false);

                    if ((NewTable1.Count == 0) || (NewTable1[0].Count < 5) || (NewTable2.Count == 0) || (NewTable2[0].Count < 5))
                    {
                        if (ProcessModeCurrentPlateOnlyToolStripMenuItem.Checked)
                        {
                            MessageBox.Show("Insufficient number of control wells", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        else
                            continue;
                    }

                    cExtendedTable TableForZ = new cExtendedTable();

                    TableForZ.Add(NewTable1[0]);
                    TableForZ.Add(NewTable2[0]);

                    cMannWithneyTest ZF = new cMannWithneyTest();
                    ZF.SetInputData(TableForZ);
                    ZF.Run();
                    double Zfactor = ZF.GetOutPut()[0][1];
                    ListZ.Add(Zfactor);

                    // update plate quality
                    //TmpPlate.ListProperties.UpdateValueByName("Quality", Math.Exp(Zfactor - 1));
                    //cProperty Prop = TmpPlate.ListProperties.FindByName("Quality");
                    //Prop.Info = ZF.GetInfo();

                    ListPlatesForZFactor.Add(TmpPlate);
                }


                cExtendedTable ET = new cExtendedTable(new cExtendedTable(ListZ));
                ET[0].ListTags = new List<object>();
                ET[0].ListTags.AddRange(ListPlatesForZFactor);
                ET.Name = SubTitle + " - " + cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName() + " - " + cGlobalInfo.ListWellClasses[IdxClassNeg].Name + /*" (" + NewTable1[0].Count + " wells)*/ " vs. " + cGlobalInfo.ListWellClasses[IdxClassPos].Name;// +" (" + NewTable2[0].Count + " wells)";
                ET[0].Name = ET.Name;

                cViewerGraph1D VG1 = new cViewerGraph1D();
                VG1.SetInputData(ET);

                VG1.Chart.LabelAxisY = SubTitle;
                VG1.Chart.LabelAxisX = "Plate";
                VG1.Chart.IsZoomableX = true;
                VG1.Chart.IsBar = true;
                VG1.Chart.IsBorder = true;
                VG1.Chart.IsDisplayValues = true;
                VG1.Chart.IsShadow = true;
                VG1.Chart.MarkerSize = 4;


                Classes.Base_Classes.General.cLineHorizontalForGraph VLZ05 = new Classes.Base_Classes.General.cLineHorizontalForGraph(.05);
                VLZ05.IsAllowMoving = true;
                VG1.Chart.ListHorizontalLines.Add(VLZ05);

                VG1.Title = cGlobalInfo.CurrentScreening.ListDescriptors[cGlobalInfo.CurrentScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName();
                VG1.Run();

                cDisplayToWindow CDW = new cDisplayToWindow();
                CDW.SetInputData(VG1.GetOutPut());
                CDW.Title = SubTitle + " - " + ListPlatesToProcess.Count + " plates";
                CDW.Run();
                CDW.Display();
            #endregion
            }
        }