Package: DiscreteFDR Check: examples New result: ERROR Running examples in ‘DiscreteFDR-Ex.R’ failed The error most likely occurred in: > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: fast.Discrete > ### Title: Fast Application of Discrete Multiple Testing Procedures > ### Aliases: fast.Discrete > > ### ** Examples > > X1 <- c(4, 2, 2, 14, 6, 9, 4, 0, 1) > X2 <- c(0, 0, 1, 3, 2, 1, 2, 2, 2) > N1 <- rep(148, 9) > N2 <- rep(132, 9) > Y1 <- N1 - X1 > Y2 <- N2 - X2 > df <- data.frame(X1, Y1, X2, Y2) > df X1 Y1 X2 Y2 1 4 144 0 132 2 2 146 0 132 3 2 146 1 131 4 14 134 3 129 5 6 142 2 130 6 9 139 1 131 7 4 144 2 130 8 0 148 2 130 9 1 147 2 130 > > DBH.su <- fast.Discrete(df, input = "noassoc", direction = "su") Warning: `fast.Discrete()` was deprecated in DiscreteFDR 1.3.7. ℹ Please use `direct.discrete.BH()` instead. Error: ! `fisher.test.pv()` was deprecated in DiscreteTests 0.2 and is now defunct. ℹ Please use `fisher_test_pv()` instead. Backtrace: ▆ 1. └─DiscreteFDR::fast.Discrete(df, input = "noassoc", direction = "su") 2. └─DiscreteFDR::fisher.pvalues.support(counts, alternative, input) 3. └─DiscreteTests::fisher.test.pv(counts, alternative) 4. └─lifecycle::deprecate_stop("0.2", "fisher.test.pv()", "fisher_test_pv()") 5. └─lifecycle:::deprecate_stop0(msg) 6. └─rlang::cnd_signal(...) Execution halted Package: DiscreteFDR Check: re-building of vignette outputs New result: ERROR Error(s) in re-building vignettes: ... --- re-building ‘DiscreteFDR.Rmd’ using rmarkdown # 1. A Toy Example To give a first impression of how **DiscreteFDR** works, we consider an artificial toy example. A more realistic example involving pharmacovigilance data is given in Section 2. Suppose we would like to compare two treatments in nine different populations. For each population we do this by evaluating the responders and non-responders for each treatment. This leads to categorical data which can be represented, for each population $i = 1, \ldots, 9$ in the following 2 $\times$ 2 table: | | Responders | Non-responders | | |:------------ |:-------------------:|:-------------------:|:-----------------------:| | Treatment 1 | $x_{1i}$ | $y_{1i}$ | $n_{1i}$ | | Treatment 2 | $x_{2i}$ | $y_{2i}$ | $n_{2i}$ | | **Total** | $x_{1i} + x_{2i}$ | $y_{1i} + y_{2i}$ | $n = n_{1i} + n_{2i}$ | Denoting the responder probabilities for population $i$ by $\pi_{1i}$ and $\pi_{2i}$ we can test e.g. $$H_{0i}: \pi_{1i} = \pi_{2i} \qquad \text{vs.} \qquad H_{1i}: \pi_{1i} \neq \pi_{2i}$$ by using Fisher's (two-sided) exact test (see [Lehmann and Romano (2006)](https://doi.org/10.1214/009053605000000084)), which is implemented in the **R** function `fisher.test`. Suppose the data in the nine populations are independent and we observe the following data frame `df` ``` r library(knitr) X1 <- c(4, 2, 2, 14, 6, 9, 4, 0, 1) X2 <- c(0, 0, 1, 3, 2, 1, 2, 2, 2) N1 <- rep(148, 9) N2 <- rep(132, 9) Y1 <- N1 - X1 Y2 <- N2 - X2 df <- data.frame(X1, Y1, X2, Y2) kable(df, caption = "Toy Example") ``` Table: Toy Example | X1| Y1| X2| Y2| |--:|---:|--:|---:| | 4| 144| 0| 132| | 2| 146| 0| 132| | 2| 146| 1| 131| | 14| 134| 3| 129| | 6| 142| 2| 130| | 9| 139| 1| 131| | 4| 144| 2| 130| | 0| 148| 2| 130| | 1| 147| 2| 130| In this data frame each of the 9 rows represents the data of an observed 2 $\times$ 2 table: e.g., the third row of the data corresponds to $x_{13} = 2, y_{13} = 146, x_{23} = 1, y_{23} = 131$. Even though in this example, the total number of tested hypotheses $m = 9$ is very small, for illustrative purposes we deal with the multiplicity problem here by controlling FDR at level $\alpha = 5\%$. The DBH step-down procedure can be applied directly to the data frame object `df` and perform Fisher's exact test in-between. This yields an S3 object of class `DiscreteFDR`, for which we provide both `print` and `summary` methods: ``` r library(DiscreteFDR) DBH.sd.fast <- direct.discrete.BH(df, "fisher", direction = "sd") print(DBH.sd.fast) #> #> Discrete Benjamini-Hochberg procedure (step-down) #> #> Data: df #> Number of tests = 9 #> Number of rejections = 2 at global FDR level 0.05 #> (Original BH rejections = 0) #> Largest rejected p-value: 0.02126871 summary(DBH.sd.fast) #> #> Discrete Benjamini-Hochberg procedure (step-down) #> #> Data: df #> Number of tests = 9 #> Number of rejections = 2 at global FDR level 0.05 #> (Original BH rejections = 0) #> Largest rejected p-value: 0.02126871 #> #> Index P.value Adjusted Rejected #> 1 4 0.01243145 0.03819796 TRUE #> 2 6 0.02126871 0.03819796 TRUE #> 3 1 0.12476691 0.25630985 FALSE #> 4 8 0.22135177 0.47895996 FALSE #> 5 5 0.28849298 0.51482782 FALSE #> 6 2 0.49984639 1.00000000 FALSE #> 7 9 0.60329543 1.00000000 FALSE #> 8 7 0.68723229 1.00000000 FALSE #> 9 3 1.00000000 1.00000000 FALSE ``` The output of the `summary` function contains the same output as the `print` method, but adds a table that lists the raw $p$-values, their adjusted counterparts and their respective rejection decisions. It is sorted by raw $p$-values in ascending order. Our `summary` method actually creates a `summary.DiscreteFDR` object, which includes all contents of an `DiscreteFDR` object plus the aforementioned table. This table can be accessed directly by the `$Table` command. ``` r DBH.sd.fast.summary <- summary(DBH.sd.fast) summary.table <- DBH.sd.fast.summary$Table kable(summary.table, caption = "Summary table") ``` Table: Summary table | Index| P.value| Adjusted|Rejected | |-----:|---------:|---------:|:--------| | 4| 0.0124314| 0.0381980|TRUE | | 6| 0.0212687| 0.0381980|TRUE | | 1| 0.1247669| 0.2563098|FALSE | | 8| 0.2213518| 0.4789600|FALSE | | 5| 0.2884930| 0.5148278|FALSE | | 2| 0.4998464| 1.0000000|FALSE | | 9| 0.6032954| 1.0000000|FALSE | | 7| 0.6872323| 1.0000000|FALSE | | 3| 1.0000000| 1.0000000|FALSE | Thus we can reject two hypotheses at FDR-level $\alpha = 5\%$. Note, that our `print` method also gives the number of rejections of the usual (continuous) BH procedure. In order to compare its adjusted $p$-values with ours, we have to determine the raw $p$-values first. This would be possible by applying the `fisher.test` function to all nine 2 $\times$ 2 tables. Alternatively, we may use the more convenient function `generate.pvalues`, which is included in our package, for accessing the raw $p$-values. Since it only accept hypothesis test functions from the package `DiscreteTests` (either as a function object or a character string that can be abbreviated), we could also use such a function directly, e.g. `fisher.test.pv`. An even more simple way is to extract them from the `DiscreteFDR` object that we obtained before and contains the results: Quitting from ./toyexample.Rmd:60-76 [toy-example-generate-fisher] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: ! `fisher.test.pv()` was deprecated in DiscreteTests 0.2 and is now defunct. ℹ Please use `fisher_test_pv()` instead. --- Backtrace: ▆ 1. └─DiscreteTests::fisher.test.pv(df, "two.sided") 2. └─lifecycle::deprecate_stop("0.2", "fisher.test.pv()", "fisher_test_pv()") 3. └─lifecycle:::deprecate_stop0(msg) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Quitting from DiscreteFDR.Rmd:35-36 [unnamed-chunk-1] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: ! `fisher.test.pv()` was deprecated in DiscreteTests 0.2 and is now defunct. ℹ Please use `fisher_test_pv()` instead. --- Backtrace: ▆ 1. └─DiscreteTests::fisher.test.pv(df, "two.sided") 2. └─lifecycle::deprecate_stop("0.2", "fisher.test.pv()", "fisher_test_pv()") 3. └─lifecycle:::deprecate_stop0(msg) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: processing vignette 'DiscreteFDR.Rmd' failed with diagnostics: `fisher.test.pv()` was deprecated in DiscreteTests 0.2 and is now defunct. ℹ Please use `fisher_test_pv()` instead. --- failed re-building ‘DiscreteFDR.Rmd’ --- re-building ‘furtheranalyses.Rmd’ using rmarkdown Quitting from furtheranalyses.Rmd:29-35 [unnamed-chunk-1] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: ! `fisher.test.pv()` was deprecated in DiscreteTests 0.2 and is now defunct. ℹ Please use `fisher_test_pv()` instead. --- Backtrace: ▆ 1. └─DiscreteTests::fisher.test.pv(reconstruct_two(amnesia), alternative = "greater") 2. └─lifecycle::deprecate_stop("0.2", "fisher.test.pv()", "fisher_test_pv()") 3. └─lifecycle:::deprecate_stop0(msg) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: processing vignette 'furtheranalyses.Rmd' failed with diagnostics: `fisher.test.pv()` was deprecated in DiscreteTests 0.2 and is now defunct. ℹ Please use `fisher_test_pv()` instead. --- failed re-building ‘furtheranalyses.Rmd’ --- re-building ‘toyexample.Rmd’ using rmarkdown Quitting from toyexample.Rmd:60-76 [toy-example-generate-fisher] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: ! `fisher.test.pv()` was deprecated in DiscreteTests 0.2 and is now defunct. ℹ Please use `fisher_test_pv()` instead. --- Backtrace: ▆ 1. └─DiscreteTests::fisher.test.pv(df, "two.sided") 2. └─lifecycle::deprecate_stop("0.2", "fisher.test.pv()", "fisher_test_pv()") 3. └─lifecycle:::deprecate_stop0(msg) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Error: processing vignette 'toyexample.Rmd' failed with diagnostics: `fisher.test.pv()` was deprecated in DiscreteTests 0.2 and is now defunct. ℹ Please use `fisher_test_pv()` instead. --- failed re-building ‘toyexample.Rmd’ --- re-building ‘DiscreteFDR_vignette.pdf.asis’ using asis --- finished re-building ‘DiscreteFDR_vignette.pdf.asis’ SUMMARY: processing the following files failed: ‘DiscreteFDR.Rmd’ ‘furtheranalyses.Rmd’ ‘toyexample.Rmd’ Error: Vignette re-building failed. Execution halted Package: FDX Check: examples New result: ERROR Running examples in ‘FDX-Ex.R’ failed The error most likely occurred in: > base::assign(".ptime", proc.time(), pos = "CheckExEnv") > ### Name: fast.Discrete > ### Title: Fast application of discrete procedures > ### Aliases: fast.Discrete fast.Discrete.LR fast.Discrete.GR > ### fast.Discrete.PB > > ### ** Examples > > > X1 <- c(4, 2, 2, 14, 6, 9, 4, 0, 1) > X2 <- c(0, 0, 1, 3, 2, 1, 2, 2, 2) > N1 <- rep(148, 9) > N2 <- rep(132, 9) > Y1 <- N1 - X1 > Y2 <- N2 - X2 > df <- data.frame(X1, Y1, X2, Y2) > df X1 Y1 X2 Y2 1 4 144 0 132 2 2 146 0 132 3 2 146 1 131 4 14 134 3 129 5 6 142 2 130 6 9 139 1 131 7 4 144 2 130 8 0 148 2 130 9 1 147 2 130 > > # DLR > DLR.sd <- fast.Discrete.LR(counts = df, input = "noassoc") Warning: `fast.Discrete.LR()` was deprecated in FDX 2.0.0. ℹ Please use `direct.discrete.LR()` instead. Error: ! `fisher.test.pv()` was deprecated in DiscreteTests 0.2 and is now defunct. ℹ Please use `fisher_test_pv()` instead. Backtrace: ▆ 1. └─FDX::fast.Discrete.LR(counts = df, input = "noassoc") 2. └─DiscreteFDR::fisher.pvalues.support(counts, alternative, input) 3. └─DiscreteTests::fisher.test.pv(counts, alternative) 4. └─lifecycle::deprecate_stop("0.2", "fisher.test.pv()", "fisher_test_pv()") 5. └─lifecycle:::deprecate_stop0(msg) 6. └─rlang::cnd_signal(...) Execution halted