@@ -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 , " " , 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