... | ... |
@@ -9,7 +9,8 @@ |
9 | 9 |
#' @param paired Logical. Indicates if the data is paired or not. Default is FALSE. |
10 | 10 |
#' @param var_equal Logical. Indicates if the data variances are assumed to be equal or not. Default is FALSE. |
11 | 11 |
#' @param adjust Character. Multiple comparisons correction method to adjust p-values. Available options are: "fdr" (false discovery rate), "holm", "hochberg", "hommel", "bonferroni", "BH" (Benjamini-Hochberg), and "BY" (Benjamini-Yekutieli). |
12 |
-#' |
|
12 |
+#' @param run_post_hoc Logical. Indicates if computing post-hoc tests or not. Setting this parameter to FALSE can save time for large datasets. |
|
13 |
+#' |
|
13 | 14 |
#' @export |
14 | 15 |
#' |
15 | 16 |
#' @return A `list` with the results. |
... | ... |
@@ -51,7 +52,8 @@ PomaUnivariate <- function(data, |
51 | 52 |
covs = NULL, |
52 | 53 |
paired = FALSE, |
53 | 54 |
var_equal = FALSE, |
54 |
- adjust = "fdr"){ |
|
55 |
+ adjust = "fdr", |
|
56 |
+ run_post_hoc = TRUE){ |
|
55 | 57 |
|
56 | 58 |
if(!is(data, "SummarizedExperiment")){ |
57 | 59 |
stop("data is not a SummarizedExperiment object. \nSee POMA::PomaCreateObject or SummarizedExperiment::SummarizedExperiment") |
... | ... |
@@ -133,15 +135,19 @@ PomaUnivariate <- function(data, |
133 | 135 |
dplyr::as_tibble() |
134 | 136 |
|
135 | 137 |
# Post-hoc tests |
136 |
- post_hoc_tests <- list() |
|
137 |
- for (i in 1:nrow(SummarizedExperiment::assay(data))) { |
|
138 |
- post_hoc_tests[[i]] <- dplyr::tibble(feature = rownames(SummarizedExperiment::assay(data))[i], |
|
139 |
- broom::tidy(TukeyHSD(aov(to_univariate[,i] ~ group_factor)))[,c(2, 7)]) |
|
138 |
+ if (run_post_hoc) { |
|
139 |
+ post_hoc_tests <- list() |
|
140 |
+ for (i in 1:nrow(SummarizedExperiment::assay(data))) { |
|
141 |
+ post_hoc_tests[[i]] <- dplyr::tibble(feature = rownames(SummarizedExperiment::assay(data))[i], |
|
142 |
+ broom::tidy(TukeyHSD(aov(to_univariate[,i] ~ group_factor)))[,c(2, 7)]) |
|
143 |
+ } |
|
144 |
+ |
|
145 |
+ post_hoc_tests <- dplyr::bind_rows(post_hoc_tests) %>% |
|
146 |
+ dplyr::rename(adj_pvalue = adj.p.value) %>% |
|
147 |
+ dplyr::arrange(adj_pvalue) |
|
148 |
+ } else { |
|
149 |
+ post_hoc_tests <- NULL |
|
140 | 150 |
} |
141 |
- |
|
142 |
- post_hoc_tests <- dplyr::bind_rows(post_hoc_tests) %>% |
|
143 |
- dplyr::rename(adj_pvalue = adj.p.value) %>% |
|
144 |
- dplyr::arrange(adj_pvalue) |
|
145 | 151 |
|
146 | 152 |
return(list(result = res_aov, |
147 | 153 |
post_hoc_tests = post_hoc_tests)) |
... | ... |
@@ -174,20 +180,24 @@ PomaUnivariate <- function(data, |
174 | 180 |
dplyr::as_tibble() |
175 | 181 |
|
176 | 182 |
# Post-hoc tests |
177 |
- post_hoc_tests <- list() |
|
178 |
- for (i in 1:nrow(SummarizedExperiment::assay(data))) { |
|
179 |
- post_hoc_tests[[i]] <- dplyr::tibble(feature = rownames(SummarizedExperiment::assay(data))[i], |
|
180 |
- as.data.frame(TukeyHSD( |
|
181 |
- aov(as.formula(paste(colnames(covariates_feat)[1], "~", model_names)), |
|
182 |
- data = covariates_feat))$group_factor) %>% |
|
183 |
- tibble::rownames_to_column("contrast") %>% |
|
184 |
- dplyr::select(contrast, adj_pvalue = `p adj`) |
|
185 |
- ) |
|
183 |
+ if (run_post_hoc) { |
|
184 |
+ post_hoc_tests <- list() |
|
185 |
+ for (i in 1:nrow(SummarizedExperiment::assay(data))) { |
|
186 |
+ post_hoc_tests[[i]] <- dplyr::tibble(feature = rownames(SummarizedExperiment::assay(data))[i], |
|
187 |
+ as.data.frame(TukeyHSD( |
|
188 |
+ aov(as.formula(paste(colnames(covariates_feat)[1], "~", model_names)), |
|
189 |
+ data = covariates_feat))$group_factor) %>% |
|
190 |
+ tibble::rownames_to_column("contrast") %>% |
|
191 |
+ dplyr::select(contrast, adj_pvalue = `p adj`) |
|
192 |
+ ) |
|
193 |
+ } |
|
194 |
+ |
|
195 |
+ post_hoc_tests <- dplyr::bind_rows(post_hoc_tests) %>% |
|
196 |
+ dplyr::arrange(adj_pvalue) |
|
197 |
+ } else { |
|
198 |
+ post_hoc_tests <- NULL |
|
186 | 199 |
} |
187 | 200 |
|
188 |
- post_hoc_tests <- dplyr::bind_rows(post_hoc_tests) %>% |
|
189 |
- dplyr::arrange(adj_pvalue) |
|
190 |
- |
|
191 | 201 |
return(list(result = res_aov_cov, |
192 | 202 |
post_hoc_tests = post_hoc_tests)) |
193 | 203 |
} |
... | ... |
@@ -226,19 +236,23 @@ PomaUnivariate <- function(data, |
226 | 236 |
dplyr::as_tibble() |
227 | 237 |
|
228 | 238 |
# Post-hoc tests |
229 |
- post_hoc_tests <- list() |
|
230 |
- for (i in 1:nrow(SummarizedExperiment::assay(data))) { |
|
231 |
- post_hoc_tests[[i]] <- dplyr::tibble(feature = rownames(SummarizedExperiment::assay(data))[i], |
|
232 |
- FSA::dunnTest(to_univariate[,i] ~ group_factor, |
|
233 |
- data = as.data.frame(to_univariate))$res |
|
234 |
- ) |
|
239 |
+ if (run_post_hoc) { |
|
240 |
+ post_hoc_tests <- list() |
|
241 |
+ for (i in 1:nrow(SummarizedExperiment::assay(data))) { |
|
242 |
+ post_hoc_tests[[i]] <- dplyr::tibble(feature = rownames(SummarizedExperiment::assay(data))[i], |
|
243 |
+ FSA::dunnTest(to_univariate[,i] ~ group_factor, |
|
244 |
+ data = as.data.frame(to_univariate))$res |
|
245 |
+ ) |
|
246 |
+ } |
|
247 |
+ |
|
248 |
+ post_hoc_tests <- dplyr::bind_rows(post_hoc_tests) %>% |
|
249 |
+ dplyr::select(feature, contrast = Comparison, adj_pvalue = P.adj) %>% |
|
250 |
+ dplyr::mutate(contrast = gsub(" ", "", contrast)) %>% |
|
251 |
+ dplyr::arrange(adj_pvalue) |
|
252 |
+ } else { |
|
253 |
+ post_hoc_tests <- NULL |
|
235 | 254 |
} |
236 | 255 |
|
237 |
- post_hoc_tests <- dplyr::bind_rows(post_hoc_tests) %>% |
|
238 |
- dplyr::select(feature, contrast = Comparison, adj_pvalue = P.adj) %>% |
|
239 |
- dplyr::mutate(contrast = gsub(" ", "", contrast)) %>% |
|
240 |
- dplyr::arrange(adj_pvalue) |
|
241 |
- |
|
242 | 256 |
return(list(result = res_kruskal, |
243 | 257 |
post_hoc_tests = post_hoc_tests)) |
244 | 258 |
} |
... | ... |
@@ -16,7 +16,7 @@ output: github_document |
16 | 16 |
| _BioC_ branch | Status | Version | Dependencies | Rank | |
17 | 17 |
|- |- |- |- |- | |
18 | 18 |
| [Release](http://bioconductor.org/packages/release/bioc/html/POMA.html) | [](https://bioconductor.org/checkResults/release/bioc-LATEST/POMA/) | [](https://www.bioconductor.org/packages/POMA) | [](http://bioconductor.org/packages/release/bioc/html/POMA.html#since) | [](https://bioconductor.org/packages/stats/bioc/POMA) | |
19 |
-| [Devel](http://bioconductor.org/packages/devel/bioc/html/POMA.html) | [](https://bioconductor.org/checkResults/devel/bioc-LATEST/POMA/) | [](https://bioconductor.org/packages/devel/bioc/html/POMA.html) | [](http://bioconductor.org/packages/devel/bioc/html/POMA.html#since) | [](https://bioconductor.org/packages/stats/bioc/POMA) | |
|
19 |
+| [Devel](http://bioconductor.org/packages/devel/bioc/html/POMA.html) | [](https://bioconductor.org/checkResults/devel/bioc-LATEST/POMA/) | [](https://bioconductor.org/packages/devel/bioc/html/POMA.html) | [](http://bioconductor.org/packages/devel/bioc/html/POMA.html#since) | [](https://bioconductor.org/packages/stats/bioc/POMA) | |
|
20 | 20 |
|
21 | 21 |
<!-- badges: end --> |
22 | 22 |
|
... | ... |
@@ -18,7 +18,7 @@ v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/li |
18 | 18 |
| *BioC* branch | Status | Version | Dependencies | Rank | |
19 | 19 |
|-------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------| |
20 | 20 |
| [Release](http://bioconductor.org/packages/release/bioc/html/POMA.html) | [](https://bioconductor.org/checkResults/release/bioc-LATEST/POMA/) | [](https://www.bioconductor.org/packages/POMA) | [](http://bioconductor.org/packages/release/bioc/html/POMA.html#since) | [](https://bioconductor.org/packages/stats/bioc/POMA) | |
21 |
-| [Devel](http://bioconductor.org/packages/devel/bioc/html/POMA.html) | [](https://bioconductor.org/checkResults/devel/bioc-LATEST/POMA/) | [](https://bioconductor.org/packages/devel/bioc/html/POMA.html) | [](http://bioconductor.org/packages/devel/bioc/html/POMA.html#since) | [](https://bioconductor.org/packages/stats/bioc/POMA) | |
|
21 |
+| [Devel](http://bioconductor.org/packages/devel/bioc/html/POMA.html) | [](https://bioconductor.org/checkResults/devel/bioc-LATEST/POMA/) | [](https://bioconductor.org/packages/devel/bioc/html/POMA.html) | [](http://bioconductor.org/packages/devel/bioc/html/POMA.html#since) | [](https://bioconductor.org/packages/stats/bioc/POMA) | |
|
22 | 22 |
|
23 | 23 |
<!-- badges: end --> |
24 | 24 |
|
... | ... |
@@ -10,7 +10,8 @@ PomaUnivariate( |
10 | 10 |
covs = NULL, |
11 | 11 |
paired = FALSE, |
12 | 12 |
var_equal = FALSE, |
13 |
- adjust = "fdr" |
|
13 |
+ adjust = "fdr", |
|
14 |
+ run_post_hoc = TRUE |
|
14 | 15 |
) |
15 | 16 |
} |
16 | 17 |
\arguments{ |
... | ... |
@@ -25,6 +26,8 @@ PomaUnivariate( |
25 | 26 |
\item{var_equal}{Logical. Indicates if the data variances are assumed to be equal or not. Default is FALSE.} |
26 | 27 |
|
27 | 28 |
\item{adjust}{Character. Multiple comparisons correction method to adjust p-values. Available options are: "fdr" (false discovery rate), "holm", "hochberg", "hommel", "bonferroni", "BH" (Benjamini-Hochberg), and "BY" (Benjamini-Yekutieli).} |
29 |
+ |
|
30 |
+\item{run_post_hoc}{Logical. Indicates if computing post-hoc tests or not. Setting this parameter to FALSE can save time for large datasets.} |
|
28 | 31 |
} |
29 | 32 |
\value{ |
30 | 33 |
A \code{list} with the results. |