@@ -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(
0 commit comments