Esempio n. 1
0
        public static IHypothesisTestingTwoSample CreateTests(HypothesisTests test)
        {
            IHypothesisTestingTwoSample newTest = null;

            switch (test)
            {
            case HypothesisTests.TTest:
                newTest = new StudentTTest();
                break;

            case HypothesisTests.MannWhitneyU:
                newTest = new MannWhitneyTest();
                break;

            case HypothesisTests.KolmogorovSmirnov:
                newTest = new KolmogorovSmirnovTest();
                break;
            }

            return(newTest);
        }
Esempio n. 2
0
        public void TestSpectralAlignment(string basePath, string baselineName, string aligneeName,
            double comparisonCutoff)
        {
            RootDataPath = basePath;

            var featureFileX = GetTestPath(baselineName + "_isos.csv");
            var rawFileX = GetTestPath(baselineName + ".raw");

            var featureFileY = GetTestPath(aligneeName + "_isos.csv");
            var rawFileY = GetTestPath(aligneeName + ".raw");

            Print("Detecting Features");
            var baselineFeatures = FindFeatures(rawFileX, featureFileX);
            var aligneeFeatures = FindFeatures(rawFileY, featureFileY);

            Print("Aligning Features");
            // Align the features
            var aligner = new LcmsWarpFeatureAligner();
            var alignmentOptions = new AlignmentOptions();
            aligner.Options = alignmentOptions.LCMSWarpOptions;
            aligner.Align(baselineFeatures, aligneeFeatures);

            PrintFeatureMsMsData(baselineFeatures);
            PrintFeatureMsMsData(aligneeFeatures);

            var matches = GetSpectralMatches(
                baselineFeatures, aligneeFeatures, comparisonCutoff);
            Print(string.Format("Found {0} spectral matches", matches.Count));
            Print("Similarity, Pre-Alignment, Post-Alignment");

            var counts = new Dictionary<double, int>();
            counts.Add(.9, 0);
            counts.Add(.8, 0);
            counts.Add(.7, 0);
            counts.Add(.6, 0);
            counts.Add(.5, 0);

            var preDist = new List<double>();
            var postDist = new List<double>();

            foreach (var match in matches)
            {
                var baselineFeature = match.Baseline.ParentFeature.ParentFeature;
                var aligneeFeature = match.Alignee.ParentFeature.ParentFeature;

                var preAlignment = baselineFeature.Net - aligneeFeature.Net;
                var postAlignment = baselineFeature.Net - aligneeFeature.NetAligned;

                postDist.Add(postAlignment);
                preDist.Add(preAlignment);

                Print(string.Format("{0},{1},{2}", match.Similarity, preAlignment, postAlignment));

                if (match.Similarity > .9)
                {
                    counts[.9]++;
                }
                else if (match.Similarity > .8)
                {
                    counts[.8]++;
                }
                else if (match.Similarity > .7)
                {
                    counts[.7]++;
                }
                else if (match.Similarity > .6)
                {
                    counts[.6]++;
                }
            }
            Print("");
            Print("Counts");
            Print("");
            foreach (var key in counts.Keys)
            {
                Print(string.Format("{0},{1}", key, counts[key]));
            }

            var test = new MannWhitneyTest();
            var data = test.Test(preDist, postDist);
            Print(string.Format("Two Tail - {0} ", data.TwoTail));
            Print(string.Format("Left Tail - {0} ", data.LeftTail));
            Print(string.Format("Right Tail - {0} ", data.RightTail));
        }
Esempio n. 3
0
        public void TestSpectralAlignment(string basePath, string baselineName, string aligneeName,
                                          double comparisonCutoff)
        {
            RootDataPath = basePath;


            var featureFileX = GetTestPath(baselineName + "_isos.csv");
            var rawFileX     = GetTestPath(baselineName + ".raw");

            var featureFileY = GetTestPath(aligneeName + "_isos.csv");
            var rawFileY     = GetTestPath(aligneeName + ".raw");

            Print("Detecting Features");
            var baselineFeatures = FindFeatures(rawFileX, featureFileX);
            var aligneeFeatures  = FindFeatures(rawFileY, featureFileY);

            Print("Aligning Features");
            // Align the features
            var alignmentOptions = new AlignmentOptions();
            var aligner          = new LcmsWarpFeatureAligner(alignmentOptions.LCMSWarpOptions);

            aligner.Align(baselineFeatures, aligneeFeatures);

            PrintFeatureMsMsData(baselineFeatures);
            PrintFeatureMsMsData(aligneeFeatures);

            var matches = GetSpectralMatches(
                baselineFeatures, aligneeFeatures, comparisonCutoff);

            Print(string.Format("Found {0} spectral matches", matches.Count));
            Print("Similarity, Pre-Alignment, Post-Alignment");

            var counts = new Dictionary <double, int>();

            counts.Add(.9, 0);
            counts.Add(.8, 0);
            counts.Add(.7, 0);
            counts.Add(.6, 0);
            counts.Add(.5, 0);

            var preDist  = new List <double>();
            var postDist = new List <double>();

            foreach (var match in matches)
            {
                var baselineFeature = match.Baseline.ParentFeature.GetParentFeature();
                var aligneeFeature  = match.Alignee.ParentFeature.GetParentFeature();

                var preAlignment  = baselineFeature.Net - aligneeFeature.Net;
                var postAlignment = baselineFeature.Net - aligneeFeature.NetAligned;

                postDist.Add(postAlignment);
                preDist.Add(preAlignment);

                Print(string.Format("{0},{1},{2}", match.Similarity, preAlignment, postAlignment));

                if (match.Similarity > .9)
                {
                    counts[.9]++;
                }
                else if (match.Similarity > .8)
                {
                    counts[.8]++;
                }
                else if (match.Similarity > .7)
                {
                    counts[.7]++;
                }
                else if (match.Similarity > .6)
                {
                    counts[.6]++;
                }
            }
            Print("");
            Print("Counts");
            Print("");
            foreach (var key in counts.Keys)
            {
                Print(string.Format("{0},{1}", key, counts[key]));
            }

            var test = new MannWhitneyTest();
            var data = test.Test(preDist, postDist);

            Print(string.Format("Two Tail - {0} ", data.TwoTail));
            Print(string.Format("Left Tail - {0} ", data.LeftTail));
            Print(string.Format("Right Tail - {0} ", data.RightTail));
        }