Skip to content

Commit 1cb3748

Browse files
authored
Merge pull request #1616 from bigomics/gset-rowgroup
enable grouping by database of geneset table
2 parents 66225f7 + d19300d commit 1cb3748

File tree

3 files changed

+37
-17
lines changed

3 files changed

+37
-17
lines changed

components/board.enrichment/R/enrichment_plot_top_enrich_gsets.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,8 @@ enrichment_plot_top_enrich_gsets_server <- function(id,
9696
}
9797

9898
## selected
99-
sel <- as.integer(gseatable$rows_selected())
100-
sel.gs <- NULL
101-
if (!is.null(sel) && length(sel) > 0) sel.gs <- rownames(rpt)[sel]
102-
103-
ii <- gseatable$rows_selected()
104-
jj <- gseatable$rows_current()
99+
ii <- gseatable$rownames_selected()
100+
jj <- gseatable$rownames_current()
105101
shiny::req(jj)
106102

107103
if (nrow(rpt) == 0) {

components/board.enrichment/R/enrichment_server.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ EnrichmentBoard <- function(id, pgx,
368368
## Enrichment table
369369
## ================================================================================
370370

371-
gset_selected <- shiny::reactive({
371+
gset_selected.SAVE <- shiny::reactive({
372372
i <- as.integer(gseatable$rows_selected())
373373
if (is.null(i) || length(i) == 0) {
374374
return(NULL)
@@ -378,6 +378,14 @@ EnrichmentBoard <- function(id, pgx,
378378
return(gs)
379379
})
380380

381+
gset_selected <- shiny::reactive({
382+
gs <- gseatable$rownames_selected()
383+
if (is.null(gs) || length(gs) == 0) {
384+
return(NULL)
385+
}
386+
return(gs)
387+
})
388+
381389
geneDetails <- shiny::reactive({
382390
## return details of the genes in the selected gene set
383391
shiny::req(pgx$X, input$gs_contrast)

components/board.enrichment/R/enrichment_table_enrichment_analysis.R

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ enrichment_table_enrichment_analysis_ui <- function(
1515

1616
gseatable_opts <- shiny::tagList(
1717
withTooltip(shiny::checkboxInput(ns("gs_showqvalues"), "Show individual q-values", FALSE),
18-
"Show q-values of each statistical method in the table.",
19-
placement = "top", options = list(container = "body")
18+
"Show q-values of each statistical method in the table."
2019
),
2120
withTooltip(shiny::checkboxInput(ns("show_scores"), "Show method-specific score", FALSE),
22-
"Show enrichment score of each statistical method in the table.",
23-
placement = "top", options = list(container = "body")
21+
"Show enrichment score of each statistical method in the table."
22+
),
23+
withTooltip(shiny::checkboxInput(ns("rowgroup"), "Group by database", FALSE),
24+
"Groups genesets by database."
2425
)
2526
)
2627

@@ -60,7 +61,7 @@ enrichment_table_enrichment_analysis_server <- function(id,
6061
return(NULL)
6162
}
6263

63-
if ("GS" %in% colnames(rpt)) rpt$GS <- playbase::shortstring(rpt$GS, 72)
64+
if ("GS" %in% colnames(rpt)) rpt$GS <- playbase::shortstring(rpt$GS, 60)
6465
if ("size" %in% colnames(rpt)) rpt$size <- as.integer(rpt$size)
6566

6667
fx <- NULL
@@ -91,17 +92,27 @@ enrichment_table_enrichment_analysis_server <- function(id,
9192
rpt$GS <- paste(rpt$GS, "&nbsp;", GS_link)
9293
colnames(rpt) <- sub("GS", "geneset", colnames(rpt))
9394

95+
if(input$rowgroup) {
96+
db <- sub(":.*","",rownames(rpt))
97+
rpt <- cbind( DB = db, rpt )
98+
rpt <- rpt[order(rpt$DB, rpt$meta.q, -abs(rpt$logFC)), ]
99+
}
100+
94101
is.numcol <- sapply(rpt, function(col) is.numeric(col) && !is.integer(col))
95102
numcols <- which(is.numcol & !colnames(rpt) %in% c("size"))
96103
numcols <- colnames(rpt)[numcols]
104+
escapecols <- -1 * (match(c("geneset"), colnames(rpt)) + 0)
97105

98-
106+
rowgroup.opt <- NULL
107+
if(input$rowgroup) rowgroup.opt <- list(dataSrc = 0)
108+
99109
DT::datatable(rpt,
100110
class = "compact cell-border stripe hover",
101111
rownames = FALSE,
102-
escape = c(-1, -2),
103-
extensions = c("Scroller"),
104-
plugins = "scrollResize",
112+
#escape = c(-1, -2),
113+
escape = escapecols,
114+
extensions = c("Scroller","RowGroup"),
115+
plugins = c("scrollResize","ellipsis"),
105116
fillContainer = TRUE,
106117
selection = list(mode = "single", target = "row", selected = 1),
107118
options = list(
@@ -113,10 +124,15 @@ enrichment_table_enrichment_analysis_server <- function(id,
113124
scrollResize = TRUE,
114125
scroller = TRUE,
115126
deferRender = TRUE,
127+
rowGroup = rowgroup.opt,
116128
search = list(
117129
regex = TRUE,
118130
caseInsensitive = TRUE
119-
)
131+
),
132+
columnDefs = list(list(
133+
targets = c("geneset"),
134+
render = DT::JS("$.fn.dataTable.render.ellipsis( 60, false )")
135+
))
120136
) ## end of options.list
121137
) %>%
122138
DT::formatSignif(numcols, 4) %>%

0 commit comments

Comments
 (0)