@@ -22,6 +22,7 @@ schematic_b64 <- base64enc::dataURI(file = "www/charm_schematic.svg", mime = "im
2222
2323source(" plot_theme.R" ) # one font/size/style for every plot
2424source(" correlation_reference.R" ) # percentile / permutation-null context for correlations
25+ source(" rmats_mapping.R" ) # rMATS IDs anchored on VAST-TOOLS IDs (Splicing tab)
2526source(" helper_functions.R" )
2627
2728# --- Data directory -----------------------------------------------------
@@ -50,6 +51,9 @@ qload <- function(name) {
5051CORR_REF <- tryCatch(qload(" Correlation_Reference" ), error = function (e ) NULL )
5152# Same idea for binding profiles (built by build_binding_reference.R)
5253BIND_REF <- tryCatch(qload(" Binding_Correlation_Reference" ), error = function (e ) NULL )
54+ # VAST-TOOLS -> rMATS event ID cross-reference (built by eCLIPSE/map_vast_rmats_events.R). Optional: without
55+ # the file the "Show rMATS IDs" option is simply not offered.
56+ RMATS_MAP <- tryCatch(qload(" RMATS_Event_Mapping" ), error = function (e ) NULL )
5357# Taller plot box when the density panel is stacked under the bar plot
5458corr_plot_height <- function (key ) if (corr_has_ref(key )) " 800px" else " 500px"
5559
@@ -271,6 +275,10 @@ ui <- fluidPage(
271275 .charm-card-body { padding: 22px 24px 24px; }
272276 .charm-card-body h3 { margin: 4px 0 8px; font-weight: bold; }
273277 .charm-card-body p { margin: 0; }
278+ .charm-cards-three .charm-card { flex: 1 1 290px; max-width: 370px; }
279+ .charm-card-go { display: block; margin-top: 12px; font-size: 13px; font-weight: bold; color: #2c3e50; }
280+ .charm-modes { max-width: 760px; margin: 8px auto 0; }
281+ .charm-modes .charm-layer-go { display: none; }
274282 .charm-tutorial { text-align: center; margin: 16px 0 0; font-size: 14px; }
275283 .charm-footer { text-align: center; font-size: 12px; color: #666; max-width: 900px;
276284 margin: 0 auto; padding-top: 14px; border-top: 1px solid #e0e0e0; }
@@ -382,27 +390,30 @@ ui <- fluidPage(
382390 )
383391 ),
384392
385- # ── What each layer adds ─────────────────────── ─────────────────────
393+ # ── The three layers (main modules): large cards ─────────────────────
386394 div(
387- class = " charm-layers " ,
388- div(class = " charm-layer " ,
395+ class = " charm-cards charm-cards-three " ,
396+ div(class = " charm-card " ,
389397 onclick = " Shiny.setInputValue('home_go_layer', 'Binding', {priority: 'event'});" ,
390- div(class = " charm-layer-num" , " 1" ),
391- tags $ h4(" Binding" ),
392- tags $ p(" Where does an RBP bind, and what are its consequences? RNA splicing maps from eCLIP show where it binds around affected events, helping to separate direct targets from indirect ones." ),
393- tags $ span(class = " charm-layer-go" , " Open Binding \u 2192" )),
394- div(class = " charm-layer" ,
398+ div(class = " charm-card-body" ,
399+ div(class = " charm-card-icon" , fa(" link" , fill = " black" , height = " 2em" )),
400+ tags $ h3(" Binding" ),
401+ tags $ p(" Where does an RBP bind, and what are its consequences? RNA splicing maps from eCLIP show where it binds around affected events, helping to separate direct targets from indirect ones." ),
402+ tags $ span(class = " charm-card-go" , " Open Binding \u 2192" ))),
403+ div(class = " charm-card" ,
395404 onclick = " Shiny.setInputValue('home_go_layer', 'Splicing', {priority: 'event'});" ,
396- div(class = " charm-layer-num" , " 2" ),
397- tags $ h4(" Splicing" ),
398- tags $ p(" Which splicing events depend on the RBP? Changes in exon skipping and intron retention (dPSI) after knockdown, across VastDB-annotated events." ),
399- tags $ span(class = " charm-layer-go" , " Open Splicing \u 2192" )),
400- div(class = " charm-layer" ,
405+ div(class = " charm-card-body" ,
406+ div(class = " charm-card-icon" , fa(" scissors" , fill = " black" , height = " 2em" )),
407+ tags $ h3(" Splicing" ),
408+ tags $ p(" Which splicing events depend on the RBP? Changes in exon skipping and intron retention (dPSI) after knockdown, across VastDB-annotated events." ),
409+ tags $ span(class = " charm-card-go" , " Open Splicing \u 2192" ))),
410+ div(class = " charm-card" ,
401411 onclick = " Shiny.setInputValue('home_go_layer', 'Expression', {priority: 'event'});" ,
402- div(class = " charm-layer-num" , " 3" ),
403- tags $ h4(" Expression" ),
404- tags $ p(" Which genes and cellular programs change? Differential expression after knockdown, with Hallmark gene-set enrichment." ),
405- tags $ span(class = " charm-layer-go" , " Open Expression \u 2192" ))
412+ div(class = " charm-card-body" ,
413+ div(class = " charm-card-icon" , fa(" dna" , fill = " black" , height = " 2em" )),
414+ tags $ h3(" Expression" ),
415+ tags $ p(" Which genes and cellular programs change? Differential expression after knockdown, with Hallmark gene-set enrichment." ),
416+ tags $ span(class = " charm-card-go" , " Open Expression \u 2192" )))
406417 ),
407418
408419 # ── Questions CHARM can answer ──────────────────────────────────────
@@ -429,25 +440,18 @@ ui <- fluidPage(
429440 # ── Entry points ────────────────────────────────────────────────────
430441 div(
431442 class = " charm-section" ,
432- tags $ h2(" Start here" ),
433443 div(
434- class = " charm-cards" ,
435- div(
436- class = " charm-card" ,
437- onclick = " Shiny.setInputValue('home_go_explore', Math.random());" ,
438- div(class = " charm-card-body" ,
439- div(class = " charm-card-icon" , fa(" globe" , fill = " black" , height = " 2em" )),
440- tags $ h3(" Explore" ),
441- tags $ p(" Investigate how a known RBP affects expression, splicing, and binding, based on ENCODE's gene silencing series and eCLIP data." ))
442- ),
443- div(
444- class = " charm-card" ,
445- onclick = " Shiny.setInputValue('home_go_discover', Math.random());" ,
446- div(class = " charm-card-body" ,
447- div(class = " charm-card-icon" , fa(" map" , fill = " black" , height = " 2em" )),
448- tags $ h3(" Discovery" ),
449- tags $ p(" Upload your own expression, splicing, or binding data to discover which RBPs are most likely altered in your biological system." ))
450- )
444+ class = " charm-layers charm-modes" ,
445+ div(class = " charm-layer" ,
446+ onclick = " Shiny.setInputValue('home_go_explore', Math.random());" ,
447+ div(class = " charm-layer-num" , fa(" globe" , fill = " white" , height = " 0.9em" )),
448+ tags $ h4(" Explore" ),
449+ tags $ p(" Investigate how a known RBP affects expression, splicing, and binding, based on ENCODE's gene silencing series and eCLIP data." )),
450+ div(class = " charm-layer" ,
451+ onclick = " Shiny.setInputValue('home_go_discover', Math.random());" ,
452+ div(class = " charm-layer-num" , fa(" map" , fill = " white" , height = " 0.9em" )),
453+ tags $ h4(" Discovery" ),
454+ tags $ p(" Upload your own expression, splicing, or binding data to discover which RBPs are most likely altered in your biological system." ))
451455 # DISABLED: Network module intentionally commented out. Code kept intact for a future redesign; to restore, uncomment this block, the Home card, and the home_go_network observer. [Home card]
452456 # ,div(
453457 # class = "charm-card",
@@ -823,6 +827,15 @@ ui <- fluidPage(
823827 )
824828 )
825829 ),
830+ # ---- Optional: show rMATS IDs (anchored on the VAST-TOOLS IDs) ----
831+ if (! is.null(RMATS_MAP )) conditionalPanel(
832+ condition = " input.splice_dataset != 'Similar RBPs'" ,
833+ div(
834+ style = " margin-top: 20px;" ,
835+ checkboxInput(" splice_show_rmats" , " Show rMATS event IDs" , value = FALSE ),
836+ tags $ p(RMATS_DISCLAIMER_SHORT , style = " font-size: 12px; color: #666; margin-top: -8px;" )
837+ )
838+ ),
826839 conditionalPanel(
827840 condition = " input.splice_dataset == 'Similar RBPs'" ,
828841 selectizeInput(" similar_rbps_select_splice" , " Compare with specific RBPs (optional)" , choices = NULL , multiple = TRUE , options = list (placeholder = " Select one or more RBPs" )),
@@ -871,6 +884,9 @@ ui <- fluidPage(
871884 conditionalPanel(
872885 condition = " input.splice_mode == 'Explore' && input.splice_dataset != 'Similar RBPs'" ,
873886
887+ # --- Disclaimer, shown while "Show rMATS event IDs" is ticked ---
888+ uiOutput(" splice_rmats_note" ),
889+
874890 # --- Top panel: Event ID plot, shown when searched (server-controlled) ---
875891 uiOutput(" splice_top_panel_ui" ),
876892
@@ -1615,7 +1631,7 @@ server <- function(input, output, session) {
16151631 # plot's hover text. Leaving it in wrote raw <br> tags into the CSV --
16161632 # the on-screen table already excludes it the same way (see splice_volcano_table
16171633 # renderDT above), so the download should match what the user sees.
1618- res $ top_table % > % dplyr :: select( - dplyr :: any_of( " text " ) )
1634+ splice_table_view( res $ top_table , note = TRUE )
16191635 }),
16201636 " splicing_volcano_table"
16211637 )
@@ -1991,7 +2007,7 @@ server <- function(input, output, session) {
19912007 })
19922008 output $ splice_volcano_table <- DT :: renderDataTable({
19932009 req(result_splice())
1994- result_splice()$ top_table % > % select( - text )
2010+ splice_table_view( result_splice()$ top_table )
19952011 }, rownames = FALSE , selection = " single" , options = list (pageLength = 10 ))
19962012 }
19972013
@@ -2111,6 +2127,23 @@ server <- function(input, output, session) {
21112127 # Splicing Explore page: "event" or NULL (none).
21122128 splice_top_panel <- reactiveVal(NULL )
21132129
2130+ # ---- rMATS IDs (anchored on VAST-TOOLS IDs) ----
2131+ splice_rmats_on <- function () isTRUE(input $ splice_show_rmats ) && ! is.null(RMATS_MAP )
2132+
2133+ # Table shown / downloaded in the Splicing volcano: internal "text" column dropped and, when requested,
2134+ # the rMATS columns inserted after Event.ID (the row order never changes).
2135+ splice_table_view <- function (tbl , note = FALSE ) {
2136+ if (is.null(tbl )) return (NULL )
2137+ tbl <- dplyr :: select(tbl , - dplyr :: any_of(" text" ))
2138+ if (splice_rmats_on()) rmats_add_columns(tbl , RMATS_MAP , note = note ) else tbl
2139+ }
2140+
2141+ output $ splice_rmats_note <- renderUI({
2142+ req(splice_rmats_on())
2143+ div(class = " alert alert-warning" , style = " font-size: 12.5px; padding: 8px 12px; margin-bottom: 10px;" ,
2144+ tags $ b(" About the rMATS IDs. " ), RMATS_DISCLAIMER_LONG )
2145+ })
2146+
21142147 output $ splice_top_panel_ui <- renderUI({
21152148 panel <- splice_top_panel()
21162149 if (is.null(panel )) return (NULL )
@@ -2134,7 +2167,11 @@ server <- function(input, output, session) {
21342167 splice_top_panel(" event" )
21352168
21362169 output $ heatmap_splicing_dpsi <- renderPlot({
2137- p <- plot_event_dpsi_barplot(charm_obj , event_id )
2170+ show_rmats <- splice_rmats_on()
2171+ p <- plot_event_dpsi_barplot(
2172+ charm_obj , event_id ,
2173+ extra_subtitle = if (show_rmats ) paste0(" rMATS ID: " , rmats_label(event_id , RMATS_MAP )) else NULL ,
2174+ extra_caption = if (show_rmats ) " rMATS IDs mapped from VAST-TOOLS IDs by genomic coordinates (\u 00b11 nt); dPSI from VAST-TOOLS" else NULL )
21382175 dl_store $ event_dpsi(p )
21392176 p
21402177 })
@@ -3003,16 +3040,26 @@ server <- function(input, output, session) {
30033040 highlight_colors <- c(" None" = " #CCCCCC" , " RBP" = " #A10702" , " Selected" = " #008057" )
30043041 plot_df <- tbl
30053042 plot_df $ point_color <- unname(highlight_colors [plot_df $ highlight ])
3043+ show_rmats <- splice_rmats_on()
3044+ if (show_rmats ) {
3045+ plot_df <- rmats_add_columns(plot_df , RMATS_MAP )
3046+ plot_df $ rmats <- plot_df [[" rMATS ID" ]]
3047+ }
3048+ tip <- if (show_rmats ) " Event: {point.key}<br>rMATS: {point.rmats}" else " Event: {point.key}"
30063049
3007- highcharter :: hchart(
3050+ (if (show_rmats ) highcharter :: hchart(
3051+ plot_df , " scatter" ,
3052+ highcharter :: hcaes(x = dPSI , y = Pdiff , color = point_color , key = Event.ID , rmats = rmats ),
3053+ fast = TRUE
3054+ ) else highcharter :: hchart(
30083055 plot_df , " scatter" ,
30093056 highcharter :: hcaes(x = dPSI , y = Pdiff , color = point_color , key = Event.ID ),
30103057 fast = TRUE
3011- ) %> %
3058+ )) %> %
30123059 charm_hc_style() %> % highcharter :: hc_title(text = paste0(" Volcano Plot: " , rbp , " KD" )) %> %
30133060 highcharter :: hc_xAxis(title = list (text = " dPSI (shRNA - CTRL)" )) %> %
30143061 highcharter :: hc_yAxis(title = list (text = " PDiff" )) %> %
3015- highcharter :: hc_tooltip(pointFormat = " Event: {point.key} " ) %> %
3062+ highcharter :: hc_tooltip(pointFormat = tip ) %> %
30163063 highcharter :: hc_plotOptions(scatter = list (marker = list (radius = 5 , lineWidth = 1 , lineColor = " black" ))) %> %
30173064 highcharter :: hc_legend(enabled = FALSE ) %> %
30183065 hc_add_click_input(output_id )
@@ -3424,7 +3471,7 @@ server <- function(input, output, session) {
34243471 # ---- Render table ----
34253472 output $ splice_volcano_table <- DT :: renderDataTable({
34263473 req(result_splice())
3427- result_splice()$ top_table % > % select( - text )
3474+ splice_table_view( result_splice()$ top_table )
34283475 }, rownames = FALSE , selection = " single" , options = list (pageLength = 10 ))
34293476
34303477 # ---- Shared function to update highlights ----
0 commit comments