コード例 #1
0
        private void Calculate(StreamWriter sw, string title, Func <IsobaricItem, double> numerator, Func <IsobaricItem, double> denominator, IEnumerable <IsobaricItem> values)
        {
            List <double> ratios = new List <double>();

            foreach (IsobaricItem m in values)
            {
                double dNumerator   = numerator(m);
                double dDenominator = denominator(m);

                if (dNumerator == ITraqConsts.NULL_INTENSITY || dDenominator == ITraqConsts.NULL_INTENSITY)
                {
                    continue;
                }

                ratios.Add(Math.Log(dNumerator / dDenominator));
            }

            QuantificationUtils.RatioStatistic(sw, title, ratios, values.Count());
        }
        private void DoStatistic(StreamWriter sw, List <IsobaricIndex> funcs, IIdentifiedResult ir)
        {
            sw.WriteLine("Dataset\tChannel\tMean[log2(Ratio)]\tStandardDeviation[log2(Ratio)]\tRatio\t95%\t99%\t99.9%\tTotalCount\tValidCount\tP<0.05\tP<0.01\tp<0.001");

            var dsNames = option.DatasetMap.Keys.OrderBy(m => m).ToList();

            foreach (var dsName in dsNames)
            {
                foreach (var func in funcs)
                {
                    var channelName = func.ChannelRatioName;

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

                    foreach (var m in ir)
                    {
                        var channelItem = m[0].FindITraqChannelItem(dsName, channelName);

                        if (null != channelItem && channelItem.HasRatio)
                        {
                            ratios.Add(Math.Log(channelItem.Ratio));
                        }
                    }

                    QuantificationUtils.RatioStatistic(sw, dsName + "\t" + channelName, ratios, ir.Count);
                }
            }

            sw.WriteLine();
            sw.WriteLine("Dataset\tChannel\tMean[log2(Ratio)]\tStandardDeviation[log2(Ratio)]\tRatio\t95%\t99%\t99.9%\tTotalCount\tValidCount\tP<0.05\tP<0.01\tp<0.001");
            //After normalization, have a look at the ratio/ratio in same dataset
            foreach (var dsName in option.DatasetMap.Keys)
            {
                for (int i = 0; i < funcs.Count; i++)
                {
                    var channelNameI = funcs[i].ChannelRatioName;
                    for (int j = i + 1; j < funcs.Count; j++)
                    {
                        var channelNameJ = funcs[j].ChannelRatioName;

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

                        foreach (var m in ir)
                        {
                            var channelItemI = m[0].FindITraqChannelItem(dsName, channelNameI);
                            var channelItemJ = m[0].FindITraqChannelItem(dsName, channelNameJ);

                            if (null != channelItemI && channelItemI.HasRatio && null != channelItemJ && channelItemJ.HasRatio)
                            {
                                ratios.Add(Math.Log(channelItemJ.Ratio / channelItemI.Ratio));
                            }
                        }

                        QuantificationUtils.RatioStatistic(sw, dsName + "\t" + funcs[j].Name + "/" + funcs[i].Name, ratios, ir.Count);
                    }
                }
            }

            sw.WriteLine();
            sw.WriteLine("Dataset\tChannel\tMean[log2(Ratio)]\tStandardDeviation[log2(Ratio)]\tRatio\t95%\t99%\t99.9%\tTotalCount\tValidCount\tP<0.05\tP<0.01\tp<0.001");
            //After normalization, have a look at the ratio/ratio in diffent dataset
            foreach (var func in funcs)
            {
                var channelName = func.ChannelRatioName;
                for (int i = 0; i < dsNames.Count; i++)
                {
                    var dsNameI = dsNames[i];
                    for (int j = i + 1; j < dsNames.Count; j++)
                    {
                        var dsNameJ = dsNames[j];

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

                        foreach (var m in ir)
                        {
                            var channelItemI = m[0].FindITraqChannelItem(dsNameI, channelName);
                            var channelItemJ = m[0].FindITraqChannelItem(dsNameJ, channelName);

                            if (null != channelItemI && channelItemI.HasRatio && null != channelItemJ && channelItemJ.HasRatio)
                            {
                                ratios.Add(Math.Log(channelItemJ.Ratio / channelItemI.Ratio));
                            }
                        }

                        QuantificationUtils.RatioStatistic(sw, dsNameJ + "/" + dsNameI + "\t" + func.Name, ratios, ir.Count);
                    }
                }
            }
            sw.WriteLine();
            sw.WriteLine("Dataset\tChannel\tMean[log2(Ratio)]\tStandardDeviation[log2(Ratio)]\tRatio\t95%\t99%\t99.9%\tTotalCount\tValidCount\tP<0.05\tP<0.01\tp<0.001");
            //After normalization, have a look at the ratio/ratio in diffent dataset
            for (int f1 = 0; f1 < funcs.Count; f1++)
            {
                var c1 = funcs[f1].ChannelRatioName;
                for (int f2 = f1 + 1; f2 < funcs.Count; f2++)
                {
                    var c2 = funcs[f2].ChannelRatioName;

                    for (int i = 0; i < dsNames.Count; i++)
                    {
                        var dsNameI = dsNames[i];
                        for (int j = i + 1; j < dsNames.Count; j++)
                        {
                            var dsNameJ = dsNames[j];

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

                            foreach (var m in ir)
                            {
                                var channelItemI = m[0].FindITraqChannelItem(dsNameI, c1);
                                var channelItemJ = m[0].FindITraqChannelItem(dsNameJ, c2);

                                if (null != channelItemI && channelItemI.HasRatio && null != channelItemJ && channelItemJ.HasRatio)
                                {
                                    ratios.Add(Math.Log(channelItemJ.Ratio / channelItemI.Ratio));
                                }
                            }

                            QuantificationUtils.RatioStatistic(sw, dsNameJ + "/" + dsNameI + "\t" + funcs[f2].Name + "/" + funcs[f1].Name, ratios, ir.Count);
                        }
                    }
                }
            }
        }