예제 #1
0
        public void TraitDistributionHistogram(int traitIndex, CartesianChart chart)
        {
            if (traitHistogramDist == null)
            {
                traitHistogramDist = new HistogramChart(chart);
            }

            traitHistogramDist.AxisXTitle = "Trait Values";
            traitHistogramDist.AxisYTitle = "Proportion of Individuals";
            traitHistogramDist.RemvoeColumnSeries();

            double max, min;

            max = db.SubData[0].TraitValue[0, traitIndex];
            min = db.SubData[0].TraitValue[0, traitIndex];
            double popSize = 0.0;

            // make sure that our population is according to the size of the traits that we actually have info about them
            foreach (DataIndividualsAndTraits ind in db.SubData)
            {
                if (ind.TraitValueOk[0, traitIndex] == true)
                {
                    popSize++;
                }
            }

            for (int i = 0; i < db.SubData.Count; i++)
            {
                if (db.SubData[i].TraitValue[0, traitIndex] > max && db.SubData[i].TraitValueOk[0, traitIndex] == true)
                {
                    max = db.SubData[i].TraitValue[0, traitIndex];
                }
            }



            double twentyPrecent = 0.0, fortyPrecent = 0.0, sixtyPrecent = 0.0, eightPrecent = 0.0, onehundredPrecent = 0.0;

            for (int i = 0; i < this.db.SubData.Count; i++)
            {
                double temp = db.SubData[i].TraitValue[0, traitIndex];
                temp = temp / max;
                if (temp >= 0.0 && temp < 0.2 && db.SubData[i].TraitValueOk[0, traitIndex] == true)
                {
                    twentyPrecent++;
                }
                else if (temp >= 0.2 && temp < 0.4 && db.SubData[i].TraitValueOk[0, traitIndex] == true)
                {
                    fortyPrecent++;
                }
                else if (temp >= 0.4 && temp < 0.6 && db.SubData[i].TraitValueOk[0, traitIndex] == true)
                {
                    sixtyPrecent++;
                }
                else if (temp >= 0.6 && temp < 0.8 && db.SubData[i].TraitValueOk[0, traitIndex] == true)
                {
                    eightPrecent++;
                }
                else if (temp >= 0.8 && temp < 1.0 && db.SubData[i].TraitValueOk[0, traitIndex] == true)
                {
                    onehundredPrecent++;
                }
            }


            //get the proportion of the indivivuals
            List <string> titles = new List <string>();

            titles.Add("0.0-" + (max * 0.2).ToString("0.00"));
            titles.Add((max * 0.2).ToString("0.00") + "-" + (max * 0.4).ToString("0.00"));
            titles.Add((max * 0.4).ToString("0.00") + "-" + (max * 0.6).ToString("0.00"));
            titles.Add((max * 0.6).ToString("0.00") + "-" + (max * 0.8).ToString("0.00"));
            titles.Add((max * 0.8).ToString("0.00") + "-" + (max).ToString("0.00"));
            List <double> values = new List <double>();

            values.Add(twentyPrecent / popSize);
            values.Add(fortyPrecent / popSize);
            values.Add(sixtyPrecent / popSize);
            values.Add(eightPrecent / popSize);
            values.Add(onehundredPrecent / popSize);

            traitHistogramDist.AddColumnSeries(titles, values, ColorConstants.highliteColor);
        }
예제 #2
0
        public void PValueHistogram(CartesianChart chart)
        {
            if (PValhistChart == null)
            {
                PValhistChart = new HistogramChart(chart);
            }
            PValhistChart.AxisXTitle = "P-Value";
            PValhistChart.AxisYTitle = "Proportion of Markers %";
            PValhistChart.RemvoeColumnSeries();
            int    twentyPercent      = 0;
            int    fortyPercent       = 0;
            int    sixtyPercent       = 0;
            int    eightyPercent      = 0;
            int    oneHundrerdPercent = 0;
            double temp    = 0.0;
            double popSize = (db.SubData[0].Genotype.Length) * (db.SubData[0].TraitValue.Length) * 1.0;


            //go over all the individuals of first marker and first trait and calculate p value
            //get the answer and put it in the correct bin
            for (int i = 0; i < this.db.SubData[0].Genotype.Length; i++)
            {
                //we get the wanted genotype index
                for (int j = 0; j < this.db.SubData[0].TraitValue.Length; j++)
                {
                    //we get the wanted trait index
                    List <double> no = new List <double>();
                    List <double> n1 = new List <double>();
                    for (int k = 0; k < this.db.SubData.Count; k++)
                    {
                        if (this.db.SubData[k].Genotype[0, i] == 0)
                        {
                            no.Add(this.db.SubData[k].TraitValue[0, j]);
                        }
                        else if (this.db.SubData[k].Genotype[0, i] == 1)
                        {
                            n1.Add(this.db.SubData[k].TraitValue[0, j]);
                        }
                        //iterate over all the people and gather two groups of n0 and n1
                    }
                    //calculate the pvalue for trait and genotype and put in the correct bin
                    //temp=result of p value
                    temp = StatisticCalculations.PValueTStatistic(no, n1);
                    pLogValues.Add((-1.0 * Math.Log(temp)));
                    if (temp >= 0.0 && temp < 0.2)
                    {
                        twentyPercent++;
                    }
                    else if (temp >= 0.2 && temp < 0.4)
                    {
                        fortyPercent++;
                    }
                    else if (temp >= 0.4 && temp < 0.6)
                    {
                        sixtyPercent++;
                    }
                    else if (temp >= 0.6 && temp < 0.8)
                    {
                        eightyPercent++;
                    }
                    else if (temp >= 0.8 && temp <= 1.0)
                    {
                        oneHundrerdPercent++;
                    }
                }
            }

            List <double> pValues = new List <double>();

            pValues.Add(twentyPercent / popSize);
            pValues.Add(fortyPercent / popSize);
            pValues.Add(sixtyPercent / popSize);
            pValues.Add(eightyPercent / popSize);
            pValues.Add(oneHundrerdPercent / popSize);
            List <string> pTitles = new List <string>();

            pTitles.Add("0-20%");
            pTitles.Add("20-40%");
            pTitles.Add("40-60%");
            pTitles.Add("60-80%");
            pTitles.Add("80-100%");
            PValhistChart.AddColumnSeries(pTitles, pValues, ColorConstants.highliteColor);
        }