3333# ' @param ColorValues A character vector specifying the colors for the gradient
3434# ' fill in the heatmaps. Default is \code{c("#F9F4AE", "#B44141")}.
3535# ' @param title Title for the grid of plots.
36+ # '
3637# ' @return A list with two elements:
3738# ' \describe{
3839# ' \item{plt}{A combined heatmap arranged in a grid using \code{ggpubr::ggarrange}.}
6162# ' @keywords internal
6263Heatmap_Cohen <- function (cohenlist , nrow = NULL , ncol = NULL , limits = NULL ,
6364 widthTitle = 22 , titlesize = 12 , ColorValues = NULL ,
64- title = NULL ) {
65+ title = NULL ) {
6566
6667 cohentype <- ifelse(" CohenD" %in% names(cohenlist [[1 ]]), " d" ,
6768 ifelse(" CohenF" %in% names(cohenlist [[1 ]]), " f" , NULL ))
@@ -201,7 +202,12 @@ Heatmap_Cohen <- function(cohenlist, nrow = NULL, ncol = NULL, limits = NULL,
201202# ' groups.
202203# ' - `"extensive"`: All possible groupwise contrasts, ensuring balance in the
203204# ' number of terms on each side.
204- # '
205+ # ' @param p.adjust.method Character string specifying the method to use for
206+ # ' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
207+ # ' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
208+ # ' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
209+ # ' Passed to \code{\link[stats]{p.adjust}}.
210+ # '
205211# ' @return A named list where each element corresponds to a gene signature. Each
206212# ' signature element is a list with three components:
207213# ' \describe{
@@ -227,7 +233,7 @@ Heatmap_Cohen <- function(cohenlist, nrow = NULL, ncol = NULL, limits = NULL,
227233# '
228234# ' @keywords internal
229235CohenD_allConditions <- function (data , metadata , gene_sets , variable ,
230- mode = c(" simple" ," medium" ," extensive" )) {
236+ mode = c(" simple" ," medium" ," extensive" ), p.adjust.method = " BH " ) {
231237 data <- as.data.frame(data ) # Ensure data is a data frame
232238 # Step 1: Check if variable exists in metadata
233239 if (! variable %in% colnames(metadata )) {
@@ -292,8 +298,8 @@ CohenD_allConditions <- function(data, metadata, gene_sets, variable,
292298 }
293299 }
294300
295- # Step 2: Apply BH correction within each method
296- all_padj <- lapply(all_pvalues , function (pvals ) stats :: p.adjust(pvals , method = " BH " ))
301+ # Step 2: Apply correction within each method
302+ all_padj <- lapply(all_pvalues , function (pvals ) stats :: p.adjust(pvals , method = p.adjust.method ))
297303
298304 # Step 3: Store corrected p-values back into result_list
299305 index_tracker <- list () # Track index position for each method
@@ -495,6 +501,12 @@ flatten_results <- function(nested_list) {
495501# ' downregulated).
496502# ' @param variable A string specifying the categorical variable in
497503# ' \code{metadata} used to model the gene signature scores.
504+ # ' @param p.adjust.method Character string specifying the method to use for
505+ # ' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
506+ # ' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
507+ # ' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
508+ # ' Passed to \code{\link[stats]{p.adjust}}.
509+ # '
498510# ' @return A named list where each element corresponds to a gene signature. Each
499511# ' signature element is a list with three components:
500512# ' \describe{
@@ -508,7 +520,7 @@ flatten_results <- function(nested_list) {
508520# ' }
509521# '
510522# ' @keywords internal
511- CohenF_allConditions <- function (data , metadata , gene_sets , variable ) {
523+ CohenF_allConditions <- function (data , metadata , gene_sets , variable , p.adjust.method = " BH " ) {
512524 data <- as.data.frame(data ) # Ensure data is a data frame
513525 # Step 1: Check if variable exists in metadata
514526 if (! variable %in% colnames(metadata )) {
@@ -579,8 +591,8 @@ CohenF_allConditions <- function(data, metadata, gene_sets, variable ) {
579591 }
580592 }
581593
582- # Step 2: Apply BH correction within each method
583- all_padj <- lapply(all_pvalues , function (pvals ) stats :: p.adjust(pvals , method = " BH " ))
594+ # Step 2: Apply correction within each method
595+ all_padj <- lapply(all_pvalues , function (pvals ) stats :: p.adjust(pvals , method = p.adjust.method ))
584596
585597 # Step 3: Store corrected p-values back into result_list
586598 index_tracker <- list () # Track index position for each method
0 commit comments