public void TestBenjaminiHochbergFdrCorrectionAgainstRWithNaNs()
        {
            var pValues = new[]
            {
                double.NaN,
                0.55418364, 0.33169014, 0.61117003, 0.79263279, 0.74714936,
                0.93567141, 0.41151512, 0.99690655, 0.57863046, 0.35048756, double.NaN,
                0.17302064, 0.58728787, 0.45285588, 0.67122903, 0.99010006,
                0.32346151, 0.02248119, 0.5575581, 0.54179022, 0.30518608
            };
            var expectedFdrs = new[]
            {
                double.NaN,
                0.87310004, 0.87310004, 0.87310004, 0.93250916, 0.93250916,
                0.99690655, 0.87310004, 0.99690655, 0.87310004, 0.87310004, double.NaN,
                0.87310004, 0.87310004, 0.87310004, 0.89497204, 0.99690655,
                0.87310004, 0.4496238, 0.87310004, 0.87310004, 0.87310004
            };

            PerseusPluginUtils.CalcBenjaminiHochbergFdr(pValues, 0.05, out var fdrs);
            for (int i = 0; i < expectedFdrs.Length; i++)
            {
                var expected = expectedFdrs[i];
                var actual   = fdrs[i];
                if (double.IsNaN(expected) && double.IsNaN(actual))
                {
                    continue;
                }
                Assert.AreEqual(expected, actual, 0.00001);
            }
        }
Beispiel #2
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
                                ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            int[]          cols       = param.GetParam <int[]>("Columns").Value;
            int            truncIndex = param.GetParam <int>("Use for truncation").Value;
            TestTruncation truncation = truncIndex == 0
                                ? TestTruncation.Pvalue
                                : (truncIndex == 1 ? TestTruncation.BenjaminiHochberg : TestTruncation.PermutationBased);
            double   threshold = param.GetParam <double>("Threshold value").Value;
            int      sideInd   = param.GetParam <int>("Side").Value;
            TestSide side;

            switch (sideInd)
            {
            case 0:
                side = TestSide.Both;
                break;

            case 1:
                side = TestSide.Left;
                break;

            case 2:
                side = TestSide.Right;
                break;

            default:
                throw new Exception("Never get here.");
            }
            foreach (int col in cols)
            {
                BaseVector r     = mdata.Values.GetColumn(col);
                double[]   pvals = CalcSignificanceA(r, side);
                string[][] fdr;
                switch (truncation)
                {
                case TestTruncation.Pvalue:
                    fdr = PerseusPluginUtils.CalcPvalueSignificance(pvals, threshold);
                    break;

                case TestTruncation.BenjaminiHochberg:
                    double[] fdrs;
                    fdr = PerseusPluginUtils.CalcBenjaminiHochbergFdr(pvals, threshold, pvals.Length, out fdrs);
                    break;

                default:
                    throw new Exception("Never get here.");
                }
                mdata.AddNumericColumn(mdata.ColumnNames[col] + " Significance A", "", pvals);
                mdata.AddCategoryColumn(mdata.ColumnNames[col] + " A significant", "", fdr);
            }
        }
        public void TestBenjaminiHochberFdrCorrectionKinactExample()
        {
            var pValues = new[]
            {
                0.5, 0.26996402, 0.17923912, 0.29354353, double.NaN
            };
            var expectedFdrs = new[]
            {
                0.5, 0.39139137, 0.39139137, 0.39139137, double.NaN
            };

            PerseusPluginUtils.CalcBenjaminiHochbergFdr(pValues, 0.05, out var fdrs);
            for (int i = 0; i < expectedFdrs.Length; i++)
            {
                Assert.AreEqual(expectedFdrs[i], fdrs[i], 0.00001);
            }
        }
        public void TestBenjaminiHochbergFdrCorrectionWithSinglePvalue()
        {
            var pValues = new[]
            {
                0.55418364,
            };
            var expectedFdrs = new[]
            {
                0.55418364,
            };

            PerseusPluginUtils.CalcBenjaminiHochbergFdr(pValues, 0.05, out var fdrs);
            for (int i = 0; i < expectedFdrs.Length; i++)
            {
                Assert.AreEqual(expectedFdrs[i], fdrs[i], 0.00001);
            }
        }
Beispiel #5
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables,
                                ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            int[] rcols = param.GetParam <int[]>("Ratio columns").Value;
            int[] icols = param.GetParam <int[]>("Intensity columns").Value;
            if (rcols.Length == 0)
            {
                processInfo.ErrString = "Please specify some ratio columns.";
                return;
            }
            if (rcols.Length != icols.Length)
            {
                processInfo.ErrString = "The number of ratio and intensity columns have to be equal.";
                return;
            }
            int            truncIndex = param.GetParam <int>("Use for truncation").Value;
            TestTruncation truncation = truncIndex == 0
                                ? TestTruncation.Pvalue
                                : (truncIndex == 1 ? TestTruncation.BenjaminiHochberg : TestTruncation.PermutationBased);
            double   threshold = param.GetParam <double>("Threshold value").Value;
            int      sideInd   = param.GetParam <int>("Side").Value;
            TestSide side;

            switch (sideInd)
            {
            case 0:
                side = TestSide.Both;
                break;

            case 1:
                side = TestSide.Left;
                break;

            case 2:
                side = TestSide.Right;
                break;

            default:
                throw new Exception("Never get here.");
            }
            for (int i = 0; i < rcols.Length; i++)
            {
                BaseVector r      = mdata.Values.GetColumn(rcols[i]);
                BaseVector intens = icols[i] < mdata.ColumnCount
                                        ? mdata.Values.GetColumn(icols[i])
                                        : new DoubleArrayVector(mdata.NumericColumns[icols[i] - mdata.ColumnCount]);
                double[]   pvals = CalcSignificanceB(r, intens, side);
                string[][] fdr;
                switch (truncation)
                {
                case TestTruncation.Pvalue:
                    fdr = PerseusPluginUtils.CalcPvalueSignificance(pvals, threshold);
                    break;

                case TestTruncation.BenjaminiHochberg:
                    fdr = PerseusPluginUtils.CalcBenjaminiHochbergFdr(pvals, threshold, out double[] fdrs);
                    break;

                default:
                    throw new Exception("Never get here.");
                }
                mdata.AddNumericColumn(mdata.ColumnNames[rcols[i]] + " Significance B", "", pvals);
                mdata.AddCategoryColumn(mdata.ColumnNames[rcols[i]] + " B significant", "", fdr);
            }
        }
 public void TestBenjaminiHochbergFdrCorrectionWithoutValues()
 {
     PerseusPluginUtils.CalcBenjaminiHochbergFdr(new double[0], 0.05, out var fdrs);
     Assert.AreEqual(0, fdrs.Length);
 }