Exemple #1
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();

        }
Exemple #2
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
            }

        }
Exemple #3
0
        private void PerformTestType(eTestType TestType)
        {

            #region extract classes of interest
            cGUI_ListClasses GUI_ListClasses = new cGUI_ListClasses();
            GUI_ListClasses.IsCheckBoxes = !_DescEvolCellByCellItem.Checked;
            GUI_ListClasses.IsSelectAll = true;

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

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

            cDesignerTab DT = new cDesignerTab();

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

                if (cGlobalInfo.CurrentScreening.ListDescriptors[i].IsActive() == false) continue;

                cDesignerSplitter DS = new cDesignerSplitter();
                DS.Orientation = Orientation.Vertical;
                cViewerTable VTable = new cViewerTable();

                cViewertext VT = new cViewertext();

                cExtendedTable FinalTable = new cExtendedTable(cGlobalInfo.ListWellClasses.Count, 0, 0);
                for (int j = 0; j < cGlobalInfo.ListWellClasses.Count; j++)
                {
                    FinalTable[j].Tag = cGlobalInfo.ListWellClasses[j];
                    FinalTable[j].Name = cGlobalInfo.ListWellClasses[j].Name;
                }

                cListWells ListWellsToProcess = new cListWells(null);
                cDescriptorType CurrentDesc = cGlobalInfo.CurrentScreening.ListDescriptors[i];
                // build the table
                foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                {
                    foreach (cWell CurrentWell in CurrentPlate.ListActiveWells)
                    {
                        if ((CurrentWell.GetCurrentClassIdx() < 0) || (ListClassSelected[0][CurrentWell.GetCurrentClassIdx()] == 0)) continue;
                        {
                            FinalTable[CurrentWell.GetCurrentClassIdx()].Add(CurrentWell.GetAverageValue(CurrentDesc));
                            ListWellsToProcess.Add(CurrentWell);
                        }
                    }
                }

                cClean C = new cClean();
                C.SetInputData(FinalTable);
                C.Run();
                cExtendedTable NewTable = C.GetOutPut();

                cTwoSampleFTest TSFTest = null;
                cANOVA Anova = null;
                cTwoSampleUnpooledTTest TwoSampleTTest = null;
                cStudent_tTest StudentTTest = null;

                if (TestType == eTestType.F_TEST)
                {
                    TSFTest = new cTwoSampleFTest();
                    TSFTest.SetInputData(NewTable);
                    TSFTest.Run();
                    VTable.SetInputData(TSFTest.GetOutPut());
                    VT.SetInputData(TSFTest.GetInfo());
                }
                else if (TestType == eTestType.ANOVA)
                {
                    Anova = new cANOVA();
                    Anova.SetInputData(NewTable);
                    Anova.Run();
                    VTable.SetInputData(Anova.GetOutPut());
                    VT.SetInputData(Anova.GetInfo());
                }
                else if (TestType == eTestType.TWO_SAMPLES_T_TEST)
                {
                    TwoSampleTTest = new cTwoSampleUnpooledTTest();
                    TwoSampleTTest.SetInputData(NewTable);
                    TwoSampleTTest.Run();
                    VTable.SetInputData(TwoSampleTTest.GetOutPut());
                    VT.SetInputData(TwoSampleTTest.GetInfo());
                }
                else if (TestType == eTestType.STUDENT_T_TEST)
                {
                    StudentTTest = new cStudent_tTest();
                    StudentTTest.SetInputData(NewTable);
                    StudentTTest.Run();
                    VTable.SetInputData(StudentTTest.GetOutPut());
                    VT.SetInputData(StudentTTest.GetInfo());
                }
                VTable.DigitNumber = -1;
                VTable.Run();
                DS.SetInputData(VTable.GetOutPut());

                VT.Run();
                DS.SetInputData(VT.GetOutPut());
                DS.Run();
                DS.Title = cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName();

                cDesignerSplitter DSMain = new cDesignerSplitter();
                DSMain.Orientation = Orientation.Horizontal;
                DSMain.SetInputData(DS.GetOutPut());

                // Compute and display associated Stacked histogram

                //CDW1.Title = CompleteScreening.ListDescriptors[CompleteScreening.ListDescriptors.CurrentSelectedDescriptorIdx].GetName() + " - Stacked Histogram - " + PlateList.Count + " plates";

                cExtendedTable TableForHisto = ListWellsToProcess.GetAverageDescriptorValues(i);
                TableForHisto.Name = "";

                cViewerStackedHistogram CV1 = new cViewerStackedHistogram();
                CV1.SetInputData(TableForHisto);
                CV1.Chart.LabelAxisX = cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName();
                CV1.Chart.IsLegend = true;
                CV1.Run();

                DSMain.SetInputData(CV1.GetOutPut());
                DSMain.Title = cGlobalInfo.CurrentScreening.ListDescriptors[i].GetName();
                DSMain.Run();
                DT.SetInputData(DSMain.GetOutPut());
            }

            DT.Run();
            cDisplayToWindow DTW = new cDisplayToWindow();
            DTW.SetInputData(DT.GetOutPut());
            DTW.Title = "Classification Significance - " + TestType.ToString();
            DTW.Run();
            DTW.Display();

        }
        void ToolStripMenuItem_DRCAnalysis_Click(object sender, EventArgs e)
        {
            List<cDescriptorType> ListSelectedDesc = new List<cDescriptorType>();// GlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors();
            ListSelectedDesc.Add(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor());

            //if (GlobalInfo == null) GlobalInfo = cGlobalInfo.CurrentScreening.GlobalInfo;
            //if (cGlobalInfo == null) return;

            cDesignerMultiChoices DT = new cDesignerMultiChoices();

            cExtendedTable TableForGeneralResuts = new cExtendedTable();
            TableForGeneralResuts.Add(new cExtendedList("p-Value"));
            TableForGeneralResuts.Add(new cExtendedList("EC50"));
            TableForGeneralResuts.Add(new cExtendedList("Slope"));
            TableForGeneralResuts.Add(new cExtendedList("Bottom"));
            TableForGeneralResuts.Add(new cExtendedList("Top"));
            TableForGeneralResuts.Add(new cExtendedList("Window"));
            TableForGeneralResuts.Add(new cExtendedList("Area Under Curve"));

            TableForGeneralResuts.ListRowNames = new List<string>();
            TableForGeneralResuts.ListTags = new List<object>();

            cDesignerSplitter MainSplitter = new cDesignerSplitter();

            int IdxNode = 0;
            cListListWells CurrentSelectedGroups = this.BuildListListWells();

            foreach (cListWells TmpListWells in CurrentSelectedGroups)
            {
                // List<cDescriptorType> LType = new List<cDescriptorType>();
                //  LType.Add(ListSelectedDesc[i]);
                cExtendedTable CompleteTable = TmpListWells.GetAverageDescriptorValues(ListSelectedDesc, true, false);

                //cExtendedTable CompleteTable = GLP.GetOutPut();

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

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

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

                cANOVA A = new cANOVA();

                cExtendedTable NewTable = CFG.ListPtValues.Crop(0, CFG.ListPtValues.Count - 1, 1, CFG.ListPtValues[0].Count - 1);
                A.SignificanceThreshold = 1E-11;
                A.SetInputData(NewTable);
                A.Run();

                cExtendedTable Sigmoid = SF.GetFittedRawValues(CFG.GetListXValues());
                CompleteTable[0] = Sigmoid[1];
                CompleteTable[0].Name = ListSelectedDesc[0].GetName() + "\n" + Sigmoid[1].Name;
                cDesignerSplitter DS = new cDesignerSplitter();

                //cViewerTableAsRichText VT = new cViewerTableAsRichText();
                cViewerTable VT = new cViewerTable();
                cExtendedTable TableResults = SF.GetOutPut();

                if ((A.GetOutPut() != null) && (A.GetOutPut().Count > 0))
                {
                    TableResults[0].Add(A.GetOutPut()[0][0]);
                    TableResults[0].Add(A.GetOutPut()[0][1]);
                    TableResults.ListRowNames.Add("p-Value");
                    TableResults.ListRowNames.Add("Rejected?");

                    TableForGeneralResuts[0].Add(A.GetOutPut()[0][0]);
                }
                else
                {
                    TableForGeneralResuts[0].Add(1);
                }

                TableResults.Name = TV.Nodes[IdxNode].Text;
                TableResults[0].Name = "Fitting Parameters";
                VT.SetInputData(TableResults);
                VT.DigitNumber = -1;
                VT.Run();

                cViewerGraph1D VS1 = new cViewerGraph1D();

                cExtendedTable MyTable = new cExtendedTable(Sigmoid[1]);
                MyTable.Name = TmpListWells.Name;// TV.Nodes[IdxNode].Text;
                VS1.SetInputData(MyTable);
                VS1.AddCurve(CFG);

                VS1.Chart.X_AxisValues = Sigmoid[0];
                VS1.Chart.IsLogAxis = true;
                VS1.Chart.IsLine = true;
                VS1.Chart.IsShadow = false;
                VS1.Chart.Opacity = 210;
                VS1.Chart.LineWidth = 3;
                VS1.Chart.MarkerSize = 8;
                VS1.Chart.IsDisplayValues = cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxDRCDisplayValues.Checked;
                VS1.Chart.LabelAxisX = "Concentration";
                VS1.Chart.LabelAxisY = CompleteTable[1].Name;
                VS1.Chart.XAxisFormatDigitNumber = cGlobalInfo.OptionsWindow.FFAllOptions.GetDRCNumberOfDigit();
                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);

                TableForGeneralResuts.ListRowNames.Add(TV.Nodes[IdxNode].Text);
                TableForGeneralResuts.ListTags.Add((Chart)VS1.Chart);//ListSelectedDesc[0]);

                //EC50
                TableForGeneralResuts[1].Add(SF.GetOutPut()[0][2]);

                // Slope
                TableForGeneralResuts[2].Add(SF.GetOutPut()[0][3]);

                // Bottom
                TableForGeneralResuts[3].Add(SF.GetOutPut()[0][0]);

                // Top
                TableForGeneralResuts[4].Add(SF.GetOutPut()[0][1]);

                // Window
                double Window = SF.GetOutPut()[0][1] / SF.GetOutPut()[0][0];
                TableForGeneralResuts[5].Add(Window);

                TableForGeneralResuts[6].Add(SF.GetOutPut()[0][5]);

                VS1.Chart.ArraySeriesInfo = new cSerieInfoDesign[CompleteTable.Count];

                for (int IdxCurve = 0; IdxCurve < CompleteTable.Count; IdxCurve++)
                {
                    cSerieInfoDesign TmpSerieInfo = new cSerieInfoDesign();
                    TmpSerieInfo.color = cGlobalInfo.ListCellularPhenotypes[IdxCurve % cGlobalInfo.ListCellularPhenotypes.Count].ColourForDisplay;
                    TmpSerieInfo.markerStyle = MarkerStyle.None;

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

                VS1.Run();

                DS.SetInputData(VS1.GetOutPut());
                DS.SetInputData(VT.GetOutPut());
                DS.Orientation = Orientation.Horizontal;
                DS.Title = TV.Nodes[IdxNode++].Text; //TmpListWells.ti;// ListSelectedDesc[0].GetName();
                DS.Run();
                DT.SetInputData(DS.GetOutPut());
            }

            DT.Run();
            cExtendedControl TextEC = DT.GetOutPut();
            if (TextEC == null) return;

            TextEC.Width = 0;
            TextEC.Height = 0;

            TextEC.Anchor = (System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom
                    | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right);

            MainSplitter.SetInputData(TextEC);

            string DRCsortingMethod = cGlobalInfo.OptionsWindow.FFAllOptions.comboBoxDRCSorting.SelectedItem.ToString();
            //comboBoxDRCSorting
            int IdxColSorting = 0;
            cExtendedTable RT = TableForGeneralResuts;

            switch (DRCsortingMethod)
            {
                case "ANOVA":
                    IdxColSorting = 0;
                    break;
                case "EC50":
                    IdxColSorting = 1;
                    break;
                case "Window":
                    IdxColSorting = 5;
                    break;
                case "AUC":
                    IdxColSorting = 6;
                    break;
                case "None":
                    IdxColSorting = -1;
                    break;
                default:
                    break;

            }

            if (IdxColSorting != -1)
            {
                cSort S = new cSort();
                S.ColumnIndexForSorting = IdxColSorting;
                S.SetInputData(TableForGeneralResuts);
                S.IsAscending = true;
                S.Run();
                RT = S.GetOutPut();
            }
            cViewerTable VTForEC50 = new cViewerTable();

            RT.Name = cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor().GetName();
            VTForEC50.SetInputData(RT);
            VTForEC50.DigitNumber = -1;
            VTForEC50.Run();

            MainSplitter.SetInputData(VTForEC50.GetOutPut());

            MainSplitter.Orientation = Orientation.Vertical;
            MainSplitter.Run();

            cDisplayToWindow DTW = new cDisplayToWindow();
            DTW.SetInputData(MainSplitter.GetOutPut());
            DTW.Title = "DRC analysis [" + cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor().GetName() + "]";

            DTW.Run();
            DTW.Display();
        }
        void ToolStripMenuItem_DRCAnalysisMultiDesc_Click(object sender, EventArgs e)
        {
            List<cDescriptorType> ListSelectedDescs = cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors();

            cListListWells CurrentSelectedGroups = this.BuildListListWells();

            #region select folder
            var dlg1 = new Ionic.Utils.FolderBrowserDialogEx();
            dlg1.Description = "Select the folder containing your databases.";
            dlg1.ShowNewFolderButton = true;
            dlg1.ShowEditBox = true;
            dlg1.ShowFullPathInEditBox = true;

            DialogResult result = dlg1.ShowDialog();
            if (result != DialogResult.OK) return;

            string Path = dlg1.SelectedPath;
            if (Directory.Exists(Path) == false) return;

            string FolderName = dlg1.SelectedPath;
            #endregion

            foreach (var item in ListSelectedDescs)
            {
                string TmpFolder = FolderName + "\\" + item.GetName();
                Directory.CreateDirectory(TmpFolder);

                int IdxNode = 0;

                List<cDescriptorType> ListSelectedDesc = new List<cDescriptorType>();
                ListSelectedDesc.Add(item);

                cExtendedTable TableForGeneralResuts = new cExtendedTable();
                TableForGeneralResuts.Add(new cExtendedList("p-Value"));
                TableForGeneralResuts.Add(new cExtendedList("EC50"));
                TableForGeneralResuts.Add(new cExtendedList("Slope"));
                TableForGeneralResuts.Add(new cExtendedList("Bottom"));
                TableForGeneralResuts.Add(new cExtendedList("Top"));
                TableForGeneralResuts.Add(new cExtendedList("Window"));
                TableForGeneralResuts.Add(new cExtendedList("Area Under Curve"));

                TableForGeneralResuts.ListRowNames = new List<string>();
                TableForGeneralResuts.ListTags = new List<object>();

                foreach (cListWells TmpListWells in CurrentSelectedGroups)
                {
                    // List<cDescriptorType> LType = new List<cDescriptorType>();
                    //  LType.Add(ListSelectedDesc[i]);
                    cExtendedTable CompleteTable = TmpListWells.GetAverageDescriptorValues(ListSelectedDesc, true, false);

                    //cExtendedTable CompleteTable = GLP.GetOutPut();

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

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

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

                    cANOVA A = new cANOVA();

                    cExtendedTable NewTable = CFG.ListPtValues.Crop(0, CFG.ListPtValues.Count - 1, 1, CFG.ListPtValues[0].Count - 1);
                    A.SignificanceThreshold = 1E-11;
                    A.SetInputData(NewTable);
                    A.Run();

                    cExtendedTable Sigmoid = SF.GetFittedRawValues(CFG.GetListXValues());
                    CompleteTable[0] = Sigmoid[1];
                    CompleteTable[0].Name = ListSelectedDesc[0].GetName() + "\n" + Sigmoid[1].Name;
                    cDesignerSplitter DS = new cDesignerSplitter();

                    //cViewerTableAsRichText VT = new cViewerTableAsRichText();
                    cViewerTable VT = new cViewerTable();
                    cExtendedTable TableResults = SF.GetOutPut();

                    if ((A.GetOutPut() != null) && (A.GetOutPut().Count > 0))
                    {
                        TableResults[0].Add(A.GetOutPut()[0][0]);
                        TableResults[0].Add(A.GetOutPut()[0][1]);
                        TableResults.ListRowNames.Add("p-Value");
                        TableResults.ListRowNames.Add("Rejected?");

                        TableForGeneralResuts[0].Add(A.GetOutPut()[0][0]);
                    }
                    else
                    {
                        TableForGeneralResuts[0].Add(1);
                    }

                    TableResults.Name = TV.Nodes[IdxNode].Text;
                    TableResults[0].Name = "Fitting Parameters";
                    VT.SetInputData(TableResults);
                    VT.DigitNumber = -1;
                    VT.Run();

                    cViewerGraph1D VS1 = new cViewerGraph1D();

                    cExtendedTable MyTable = new cExtendedTable(Sigmoid[1]);
                    MyTable.Name = TmpListWells.Name;// TV.Nodes[IdxNode].Text;
                    VS1.SetInputData(MyTable);
                    VS1.AddCurve(CFG);

                    VS1.Chart.X_AxisValues = Sigmoid[0];
                    VS1.Chart.IsLogAxis = true;
                    VS1.Chart.IsLine = true;
                    VS1.Chart.IsShadow = false;
                    VS1.Chart.Opacity = 210;
                    VS1.Chart.LineWidth = 3;
                    VS1.Chart.MarkerSize = 8;
                    VS1.Chart.IsDisplayValues = cGlobalInfo.OptionsWindow.FFAllOptions.checkBoxDRCDisplayValues.Checked;
                    VS1.Chart.LabelAxisX = "Concentration";
                    VS1.Chart.LabelAxisY = CompleteTable[1].Name;
                    VS1.Chart.XAxisFormatDigitNumber = cGlobalInfo.OptionsWindow.FFAllOptions.GetDRCNumberOfDigit();
                    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);

                    TableForGeneralResuts.ListRowNames.Add(TV.Nodes[IdxNode].Text);
                    TableForGeneralResuts.ListTags.Add((Chart)VS1.Chart);//ListSelectedDesc[0]);

                    //EC50
                    TableForGeneralResuts[1].Add(SF.GetOutPut()[0][2]);

                    // Slope
                    TableForGeneralResuts[2].Add(SF.GetOutPut()[0][3]);

                    // Bottom
                    TableForGeneralResuts[3].Add(SF.GetOutPut()[0][0]);

                    // Top
                    TableForGeneralResuts[4].Add(SF.GetOutPut()[0][1]);

                    // Window
                    double Window = SF.GetOutPut()[0][1] / SF.GetOutPut()[0][0];
                    TableForGeneralResuts[5].Add(Window);

                    TableForGeneralResuts[6].Add(SF.GetOutPut()[0][5]);

                    VS1.Chart.ArraySeriesInfo = new cSerieInfoDesign[CompleteTable.Count];

                    for (int IdxCurve = 0; IdxCurve < CompleteTable.Count; IdxCurve++)
                    {
                        cSerieInfoDesign TmpSerieInfo = new cSerieInfoDesign();
                        TmpSerieInfo.color = cGlobalInfo.ListCellularPhenotypes[IdxCurve % cGlobalInfo.ListCellularPhenotypes.Count].ColourForDisplay;
                        TmpSerieInfo.markerStyle = MarkerStyle.None;

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

                    VS1.Run();

                    //DS.SetInputData(VS1.GetOutPut());
                    //DS.SetInputData(VT.GetOutPut());
                    //DS.Orientation = Orientation.Horizontal;
                    //DS.Title = TV.Nodes[IdxNode++].Text; //TmpListWells.ti;// ListSelectedDesc[0].GetName();
                    //DS.Run();

                    IdxNode++;

                    //   DT.SetInputData(DS.GetOutPut());
                }
                cTableToHTML THTML = new cTableToHTML();
                TableForGeneralResuts.Name = item.GetName();
                THTML.SetInputData(TableForGeneralResuts);
                THTML.IsDisplayUIForFilePath = false;
                THTML.FolderName = TmpFolder;

                THTML.ListProperties.FindByName("Open HTML File ?").SetNewValue((bool)false);
                THTML.ListProperties.FindByName("Open HTML File ?").IsGUIforValue = false;

                THTML.Run();
            }

            System.Diagnostics.Process.Start(FolderName);
        }
Exemple #6
0
        private void ToolStripMenuItem_TestsOneWayANOVA(object sender, EventArgs e)
        {
            cExtendedTable CET = new cExtendedTable();
            foreach (DataGridViewColumn item in GridView.SelectedColumns)
                CET.Add(Input[item.Index]);

            cANOVA S = new cANOVA();
            S.SetInputData(CET);
            S.Run();

            cDisplayExtendedTable CDT = new cDisplayExtendedTable();
            CDT.DigitNumber = -1;
            CDT.SetInputData(S.GetOutPut());
            CDT.Run();
        }