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();
        }
Esempio n. 2
0
        void Process()
        {
            cDesignerTab DT = new cDesignerTab();

            for (int i = 0; i < this.Input.Count; i++)
            {
                cExtendedTable FinalTable = this.Input[i];

                cCurveForGraph CFG = new cCurveForGraph();
                CFG.SetInputData(FinalTable);
                CFG.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(CFG.GetListXValues());
                FinalTable[0] = Sigmoid[1];

                cDesignerSplitter DS = new cDesignerSplitter();

                //cViewerTableAsRichText VT = new cViewerTableAsRichText();
                cViewerTable VT = new cViewerTable();
                VT.SetInputData(SF.GetOutPut());
                VT.DigitNumber = -1;
                VT.Run();

                cViewerGraph1D VS1 = new cViewerGraph1D();
                //VS1.SetInputData(/*new cExtendedTable(AN.GetOutPut()[1])*/FinalTable);
                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.IsDisplayValues = true;
                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];

                for (int IdxCurve = 0; IdxCurve < FinalTable.Count; IdxCurve++)
                {
                    cSerieInfoDesign TmpSerieInfo = new cSerieInfoDesign();
                   // TmpSerieInfo.color = 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" + i * 10;
                DS.Run();
                DT.SetInputData(DS.GetOutPut());

            }
            DT.Run();

            cDisplayToWindow MyDisplay = new cDisplayToWindow();
            MyDisplay.SetInputData(DT.GetOutPut());
            MyDisplay.Title = this.Input.Name;
            MyDisplay.Run();
            MyDisplay.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);
        }