Skip to content

Commit 85edcb6

Browse files
committed
Add option to set p-vlaues==0 to the next smallest value
1 parent ca1e497 commit 85edcb6

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

R/workflow_ttest.R

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#' If \code{TRUE}, the data will be log-transformed.
1616
#' @param delog_for_FC \strong{logical} \cr
1717
#' If \code{TRUE}, the fold change will be calculated without the log-transformation.
18+
#' @param p_value_zeros_to_min \strong{logical} \cr
19+
#' If \code{TRUE}, then \code{p_values == 0} will be set to the next smallest value of the p-values.
1820
#'
1921
#' @param significant_after_FDR \strong{logical} \cr
2022
#' If \code{TRUE}, candidates for the boxplots and heatmap need to be significant after FDR correction, otherwise all significant candidates will be used.
@@ -70,6 +72,7 @@ workflow_ttest <- function(data_path,
7072
var.equal = FALSE,
7173
log_before_test = TRUE,
7274
delog_for_FC = TRUE,
75+
p_value_zeros_to_min = TRUE,
7376

7477
significant_after_FDR = TRUE,
7578
max_valid_values_off = 0,
@@ -110,6 +113,22 @@ workflow_ttest <- function(data_path,
110113
ifelse(delog_for_FC, "", "not"),
111114
"de-log-transformed for the fold change. \n")
112115

116+
117+
if(p_value_zeros_to_min){
118+
119+
p_value_zero <- which(test_results$p == 0)
120+
121+
if(length(p_value_zero) > 0){
122+
next_smallest_value <- sort(unique(test_results$p))[2]
123+
124+
test_results$p[test_results$p == 0] <- next_smallest_value
125+
126+
mess <- paste0(mess, "There were ", length(p_value_zero), " p_values, which were 0. ",
127+
"They were set to the next smallest occuring value ", next_smallest_value, ". \n")
128+
}
129+
}
130+
131+
113132
fc_col_name <- paste0("FC_", levels(data[["group"]])[[1]], "_divided_by_", levels(data[["group"]])[[2]])
114133

115134

@@ -244,6 +263,8 @@ workflow_ttest <- function(data_path,
244263
#' If \code{TRUE}, the data will be log-transformed.
245264
#' @param delog_for_FC \strong{logical} \cr
246265
#' If \code{TRUE}, the fold change will be calculated without the log-transformation.
266+
#' @param p_value_zeros_to_min \strong{logical} \cr
267+
#' If \code{TRUE}, then \code{p_values == 0} will be set to the next smallest value of the p-values.
247268
#'
248269
#' @param significant_after_FDR \strong{logical} \cr
249270
#' If \code{TRUE}, candidates for the boxplots and heatmap need to be significant after FDR correction, otherwise all significant candidates will be used.
@@ -301,6 +322,7 @@ workflow_ANOVA <- function(data_path,
301322
var.equal = TRUE,
302323
log_before_test = TRUE,
303324
delog_for_FC = TRUE,
325+
p_value_zeros_to_min = TRUE,
304326

305327
significant_after_FDR = TRUE,
306328
max_valid_values_off = 0,
@@ -336,6 +358,21 @@ workflow_ANOVA <- function(data_path,
336358
mess <- paste0(mess, "ANOVA calculated. \n")
337359

338360

361+
if(p_value_zeros_to_min){
362+
363+
p_value_zero <- which(ANOVA_results$p.anova == 0)
364+
365+
if(length(p_value_zero) > 0){
366+
next_smallest_value <- sort(unique(ANOVA_results$p.anova))[2]
367+
368+
ANOVA_results$p.anova[ANOVA_results$p.anova == 0] <- next_smallest_value
369+
370+
mess <- paste0(mess, "There were ", length(p_value_zero), " p_values, which were 0. ",
371+
"They were set to the next smallest occuring value ", next_smallest_value, ". \n")
372+
}
373+
}
374+
375+
339376

340377
#### Create Volcano Plot ####
341378

man/workflow_ANOVA.Rd

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/workflow_ttest.Rd

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)