Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
^\\.git$
^codecov\.yml$
^vignettes/articles$
^data_aux$
^data_aux$
^python(/.*)?$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ markeR.Rproj
inst/doc
data_aux
markeR.Rcheck
/python/.venv
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: markeR
Title: An R Toolkit for Evaluating Gene Signatures as Phenotypic Markers
Version: 1.1.0
Version: 1.1.2
Authors@R:
c(
person("Rita", "Martins-Silva",
Expand All @@ -25,7 +25,7 @@ Encoding: UTF-8
Language: en-GB
LazyData: false
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Additional_repositories: https://bioconductor.org/packages/release/bioc
Imports:
circlize,
Expand Down
25 changes: 25 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# markeR 1.1.2 (12 Mar, 2026)

## Minor Changes
- Moved Python bridge scripts from `inst/python/` to a top-level `python/`
directory, as these are supplementary scripts not part of the R package itself.
- Added `requirements.txt` to the `python/` directory listing all needed
Python dependencies (`rpy2`, `pandas`, `numpy`, and optionally
`ipython` and `jupyter`) for easier environment setup.
- Removed redundant code snippets from the Python bridge scripts.

# markeR 1.1.1 (11 Mar, 2026)

- Added `p.adjust.method` parameter across all functions performing or
depending on multiple testing correction, allowing users to specify
any correction method supported by `stats::p.adjust()`, beyond the default
Benjamini-Hochberg FDR.
- Added Python bridge scripts in `inst/python/` for users who wish to call
markeR from a Python environment via `rpy2`. Includes a tutorial workflow
script and a generic command-line wrapper capable of invoking any exported
markeR function. See `inst/python/README.md` for installation and usage.

# markeR 1.0.0 (31 Oct, 2025)

- Official Bioconductor Release.

# markeR 0.99.5 (17 Sep, 2025)

- Minor fix in `.onAttach()` to avoid errors when checking `ggplot2` version and ensure the startup warning works correctly.
Expand Down
18 changes: 11 additions & 7 deletions R/FPR_Simulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ utils::globalVariables(c( "cohen", "method", "contrast" ))
#' grid layout. If `NULL`, layout is auto-calculated.
#' @param nrow Integer. Number of rows for arranging signature plots in a grid
#' layout. If `NULL`, layout is auto-calculated.
#'
#' @param p.adjust.method Character string specifying the method to use for
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
#' Passed to \code{\link[stats]{p.adjust}}.
#'
#' @return Invisibly returns a list containing:
#' \describe{
Expand Down Expand Up @@ -111,7 +115,7 @@ FPR_Simulation <- function(data, metadata, original_signatures, Variable,
gene_list = NULL, number_of_sims=100, title=NULL,
widthTitle = 30, titlesize = 12, pointSize = 2,
labsize = 10,mode = c( "none","simple","medium","extensive"),
ColorValues=NULL, ncol=NULL, nrow=NULL) {
ColorValues=NULL, ncol=NULL, nrow=NULL, p.adjust.method="BH") {
data <- as.data.frame(data) # Ensure data is a data frame
if (is.null(gene_list)) gene_list <- row.names(data)

Expand All @@ -128,7 +132,7 @@ FPR_Simulation <- function(data, metadata, original_signatures, Variable,
results <- suppressMessages(CohenF_allConditions(data = data,
metadata = metadata,
gene_sets = original_signatures,
variable = Variable ))
variable = Variable, p.adjust.method = p.adjust.method ))
cohentype <- "f"

} else {
Expand All @@ -138,15 +142,15 @@ FPR_Simulation <- function(data, metadata, original_signatures, Variable,
results <- suppressMessages(CohenF_allConditions(data = data,
metadata = metadata,
gene_sets = original_signatures,
variable = Variable ))
variable = Variable, p.adjust.method = p.adjust.method ))
cohentype <- "f"

} else {

results <- suppressMessages(CohenD_allConditions(data = data,
metadata = metadata,
gene_sets = original_signatures,
variable = Variable, mode = mode))
variable = Variable, mode = mode, p.adjust.method = p.adjust.method))
cohentype <- "d"

}
Expand Down Expand Up @@ -219,14 +223,14 @@ FPR_Simulation <- function(data, metadata, original_signatures, Variable,
metadata = metadata,
gene_sets = simulatedsigs,
variable = Variable,
mode = mode
mode = mode, p.adjust.method = p.adjust.method
))
} else {
results2 <- suppressMessages(CohenF_allConditions(
data = data,
metadata = metadata,
gene_sets = simulatedsigs,
variable = Variable
variable = Variable, p.adjust.method = p.adjust.method
))
}

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

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


combined_results_toreturn <- combined_results
Expand Down
28 changes: 20 additions & 8 deletions R/Heatmap_Cohen.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#' @param ColorValues A character vector specifying the colors for the gradient
#' fill in the heatmaps. Default is \code{c("#F9F4AE", "#B44141")}.
#' @param title Title for the grid of plots.
#'
#' @return A list with two elements:
#' \describe{
#' \item{plt}{A combined heatmap arranged in a grid using \code{ggpubr::ggarrange}.}
Expand Down Expand Up @@ -61,7 +62,7 @@
#' @keywords internal
Heatmap_Cohen <- function(cohenlist, nrow = NULL, ncol = NULL, limits = NULL,
widthTitle = 22, titlesize = 12, ColorValues = NULL,
title=NULL ) {
title=NULL) {

cohentype <- ifelse("CohenD" %in% names(cohenlist[[1]]), "d",
ifelse("CohenF" %in% names(cohenlist[[1]]), "f", NULL))
Expand Down Expand Up @@ -201,7 +202,12 @@ Heatmap_Cohen <- function(cohenlist, nrow = NULL, ncol = NULL, limits = NULL,
#' groups.
#' - `"extensive"`: All possible groupwise contrasts, ensuring balance in the
#' number of terms on each side.
#'
#' @param p.adjust.method Character string specifying the method to use for
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
#' Passed to \code{\link[stats]{p.adjust}}.
#'
#' @return A named list where each element corresponds to a gene signature. Each
#' signature element is a list with three components:
#' \describe{
Expand All @@ -227,7 +233,7 @@ Heatmap_Cohen <- function(cohenlist, nrow = NULL, ncol = NULL, limits = NULL,
#'
#' @keywords internal
CohenD_allConditions <- function(data, metadata, gene_sets, variable,
mode = c("simple","medium","extensive")) {
mode = c("simple","medium","extensive"), p.adjust.method = "BH") {
data <- as.data.frame(data) # Ensure data is a data frame
# Step 1: Check if variable exists in metadata
if (!variable %in% colnames(metadata)) {
Expand Down Expand Up @@ -292,8 +298,8 @@ CohenD_allConditions <- function(data, metadata, gene_sets, variable,
}
}

# Step 2: Apply BH correction within each method
all_padj <- lapply(all_pvalues, function(pvals) stats::p.adjust(pvals, method = "BH"))
# Step 2: Apply correction within each method
all_padj <- lapply(all_pvalues, function(pvals) stats::p.adjust(pvals, method = p.adjust.method))

# Step 3: Store corrected p-values back into result_list
index_tracker <- list() # Track index position for each method
Expand Down Expand Up @@ -495,6 +501,12 @@ flatten_results <- function(nested_list) {
#' downregulated).
#' @param variable A string specifying the categorical variable in
#' \code{metadata} used to model the gene signature scores.
#' @param p.adjust.method Character string specifying the method to use for
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
#' Passed to \code{\link[stats]{p.adjust}}.
#'
#' @return A named list where each element corresponds to a gene signature. Each
#' signature element is a list with three components:
#' \describe{
Expand All @@ -508,7 +520,7 @@ flatten_results <- function(nested_list) {
#' }
#'
#' @keywords internal
CohenF_allConditions <- function(data, metadata, gene_sets, variable ) {
CohenF_allConditions <- function(data, metadata, gene_sets, variable, p.adjust.method = "BH" ) {
data <- as.data.frame(data) # Ensure data is a data frame
# Step 1: Check if variable exists in metadata
if (!variable %in% colnames(metadata)) {
Expand Down Expand Up @@ -579,8 +591,8 @@ CohenF_allConditions <- function(data, metadata, gene_sets, variable ) {
}
}

# Step 2: Apply BH correction within each method
all_padj <- lapply(all_pvalues, function(pvals) stats::p.adjust(pvals, method = "BH"))
# Step 2: Apply correction within each method
all_padj <- lapply(all_pvalues, function(pvals) stats::p.adjust(pvals, method = p.adjust.method))

# Step 3: Store corrected p-values back into result_list
index_tracker <- list() # Track index position for each method
Expand Down
14 changes: 10 additions & 4 deletions R/PlotScores.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ utils::globalVariables(c("score"))
#' @param cor Correlation method for numeric variables. One of `"pearson"`
#' (default), `"spearman"`, or `"kendall"`. Only applies when the variable is
#' numeric and `method != "all"`.
#'
#' @param p.adjust.method Character string specifying the method to use for
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
#' Passed to \code{\link[stats]{p.adjust}}. Only if `method == "all"`.
#'
#' @return Depending on `method`:
#'
#' If `method = "all"`, returns a list with `heatmap` and `volcano` ggplot objects.
Expand Down Expand Up @@ -241,7 +246,8 @@ PlotScores <- function(data, metadata, gene_sets,
cond_cohend = NULL, pvalcalc = FALSE,
mode = c("simple","medium","extensive"),
widthlegend=22, sig_threshold=0.05, cohen_threshold=0.5,
colorPalette="Set3", cor=c("pearson","spearman","kendall")) {
colorPalette="Set3", cor=c("pearson","spearman","kendall"),
p.adjust.method="BH") {
data <- as.data.frame(data) # Ensure data is a data frame
method <- match.arg(method)
mode <- match.arg(mode)
Expand All @@ -254,13 +260,13 @@ PlotScores <- function(data, metadata, gene_sets,
if (type =="Numeric"){

cohenlist <- CohenF_allConditions(data = data, metadata = metadata,
gene_sets = gene_sets, variable = Variable )
gene_sets = gene_sets, variable = Variable, p.adjust.method = p.adjust.method )

} else {

cohenlist <- CohenD_allConditions(data = data, metadata = metadata,
gene_sets = gene_sets, variable = Variable,
mode = mode)
mode = mode, p.adjust.method = p.adjust.method )

}

Expand Down
13 changes: 9 additions & 4 deletions R/Score_VariableAssociation.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ create_contrast_column <- function(metadata, variable_name, contrast) {
#' @param color_palette A string specifying the color palette for discrete
#' variables. Default: `"Set2"`.
#' @param printplt Boolean specifying if plot is to be printed. Default: `TRUE`.
#'
#' @param p.adjust.method Character string specifying the method to use for
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
#' Passed to \code{\link[stats]{p.adjust}}.
#'
#' @return A list with:
#' - `Overall`: Data frame of effect sizes and p-values for each contrasted
#' phenotypic variable.
Expand Down Expand Up @@ -207,7 +212,8 @@ Score_VariableAssociation <- function(data,
discrete_colors=NULL,
continuous_color = "#8C6D03",
color_palette = "Set2",
printplt =TRUE){
printplt =TRUE,
p.adjust.method = "BH"){
method <- match.arg(method) # Validate method input
mode <- match.arg(mode)
data <- as.data.frame(data) # Ensure data is a data frame
Expand Down Expand Up @@ -296,8 +302,7 @@ Score_VariableAssociation <- function(data,
# Would happen if we have only numeric variables
if (nrow(df_results_contrast)!=0){

df_results_contrast$padj <- stats::p.adjust(df_results_contrast$PValue,
method = "BH")
df_results_contrast$padj <- stats::p.adjust(df_results_contrast$PValue, method = p.adjust.method)

if(is.null(saturation_value)){
if (min(df_results_contrast$padj)>sig_threshold){
Expand Down
27 changes: 20 additions & 7 deletions R/VariableAssociation.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ identify_variable_type <- function(df, cols = NULL) {
#' @param categorical_multi The statistical test for multi-level categorical
#' variables.
#' Options: `"anova"` (default) or `"kruskal-wallis"`.
#'
#' @param p.adjust.method Character string specifying the method to use for
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
#' Passed to \code{\link[stats]{p.adjust}}.
#'
#' @return A named list (one entry per variable being analysed) where each
#' element is a data frame with:
#' - **Metric**: The test statistic (correlation coefficient, t-statistic,
Expand Down Expand Up @@ -130,7 +135,7 @@ identify_variable_type <- function(df, cols = NULL) {
compute_stat_tests <- function(df, target_var, cols = NULL,
numeric = "pearson",
categorical_bin = "t.test",
categorical_multi = "anova") {
categorical_multi = "anova", p.adjust.method="BH") {

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


Expand Down Expand Up @@ -267,7 +272,12 @@ compute_stat_tests <- function(df, target_var, cols = NULL,
#' (`"B"` or `"t"`). Auto-detected if `NULL`.
#' @param ignore_NAs (GSEA only) Logical. If `TRUE`, rows with NA metadata are
#' removed. Default: `FALSE`.
#'
#' @param p.adjust.method Character string specifying the method to use for
#' multiple testing correction. Must be one of \code{"BH"} (Benjamini-Hochberg,
#' default), \code{"holm"}, \code{"hommel"}, \code{"bonferroni"},
#' \code{"BY"} (Benjamini-Yekutieli), \code{"fdr"}, or \code{"none"}.
#' Passed to \code{\link[stats]{p.adjust}}.
#'
#' @return A list with method-specific results and ggplot2-based visualizations:
#'
#' **For score-based methods (`logmedian`, `ssGSEA`, `ranking`):**
Expand Down Expand Up @@ -355,7 +365,8 @@ VariableAssociation <- function(method = c("ssGSEA", "logmedian",
discrete_colors = NULL,
continuous_color = "#8C6D03",
color_palette = "Set2",
printplt = TRUE) {
printplt = TRUE,
p.adjust.method = "BH") {
method <- match.arg(method)
mode <- match.arg(mode)
data <- as.data.frame(data) # Ensure data is a data frame
Expand All @@ -375,7 +386,8 @@ VariableAssociation <- function(method = c("ssGSEA", "logmedian",
labsize = labsize,
titlesize = titlesize,
pointSize = pointSize,
ignore_NAs = ignore_NAs
ignore_NAs = ignore_NAs,
p.adjust.method = p.adjust.method
)

} else if (method %in% c("ssGSEA", "logmedian", "ranking")) {
Expand All @@ -397,7 +409,8 @@ VariableAssociation <- function(method = c("ssGSEA", "logmedian",
discrete_colors = discrete_colors,
continuous_color = continuous_color,
color_palette = color_palette,
printplt = printplt
printplt = printplt,
p.adjust.method = p.adjust.method
)
}

Expand Down
Loading
Loading