示例#1
0
        public cFeedBackMessage Run()
        {
            ToReturn = new cExtendedTable(this.Widht,this.Height,0);

            RND = new Random(this.Seed);

            if (this.DistributionType == eRandDistributionType.UNIFORM)
            {

                foreach (cExtendedList item in ToReturn)
                    for (int i = 0; i < item.Count; i++)
                        item[i] = RND.NextDouble() * (Max - Min) + Min;
            }
            else if (this.DistributionType == eRandDistributionType.GAUSSIAN)
            {
                foreach (cExtendedList item in ToReturn)
                    for (int i = 0; i < item.Count; i++)
                    {
                        double u1 = RND.NextDouble();
                        double u2 = RND.NextDouble();
                        double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2);
                        item[i] = this.Mean + this.Stdev * randStdNormal;
                    }
            }
            else
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "Distribution Type not implemented";
            }

            return FeedBackMessage;
        }
示例#2
0
        public cFeedBackMessage Run()
        {
            base.Start();

            // Here is the right way for accessing the parameters...
            // a little laborious, but that's the price to pay for a complete interface
            object _firstValue = base.ListProperties.FindByName("First Paramater");
            double firstValue = 0;
            if (_firstValue == null)
            {
                base.GenerateError("First Paramater not found !");
                return base.FeedBackMessage;
            }
            try
            {
                cProperty TmpProp = (cProperty)_firstValue;
                firstValue = (double)TmpProp.GetValue();
            }
            catch (Exception)
            {
                base.GenerateError("First Paramater cast didn't work");
                return base.FeedBackMessage;
            }

            ToReturn = new cExtendedTable((int)firstValue, (int)firstValue, 0);

            base.End();
            return FeedBackMessage;
        }
示例#3
0
        public cFeedBackMessage Run()
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }

            this.OutPut = new cExtendedTable(this.Input);
            cRandomGenerator RG = new cRandomGenerator(this.Input.Count, this.Input[0].Count);
            RG.Seed = (int)System.DateTime.Now.Ticks;
            RG.Min = this.Min;
            RG.Max = this.Max;
            RG.Mean = this.Mean;
            RG.Stdev = this.Stdv;
            RG.DistributionType = this.DistributionType;

            FeedBackMessage = RG.Run();
            if (FeedBackMessage.IsSucceed == false)
            {
                return FeedBackMessage;
            }

            cArithmetic_DualOperator DO = new cArithmetic_DualOperator();
            DO.SetInputData(this.Input, RG.GetOutPut());
            DO.OperationType = eBinaryOperationType.ADD;
            DO.Run();

            this.OutPut = DO.GetOutPut();
            this.OutPut.Name = "Add Noise(" + this.Input.Name + ")";

            return FeedBackMessage;
        }
示例#4
0
        public cFeedBackMessage Run()
        {
            if(this.Input==null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data";
            }

            this.OutPut = new cExtendedTable(this.Input);
            this.OutPut[0].Name = "X";
            this.OutPut.Add(new cExtendedList());
            this.OutPut[1].Name = "Sigmoid(X)";

            foreach (var item in this.Input)
            {
                //double Value = Bottom +
                //    ( (Top - Bottom) / (1 + Math.Pow(10, (Math.Log10(EC50) - item) * Slope) ) );

                double Value = Bottom + (Top - Bottom) / (1 + Math.Pow((EC50 / item),Slope));

                this.OutPut[1].Add(Value);
                        /// (1 + Math.Pow((Math.Pow(10, EC50) / Math.Pow(10, /*ResultFit.GetLogConcentrations()*/item)), Slope)));
            }

            //for (int IdxConc = 0; IdxConc < this.Input[0].Count; IdxConc++)
            // {
            //    Y_Estimated.Add(c[0] + (c[1] - c[0]) / (1 + Math.Pow((Math.Pow(10, c[2]) / Math.Pow(10, /*ResultFit.GetLogConcentrations()*/this.Input[0][IdxConc])), c[3])));
            //    //   ResultFit.Y_Estimated.Add(c[0] + (c[1] - c[0]) / (1 + Math.Pow(((c[2]) /  ResultFit.GetLogConcentrations()[IdxConc]), c[3])));
            // }

            return FeedBackMessage;
        }
示例#5
0
        public cFeedBackMessage Run()
        {
            this.Output = new cExtendedTable();
            this.Output.Tag = this.ListObjects.Tag;
            this.Output.Name = "3D View Associated Data Table";
                if(this.ListObjects.Name!=null)
                    this.Output.Name += this.ListObjects.Name;
            this.Output.ListTags = new List<object>();
            this.Output.ListRowNames = new List<string>();

            this.Output.Add(new cExtendedList("X"));
            this.Output.Add(new cExtendedList("Y"));
            this.Output.Add(new cExtendedList("Z"));

            foreach (var item in this.ListObjects)
            {
                this.Output[0].Add(item.GetPosition().X);
                this.Output[1].Add(item.GetPosition().Y);
                this.Output[2].Add(item.GetPosition().Z);
                this.Output.ListTags.Add(item.Tag);
                this.Output.ListRowNames.Add(item.GetName());
            }

            return FeedBackMessage;
        }
示例#6
0
        private cFeedBackMessage Process()
        {
            this.Output = new cExtendedTable(this.Input);

            //int IDxCOl = 0;
               // foreach (cExtendedList item in this.Output)
            for (int IDxCOl = 0; IDxCOl < this.Output.Count; IDxCOl++)
            {
                this.Output[IDxCOl] = Input[IDxCOl].Normalize(this.NormalizationType);
            }

            switch (this.NormalizationType)
            {
                case eNormalizationType.STANDARDIZE :
                    this.Output.Name = "Standardize(" + this.Input.Name + ")";
                    break;
                case eNormalizationType.MIN_MAX:
                    this.Output.Name = "MinMax(" + this.Input.Name + ")";
                    break;
                case eNormalizationType.SHIFT_TO_MEAN:
                    this.Output.Name = "Shift To Mean(" + this.Input.Name + ")";
                    break;
                case eNormalizationType.SHIFT_TO_MEDIAN:
                    this.Output.Name = "Shift To Median(" + this.Input.Name + ")";
                    break;
                case eNormalizationType.SHIFT_TO_MIN:
                    this.Output.Name = "Shift To Min(" + this.Input.Name + ")";
                    break;
                default:
                    break;
            }

            return base.FeedBackMessage;
        }
示例#7
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;
        }
示例#8
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.";
        }
示例#9
0
文件: cClean.cs 项目: cyrenaique/HCSA
        public cFeedBackMessage Run()
        {
            if(this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }

            OutPut = new cExtendedTable(this.Input);
            this.OutPut.ListRowNames = null;

            int NumberOfColumnsRemoved = 0;
            int RealIdx = 0;
            for (int i = 0; i < this.Input.Count; i++)
            {
                if ((this.Input[i].Count <= this.MinNumberOfData) || (this.Input[i].Count >= this.MaxNumberOfData))
                {
                    this.OutPut.RemoveAt(RealIdx);
                    NumberOfColumnsRemoved++;
                    RealIdx--;
                }
                RealIdx++;
            }

            this.OutPut.Name = "Clean(" + this.Input.Name + ")";

            FeedBackMessage.Message = NumberOfColumnsRemoved + " columns removed";
            return FeedBackMessage;
        }
示例#10
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 = "Student's t-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;

                    if(this.IsUnequalVariance)
                        alglib.unequalvariancettest(this.Input[IdxCol].ToArray(), this.Input[IdxCol].Count, this.Input[IdxColBis].ToArray(), this.Input[IdxColBis].Count, out bothtails, out lefttail, out righttail);
                    else
                        alglib.studentttest2(this.Input[IdxCol].ToArray(), this.Input[IdxCol].Count, this.Input[IdxColBis].ToArray(), this.Input[IdxColBis].Count, out bothtails, out lefttail, out righttail);

                    //alglib.mannwhitneyutest(

                    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;
        }
示例#11
0
文件: cSort.cs 项目: cyrenaique/HCSA
        public cFeedBackMessage Run()
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input defined.";
                return FeedBackMessage;
            }

            if (this.ColumnIndexForSorting >= this.Input.Count)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "Sorting column index exceed table size.";
                return FeedBackMessage;
            }
            Process();

            this.Output = new cExtendedTable(this.Input);
            this.Output.Name = "Sorted "+this.Input.Name;

            int IdxCol = 0;
            foreach (var item in this.Input)
            {
                this.Output[IdxCol].Tag = item.Tag;
                IdxCol++;
            }

            for (IdxCol = 0; IdxCol < this.Input.Count; IdxCol++)
            {
                for (int IdxRow = 0; IdxRow < RefList.Count; IdxRow++)
                    this.Output[IdxCol][IdxRow] = this.Input[IdxCol][RefList[IdxRow].Index];

                if ((this.Input[IdxCol].ListTags != null) && (this.Input[IdxCol].ListTags.Count>0))
                {
                    for (int IdxRow = 0; IdxRow < RefList.Count; IdxRow++)
                        this.Output[IdxCol].ListTags[IdxRow] = this.Input[IdxCol].ListTags[RefList[IdxRow].Index];
                }
            }

            for (int IdxRow = 0; IdxRow < this.Input.ListRowNames.Count; IdxRow++)
                this.Output.ListRowNames[IdxRow] = this.Input.ListRowNames[RefList[IdxRow].Index];

            if (this.Input.ListTags != null)
            {
                for (int IdxRow = 0; IdxRow < this.Input.ListTags.Count; IdxRow++)
                    this.Output.ListTags[IdxRow] = this.Input.ListTags[RefList[IdxRow].Index];
            }

            return FeedBackMessage;
        }
示例#12
0
        private void Project()
        {
            Matrix NewPt = new Matrix(this.DataToProject[0].Count, this.DataToProject.Count);
            NewPt = DataToProject.CopyToWEKAMatrix().multiply(this.Basis.CopyToWEKAMatrix());
            ProjectedData = new cExtendedTable(NewPt);

            int Idx=0;
            foreach (var item in DataToProject)
            {
                ProjectedData[Idx].Name = Basis.ListRowNames[Idx];
                Idx++;
            }

            ProjectedData.ListRowNames.AddRange(DataToProject.ListRowNames);
        }
示例#13
0
        public cFeedBackMessage Run()
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }

            //if (Info != 1)
            //{
            //    FeedBackMessage.IsSucceed = false;
            //    FeedBackMessage.Message = "Error while inversing the matrix";
            //    return FeedBackMessage;
            //}

            this.OutPut = new cExtendedTable(this.Input[0].Count, this.Input.Count, 0);

            if (Input[0].ListTags != null)
            {
                foreach (var item in this.OutPut)
                {
                    item.ListTags = new List<object>();
                }
            }

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

            for (int i = 0; i < this.Input.Count; i++)
            {
                this.OutPut.ListRowNames.Add(this.Input[i].Name);
                for (int j = 0; j < this.Input[i].Count; j++)
                {
                    this.OutPut[j][i] = this.Input[i][j];
                    if (this.Input[i].ListTags != null) this.OutPut[j].ListTags.Add(this.Input[i].ListTags[j]);
                }
            }

            if (this.Input.ListRowNames != null)
            {
                for (int i = 0; i < this.Input.ListRowNames.Count; i++)
                    this.OutPut[i].Name = this.Input.ListRowNames[i];
            }

            this.OutPut.Name = "Transpose(" + this.Input.Name + ")";

            return FeedBackMessage;
        }
示例#14
0
文件: cImage.cs 项目: cyrenaique/HCSA
        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;

        }
示例#15
0
        public cFeedBackMessage Run()
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data defined.";
                return FeedBackMessage;
            }
            if (this.Input.Count != this.Input[0].Count)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "A square matrix is required for this operation";
                return FeedBackMessage;
            }

            // ------------- now proceed -------------
            int Info;

            double[,] Mat = this.Input.CopyToArray();
            alglib.rmatrixinverse(ref Mat, out Info, out Report);

            if (Info != 1)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "Error while inversing the matrix";
                return FeedBackMessage;
            }

            this.OutPut = new cExtendedTable(Mat);

            if (this.Input.ListRowNames != null)
            {
                this.OutPut.ListRowNames = new List<string>();
                this.OutPut.ListRowNames.AddRange(this.Input.ListRowNames.ToArray());
            }

            int IdxCOl=0;
            foreach (var item in this.Input)
            {
                this.OutPut[IdxCOl++].Name = item.Name;
            }

            this.OutPut.Name = "Inverse(" + this.Input.Name + ")";

            return FeedBackMessage;
        }
示例#16
0
        private cFeedBackMessage Process()
        {
            cExtendedTable TmpTable = new cExtendedTable(this.Input[this.IdxColumnToProcess]);

            cSort S = new cSort();
            S.SetInputData(TmpTable);
            base.FeedBackMessage = S.Run();
            if (base.FeedBackMessage.IsSucceed == false) return base.FeedBackMessage;

            cNormalize N = new cNormalize();
            N.NormalizationType = eNormalizationType.STANDARDIZE;
            N.SetInputData(S.GetOutPut());
            base.FeedBackMessage = N.Run();
            if (base.FeedBackMessage.IsSucceed == false) return base.FeedBackMessage;

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

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

            double[] PercentPointFunction = new double[Num];

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

            this.Output = new cExtendedTable(new cExtendedList(PercentPointFunction));

            this.Output.Add(new cExtendedList());

            this.Output.ListTags = new List<object>();

            for (int i = 0; i < N.GetOutPut()[0].Count; i++)
            {
                this.Output[1].Add(N.GetOutPut()[0][i]);
                if(S.GetOutPut()[0].ListTags!=null)
                this.Output.ListTags.Add(S.GetOutPut()[0].ListTags[i]);
            }

            this.Output[0].Name = "";
            this.Output[1].Name = "Normalized Data";

            return base.FeedBackMessage;
        }
示例#17
0
        cFeedBackMessage Process()
        {
            this.Output = new cExtendedTable();
            this.Output.Name = "Histogram (" + this.Input.Name + ")";

            List<double[]> Res = null;

            if (IsBinNumberMode)
            {
                if (double.IsNaN(this.Min) || double.IsNaN(this.Max))
                    Res = Input[0].CreateHistogram(this.BinNumber, this.IsNormalized);
                else
                    Res = Input[0].CreateHistogram(this.Min, this.Max, (int)this.BinNumber, this.IsNormalized);
            }
            else
            {
                //if (double.IsNaN(this.Min) || double.IsNaN(this.Max))
                //    Res = Input[0].CreateHistogram(this.BinNumber, this.IsNormalized);
                //else
                    Res = Input[0].CreateHistogram(this.Min, this.Max, this.BinSize);
            }

            if (Res.Count == 0)
            {
                base.FeedBackMessage.IsSucceed = false;
                base.FeedBackMessage.Message = "Histogram failure";
                return base.FeedBackMessage;
            }

            string ColName = "Frequency";
            if (IsNormalized) ColName = "Normalized " + ColName;

            cExtendedList ListY = new cExtendedList(ColName);
            if (this.Input[0].Name == "") ColName = "Value";
            else
                ColName = this.Input[0].Name;
            cExtendedList ListX = new cExtendedList(ColName);

            ListX.AddRange(Res[0]);
            ListY.AddRange(Res[1]);

            this.Output.Add(ListX);
            this.Output.Add(ListY);

            return base.FeedBackMessage;
        }
示例#18
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);
                }
        }
示例#19
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);
            }
        }
示例#20
0
        public cExtendedTable GetLiveListValues()
        {
            cExtendedTable CET = new cExtendedTable();
            CET.Name = Input.Name;
            //foreach (DataGridViewColumn item in GridView.SelectedColumns)

            for (int ColumnSelected = 0; ColumnSelected < GridView.SelectedColumns.Count; ColumnSelected++)
            {
                CET.Add(new cExtendedList());
                for (int i = 0; i < GridView.Rows.Count - 1; i++)
                {
                    CET[ColumnSelected].Add(double.Parse(GridView[GridView.SelectedColumns[ColumnSelected].Index, i].Value.ToString()));

                }
                //GridView[item.Index,
                //CET.Add();
            }
            //GridView.SelectedColumns
            return CET;
        }
示例#21
0
        void Process()
        {
            // here is the core of the meta component ...
            // just a list of Component steps
            foreach (cWell item in Input)
            {
                item.AssociatedPlate.DBConnection = new cDBConnection(item.AssociatedPlate, item.SQLTableName);

                cListSingleBiologicalObjects ListPhenotypes = item.AssociatedPlate.DBConnection.GetBiologicalPhenotypes(item);

                cExtendedTable ET = item.AssociatedPlate.DBConnection.GetWellValues(item, cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptors());
                item.AssociatedPlate.DBConnection.CloseConnection();

                ET.ListTags = new List<object>();

                for (int i = 0; i < ET.Count; i++)
                {
                    ET[i].ListTags = new List<object>();

                    for (int j = 0; j < ListPhenotypes.Count; j++)
                        ET[i].ListTags.Add(ListPhenotypes[j]);
                }

                for (int j = 0; j < ListPhenotypes.Count; j++)
                    ET.ListTags.Add(ListPhenotypes[j]);

                if (Output == null)
                    Output = new cExtendedTable(ET);
                else
                {
                    cMerge M = new cMerge();
                    M.IsHorizontal = false;
                    M.SetInputData(Output, ET);
                    M.Run();

                    Output = M.GetOutPut();
                }
            }
        }
示例#22
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);
                }
        }
示例#23
0
        public cFeedBackMessage Run()
        {
            if (this.Input == null)
            {
                FeedBackMessage.IsSucceed = false;
                FeedBackMessage.Message = "No input data";
            }

            this.OutPut = new cExtendedTable();
            this.OutPut.Add(new cExtendedList());

            for (int i = 0; i < NumberOfPoint; i++)
            {
                if (i == 0)
                    this.OutPut[0].Add(Start);
                else
                    this.OutPut[0].Add(this.OutPut[0][this.OutPut[0].Count - 1] / this.DilutionFactor);
            }

            double End = this.OutPut[0][this.OutPut[0].Count - 1];
            this.OutPut[0].Name = "Titration[" + Start + "..." + End + ":" + DilutionFactor + "]";
            return FeedBackMessage;
        }
示例#24
0
 public void SetInputData(cExtendedTable Input)
 {
     this.Input = Input;
 }
示例#25
0
        void Refresh()
        {
            base.CurrentSeries.Clear();

            double GlobalMinX = 0;
            double GlobalMaxX = 0;

            if (this.SliderForMarkerSizeBinSize.radioButtonMinMaxAutomated.Checked)
            {
                GlobalMinX = this.InputSimpleData.Min();
                GlobalMaxX = this.InputSimpleData.Max();
            }
            else
            {
                GlobalMinX = (double)this.SliderForMarkerSizeBinSize.numericUpDownMin.Value;
                GlobalMaxX = (double)this.SliderForMarkerSizeBinSize.numericUpDownMax.Value;

            }

            for (int IdxSerie = 0; IdxSerie < InputSimpleData.Count; IdxSerie++)
            {
                if (InputSimpleData[IdxSerie].Count == 0) continue;

                Series NewSerie = new System.Windows.Forms.DataVisualization.Charting.Series(base.InputSimpleData[IdxSerie].Name + "_Histogram");
                NewSerie.Tag = base.InputSimpleData[IdxSerie].Tag;

                cHistogramBuilder HB = new cHistogramBuilder();
                HB.SetInputData(new cExtendedTable(InputSimpleData[IdxSerie]));

                if (this.SliderForMarkerSizeBinSize.radioButtonMinMaxAutomated.Checked)
                {
                    HB.Min = GlobalMinX;
                    HB.Max = GlobalMaxX;
                }
                else
                {
                    HB.Min = (double)this.SliderForMarkerSizeBinSize.numericUpDownMin.Value;
                    HB.Max = (double)this.SliderForMarkerSizeBinSize.numericUpDownMax.Value;
                }

                HB.IsBinNumberMode = this.SliderForMarkerSizeBinSize.radioButtonBinNumber.Checked;
                HB.BinSize = (double)this.SliderForMarkerSizeBinSize.numericUpDownBinSize.Value;

                if(this.BinNumber==-1)
                    HB.BinNumber = HB.Max - HB.Min+1;
                else
                    HB.BinNumber = this.BinNumber;

                HB.Run();

                CurrentHistogram = HB.GetOutPut();

                //if (ISPoint)
                //    NewSerie.ChartType = SeriesChartType.Point;
                //if (IsLine)
                //    NewSerie.ChartType = SeriesChartType.Line;
                //if (IsBar)
               // NewSerie.ChartType = SeriesChartType.Column;

                //NewSerie.ChartType = SeriesChartType.StackedColumn;
                if (this.Is100)
                {
                    NewSerie.ChartType = SeriesChartType.StackedColumn100;
                    base.LabelAxisY = "Frequency %";
                    base.CurrentChartArea.AxisY.Minimum = 0;
                    base.CurrentChartArea.AxisY.Maximum = 100;
                }
                else
                {

                    NewSerie.ChartType = SeriesChartType.StackedColumn;
                    base.LabelAxisY = "Frequency";
                    base.CurrentChartArea.AxisY.Minimum = Double.NaN;
                    base.CurrentChartArea.AxisY.Maximum = Double.NaN;
                 //   base.CurrentChartArea.AxisY.
                }
                //SeriesPos[i].ChartType = SeriesChartType.StackedColumn;

             //   double Step = (GlobalMaxX - GlobalMinX + 1) / CurrentHistogram[0].Count;

                for (int j = 0; j < CurrentHistogram[0].Count; j++)
                {
                    double[] Value = new double[1];
                    Value[0] = CurrentHistogram[1][j];

                    DataPoint DP = new DataPoint();
                    DP.SetValueXY(/*Step * j + GlobalMinX*/ CurrentHistogram[0][j], Value[0]);

                    DP.Tag = InputSimpleData[IdxSerie].Tag;

                    if (IsBorder)
                    {
                        DP.MarkerBorderColor = Color.Black;
                        DP.MarkerBorderWidth = 1;
                        DP.BorderColor = Color.Black;
                        DP.BorderWidth = 1;
                    }
                    else
                    {
                        DP.BorderWidth = 0;
                        DP.MarkerBorderWidth = 0;
                    }

                    if (InputSimpleData[IdxSerie].Tag != null)
                    {
                        if (InputSimpleData[IdxSerie].Tag.GetType() == typeof(cWellClassType))
                         {
                             DP.Color = ((cWellClassType)(InputSimpleData[IdxSerie].Tag)).ColourForDisplay;
                             DP.ToolTip = ((cWellClassType)(InputSimpleData[IdxSerie].Tag)).Name + "\n";
                         }
                        if (InputSimpleData[IdxSerie].Tag.GetType() == typeof(cCellularPhenotype))
                        {
                            DP.Color = ((cCellularPhenotype)(InputSimpleData[IdxSerie].Tag)).ColourForDisplay;
                            DP.ToolTip = ((cCellularPhenotype)(InputSimpleData[IdxSerie].Tag)).Name + "\n";
                        }
                    }

                    DP.ToolTip += DP.XValue.ToString("N2") + " :\n" + DP.YValues[0];

                    NewSerie.Points.Add(DP);
                }
                base.CurrentSeries.Add(NewSerie);
            }
             //   base.LabelAxisY = "Frequency";
            base.Update();
        }
示例#26
0
 public void Set_Input(cExtendedTable DataToProject)
 {
     this.DataToProject = DataToProject;
 }
示例#27
0
 public void Set_Basis(cExtendedTable Basis)
 {
     this.Basis = Basis;
 }
示例#28
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);
            //}
        }
示例#29
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);
        }
示例#30
0
 public void SetInputData(cExtendedTable MyData)
 {
     this.Input1 = MyData;
 }