Skip to content

Commit 3cbbdf7

Browse files
committed
fix DGE with one vs all
1 parent 7e3a0c0 commit 3cbbdf7

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎R/markeR_tab_benchmarking.R‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,8 +1717,17 @@ benchmarkingServer <- function(id, get_expr, get_meta, get_gene_sets) {
17171717
type = "warning", duration = 10)
17181718
}
17191719
uvals <- unique(safe_vals)
1720-
all_contrasts <- remove_division(
1721-
generate_all_contrasts(uvals, mode = enrich_mode))
1720+
# Keep the "/N" averaging term (e.g. "A - (B + C + D)/3") that
1721+
# generate_all_contrasts() adds for "vs rest"-style comparisons,
1722+
# both in what's passed to calculateDE()/limma::makeContrasts()
1723+
# AND in the displayed contrast names/titles. Previously the "/N"
1724+
# was stripped via remove_division() before reaching calculateDE(),
1725+
# which silently turned the averaged "rest" side into a *summed*
1726+
# one - the contrast was then off by a factor of N, biasing the
1727+
# result almost entirely to one sign for nearly every gene. Now
1728+
# the division is both applied and visible, so a "vs rest"
1729+
# contrast's name makes clear it's a mean, not a sum.
1730+
all_contrasts <- generate_all_contrasts(uvals, mode = enrich_mode)
17221731
# Filter to user-selected contrasts
17231732
sel <- shiny::isolate(input$gsea_selected_contrasts)
17241733
contrasts_vec <- if (!is.null(sel) && length(sel) > 0L)
@@ -1981,7 +1990,10 @@ benchmarkingServer <- function(id, get_expr, get_meta, get_gene_sets) {
19811990
shiny::req(!is.null(meta), !is.null(var), nchar(var) > 0)
19821991
contrasts_all <- tryCatch({
19831992
uvals <- unique(.sanitize_group_vals(meta[[var]]))
1984-
remove_division(generate_all_contrasts(uvals, mode = mode %||% "simple"))
1993+
# Keep the "/N" averaging term visible in the picker labels (see the
1994+
# comment in the "Auto path" run_gsea observer above) so it's obvious
1995+
# which contrasts compare against a mean of several groups.
1996+
generate_all_contrasts(uvals, mode = mode %||% "simple")
19851997
}, error = function(e) character(0))
19861998
if (length(contrasts_all) == 0L) return(NULL)
19871999
shiny::div(

‎R/markeRapp.R‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ui <- bslib::page_navbar(
4747
# target = "_blank",
4848
# style = "font-size: 0.85em; color: #949494; text-decoration: none;"
4949
# )
50-
shiny::a("Web App 0.99.7",
50+
shiny::a("Web App 0.99.8",
5151
style = "font-size: 0.7em; color: #949494; text-decoration: none;")
5252
),
5353

0 commit comments

Comments
 (0)