private void simpleTestToolStripMenuItem_Click(object sender, EventArgs e) { Random RNd = new Random(); int NumRow = 8; double InitialValue = 10; int NumCol = 12; cExtendedTable FinalTable = null; for (int Col = 1; Col <= NumCol; Col++) { for (int Repeat = 1; Repeat <= NumRow; Repeat++) { cExtendedTable GeneratedTable = new cExtendedTable(1, 1000, InitialValue); cAddNoise AN = new cAddNoise(); AN.DistributionType = eRandDistributionType.GAUSSIAN; AN.Mean = 20;// Col*1.2; AN.Stdv = 0.5 * Col; AN.SetInputData(GeneratedTable); AN.Run(); GeneratedTable = AN.GetOutPut(); //for (int i = 0; i < GeneratedTable[0].Count; i++) //{ // GeneratedTable[0][i] = Col; // GeneratedTable[1][i] = Repeat; //} GeneratedTable.ListRowNames = new List<string>(); for (int i = 0; i < GeneratedTable[0].Count; i++) { GeneratedTable.ListRowNames.Add(ConvertPosition(Col, Repeat)); } if (FinalTable == null) FinalTable = new cExtendedTable(GeneratedTable); else { cMerge M = new cMerge(); M.IsHorizontal = false; M.SetInputData(FinalTable, GeneratedTable); M.Run(); FinalTable = M.GetOutPut(); } } } FinalTable.Name = "generated screen"; FinalTable[0].Name = "Volume"; // FinalTable[1].Name = "Row"; // FinalTable[2].Name = "Volume"; cDisplayExtendedTable DET = new cDisplayExtendedTable(); //DET.SetInputData(FinalTable); //DET.Run(); cTableToFile TTF = new cTableToFile(); TTF.SetInputData(FinalTable); TTF.IsDisplayUIForFilePath = true; TTF.IsRunEXCEL = true; TTF.IsAppend = false; TTF.Run(); }
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(); }