Skip to content

Commit 5baf1a2

Browse files
authored
Merge pull request #79 from DiseaseTranscriptomicsLab/main
v1.1.1
2 parents 2da37c5 + 6baef37 commit 5baf1a2

24 files changed

Lines changed: 1048 additions & 54 deletions

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: markeR
22
Title: An R Toolkit for Evaluating Gene Signatures as Phenotypic Markers
3-
Version: 1.1.0
3+
Version: 1.1.1
44
Authors@R:
55
c(
66
person("Rita", "Martins-Silva",
@@ -25,7 +25,7 @@ Encoding: UTF-8
2525
Language: en-GB
2626
LazyData: false
2727
Roxygen: list(markdown = TRUE)
28-
RoxygenNote: 7.3.2
28+
RoxygenNote: 7.3.3
2929
Additional_repositories: https://bioconductor.org/packages/release/bioc
3030
Imports:
3131
circlize,

NEWS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# markeR 1.1.1 (11 Mar, 2026)
2+
3+
- Added `p.adjust.method` parameter across all functions performing or
4+
depending on multiple testing correction, allowing users to specify
5+
any correction method supported by `stats::p.adjust()`, beyond the default
6+
Benjamini-Hochberg FDR.
7+
- Added Python bridge scripts in `inst/python/` for users who wish to call
8+
markeR from a Python environment via `rpy2`. Includes a tutorial workflow
9+
script and a generic command-line wrapper capable of invoking any exported
10+
markeR function. See `inst/python/README.md` for installation and usage.
11+
12+
# markeR 1.0.0 (31 Oct, 2025)
13+
14+
- Official Bioconductor Release.
15+
116
# markeR 0.99.5 (17 Sep, 2025)
217

318
- Minor fix in `.onAttach()` to avoid errors when checking `ggplot2` version and ensure the startup warning works correctly.

R/FPR_Simulation.R

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ utils::globalVariables(c( "cohen", "method", "contrast" ))
4444
#' grid layout. If `NULL`, layout is auto-calculated.
4545
#' @param nrow Integer. Number of rows for arranging signature plots in a grid
4646
#' layout. If `NULL`, layout is auto-calculated.
47-
#'
47+
#' @param p.adjust.method Character string specifying the method to use for
48+
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
49+
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
50+
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
51+
#' Passed to \code{\link[stats]{p.adjust}}.
4852
#'
4953
#' @return Invisibly returns a list containing:
5054
#' \describe{
@@ -111,7 +115,7 @@ FPR_Simulation <- function(data, metadata, original_signatures, Variable,
111115
gene_list = NULL, number_of_sims=100, title=NULL,
112116
widthTitle = 30, titlesize = 12, pointSize = 2,
113117
labsize = 10,mode = c( "none","simple","medium","extensive"),
114-
ColorValues=NULL, ncol=NULL, nrow=NULL) {
118+
ColorValues=NULL, ncol=NULL, nrow=NULL, p.adjust.method="BH") {
115119
data <- as.data.frame(data) # Ensure data is a data frame
116120
if (is.null(gene_list)) gene_list <- row.names(data)
117121

@@ -128,7 +132,7 @@ FPR_Simulation <- function(data, metadata, original_signatures, Variable,
128132
results <- suppressMessages(CohenF_allConditions(data = data,
129133
metadata = metadata,
130134
gene_sets = original_signatures,
131-
variable = Variable ))
135+
variable = Variable, p.adjust.method = p.adjust.method ))
132136
cohentype <- "f"
133137

134138
} else {
@@ -138,15 +142,15 @@ FPR_Simulation <- function(data, metadata, original_signatures, Variable,
138142
results <- suppressMessages(CohenF_allConditions(data = data,
139143
metadata = metadata,
140144
gene_sets = original_signatures,
141-
variable = Variable ))
145+
variable = Variable, p.adjust.method = p.adjust.method ))
142146
cohentype <- "f"
143147

144148
} else {
145149

146150
results <- suppressMessages(CohenD_allConditions(data = data,
147151
metadata = metadata,
148152
gene_sets = original_signatures,
149-
variable = Variable, mode = mode))
153+
variable = Variable, mode = mode, p.adjust.method = p.adjust.method))
150154
cohentype <- "d"
151155

152156
}
@@ -219,14 +223,14 @@ FPR_Simulation <- function(data, metadata, original_signatures, Variable,
219223
metadata = metadata,
220224
gene_sets = simulatedsigs,
221225
variable = Variable,
222-
mode = mode
226+
mode = mode, p.adjust.method = p.adjust.method
223227
))
224228
} else {
225229
results2 <- suppressMessages(CohenF_allConditions(
226230
data = data,
227231
metadata = metadata,
228232
gene_sets = simulatedsigs,
229-
variable = Variable
233+
variable = Variable, p.adjust.method = p.adjust.method
230234
))
231235
}
232236

R/GSEA_VariableAssociation.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@
5757
#' removed before analysis, leading to a loss of data to be fitted in the
5858
#' model.
5959
#' @param printplt Boolean specifying if plot is to be printed. Default: `TRUE`.
60-
#'
60+
#' @param p.adjust.method Character string specifying the method to use for
61+
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
62+
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
63+
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
64+
#' Passed to \code{\link[stats]{p.adjust}}.
65+
#'
6166
#' @return A list with two elements:
6267
#' - `data`: A data frame containing the GSEA results, including normalized
6368
#' enrichment scores (NES), adjusted p-values, and contrasts.
@@ -70,7 +75,8 @@ GSEA_VariableAssociation <- function(data, metadata, cols, stat=NULL,
7075
signif_color = "red", saturation_value=NULL,
7176
sig_threshold = 0.05, widthlabels=18,
7277
labsize=10, titlesize=14, pointSize=5,
73-
ignore_NAs = FALSE, printplt =TRUE) {
78+
ignore_NAs = FALSE, printplt =TRUE,
79+
p.adjust.method = "BH") {
7480
data <- as.data.frame(data) # Ensure data is a data frame
7581
mode <- match.arg(mode)
7682
metadata <- metadata[, cols %in% colnames(metadata), drop = FALSE]
@@ -129,7 +135,7 @@ GSEA_VariableAssociation <- function(data, metadata, cols, stat=NULL,
129135
combined_results$Contrast <- cont_vec
130136

131137
# correct adjusted p value to correct for multiple testing for the contrasts?
132-
combined_results$padj <- stats::p.adjust(combined_results$padj, method = "BH")
138+
combined_results$padj <- stats::p.adjust(combined_results$padj, method = p.adjust.method)
133139

134140

135141
combined_results_toreturn <- combined_results

R/Heatmap_Cohen.R

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
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}.}
@@ -61,7 +62,7 @@
6162
#' @keywords internal
6263
Heatmap_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
229235
CohenD_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

R/PlotScores.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ utils::globalVariables(c("score"))
114114
#' @param cor Correlation method for numeric variables. One of `"pearson"`
115115
#' (default), `"spearman"`, or `"kendall"`. Only applies when the variable is
116116
#' numeric and `method != "all"`.
117-
#'
117+
#' @param p.adjust.method Character string specifying the method to use for
118+
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
119+
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
120+
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
121+
#' Passed to \code{\link[stats]{p.adjust}}. Only if `method == "all"`.
122+
#'
118123
#' @return Depending on `method`:
119124
#'
120125
#' If `method = "all"`, returns a list with `heatmap` and `volcano` ggplot objects.
@@ -241,7 +246,8 @@ PlotScores <- function(data, metadata, gene_sets,
241246
cond_cohend = NULL, pvalcalc = FALSE,
242247
mode = c("simple","medium","extensive"),
243248
widthlegend=22, sig_threshold=0.05, cohen_threshold=0.5,
244-
colorPalette="Set3", cor=c("pearson","spearman","kendall")) {
249+
colorPalette="Set3", cor=c("pearson","spearman","kendall"),
250+
p.adjust.method="BH") {
245251
data <- as.data.frame(data) # Ensure data is a data frame
246252
method <- match.arg(method)
247253
mode <- match.arg(mode)
@@ -254,13 +260,13 @@ PlotScores <- function(data, metadata, gene_sets,
254260
if (type =="Numeric"){
255261

256262
cohenlist <- CohenF_allConditions(data = data, metadata = metadata,
257-
gene_sets = gene_sets, variable = Variable )
263+
gene_sets = gene_sets, variable = Variable, p.adjust.method = p.adjust.method )
258264

259265
} else {
260266

261267
cohenlist <- CohenD_allConditions(data = data, metadata = metadata,
262268
gene_sets = gene_sets, variable = Variable,
263-
mode = mode)
269+
mode = mode, p.adjust.method = p.adjust.method )
264270

265271
}
266272

R/Score_VariableAssociation.R

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ create_contrast_column <- function(metadata, variable_name, contrast) {
161161
#' @param color_palette A string specifying the color palette for discrete
162162
#' variables. Default: `"Set2"`.
163163
#' @param printplt Boolean specifying if plot is to be printed. Default: `TRUE`.
164-
#'
164+
#' @param p.adjust.method Character string specifying the method to use for
165+
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
166+
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
167+
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
168+
#' Passed to \code{\link[stats]{p.adjust}}.
169+
#'
165170
#' @return A list with:
166171
#' - `Overall`: Data frame of effect sizes and p-values for each contrasted
167172
#' phenotypic variable.
@@ -207,7 +212,8 @@ Score_VariableAssociation <- function(data,
207212
discrete_colors=NULL,
208213
continuous_color = "#8C6D03",
209214
color_palette = "Set2",
210-
printplt =TRUE){
215+
printplt =TRUE,
216+
p.adjust.method = "BH"){
211217
method <- match.arg(method) # Validate method input
212218
mode <- match.arg(mode)
213219
data <- as.data.frame(data) # Ensure data is a data frame
@@ -296,8 +302,7 @@ Score_VariableAssociation <- function(data,
296302
# Would happen if we have only numeric variables
297303
if (nrow(df_results_contrast)!=0){
298304

299-
df_results_contrast$padj <- stats::p.adjust(df_results_contrast$PValue,
300-
method = "BH")
305+
df_results_contrast$padj <- stats::p.adjust(df_results_contrast$PValue, method = p.adjust.method)
301306

302307
if(is.null(saturation_value)){
303308
if (min(df_results_contrast$padj)>sig_threshold){

R/VariableAssociation.R

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ identify_variable_type <- function(df, cols = NULL) {
9696
#' @param categorical_multi The statistical test for multi-level categorical
9797
#' variables.
9898
#' Options: `"anova"` (default) or `"kruskal-wallis"`.
99-
#'
99+
#' @param p.adjust.method Character string specifying the method to use for
100+
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
101+
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
102+
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
103+
#' Passed to \code{\link[stats]{p.adjust}}.
104+
#'
100105
#' @return A named list (one entry per variable being analysed) where each
101106
#' element is a data frame with:
102107
#' - **Metric**: The test statistic (correlation coefficient, t-statistic,
@@ -130,7 +135,7 @@ identify_variable_type <- function(df, cols = NULL) {
130135
compute_stat_tests <- function(df, target_var, cols = NULL,
131136
numeric = "pearson",
132137
categorical_bin = "t.test",
133-
categorical_multi = "anova") {
138+
categorical_multi = "anova", p.adjust.method="BH") {
134139

135140
# Ensure only one method is selected per variable type
136141
if (length(numeric) > 1 | length(categorical_bin) > 1 |
@@ -202,7 +207,7 @@ compute_stat_tests <- function(df, target_var, cols = NULL,
202207
# scientific notation
203208
test_df$metric <- formatC(test_df$metric, format = "e", digits = 2)
204209
# correct for multiple testing per variable
205-
test_df$p_value <- stats::p.adjust(test_df$p_value, method = "BH")
210+
test_df$p_value <- stats::p.adjust(test_df$p_value, method = p.adjust.method)
206211
test_df$p_value <- formatC(test_df$p_value, format = "e", digits = 3)
207212

208213

@@ -267,7 +272,12 @@ compute_stat_tests <- function(df, target_var, cols = NULL,
267272
#' (`"B"` or `"t"`). Auto-detected if `NULL`.
268273
#' @param ignore_NAs (GSEA only) Logical. If `TRUE`, rows with NA metadata are
269274
#' removed. Default: `FALSE`.
270-
#'
275+
#' @param p.adjust.method Character string specifying the method to use for
276+
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
277+
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
278+
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
279+
#' Passed to \code{\link[stats]{p.adjust}}.
280+
#'
271281
#' @return A list with method-specific results and ggplot2-based visualizations:
272282
#'
273283
#' **For score-based methods (`logmedian`, `ssGSEA`, `ranking`):**
@@ -355,7 +365,8 @@ VariableAssociation <- function(method = c("ssGSEA", "logmedian",
355365
discrete_colors = NULL,
356366
continuous_color = "#8C6D03",
357367
color_palette = "Set2",
358-
printplt = TRUE) {
368+
printplt = TRUE,
369+
p.adjust.method = "BH") {
359370
method <- match.arg(method)
360371
mode <- match.arg(mode)
361372
data <- as.data.frame(data) # Ensure data is a data frame
@@ -375,7 +386,8 @@ VariableAssociation <- function(method = c("ssGSEA", "logmedian",
375386
labsize = labsize,
376387
titlesize = titlesize,
377388
pointSize = pointSize,
378-
ignore_NAs = ignore_NAs
389+
ignore_NAs = ignore_NAs,
390+
p.adjust.method = p.adjust.method
379391
)
380392

381393
} else if (method %in% c("ssGSEA", "logmedian", "ranking")) {
@@ -397,7 +409,8 @@ VariableAssociation <- function(method = c("ssGSEA", "logmedian",
397409
discrete_colors = discrete_colors,
398410
continuous_color = continuous_color,
399411
color_palette = color_palette,
400-
printplt = printplt
412+
printplt = printplt,
413+
p.adjust.method = p.adjust.method
401414
)
402415
}
403416

0 commit comments

Comments
 (0)