@@ -20,6 +20,7 @@ logo_b64 <- base64enc::dataURI(file = "www/Charm_logo.png", mime = "image/png")
2020# Embedded like the logo (not served from www/), so it cannot fail to load as a static file
2121schematic_b64 <- base64enc :: dataURI(file = " www/charm_schematic.svg" , mime = " image/svg+xml" )
2222
23+ source(" plot_theme.R" ) # one font/size/style for every plot
2324source(" helper_functions.R" )
2425
2526# --- Data directory -----------------------------------------------------
@@ -1653,7 +1654,7 @@ server <- function(input, output, session) {
16531654 img <- png :: readPNG(path )
16541655 g <- grid :: rasterGrob(img , interpolate = TRUE )
16551656 ggplot() + annotation_custom(g , xmin = - Inf , xmax = Inf , ymin = - Inf , ymax = Inf ) +
1656- theme_void ()
1657+ theme_charm_void ()
16571658 }
16581659
16591660
@@ -1959,7 +1960,7 @@ server <- function(input, output, session) {
19591960 p <- ggplot(tbl , aes(x = dPSI , y = Pdiff , key = Event.ID , color = highlight )) +
19601961 geom_point(alpha = 0.7 ) +
19611962 scale_color_manual(values = c(" None" = " #CCCCCC" , " RBP" = " #A10702" , " Selected" = " #008057" )) +
1962- theme_bw () + theme(legend.position = " none" ) +
1963+ theme_charm () + theme(legend.position = " none" ) +
19631964 labs(title = paste0(" Volcano Plot: " , rbp_sel , " KD" ), x = " dPSI (shRNA - CTRL)" , y = " PDiff" )
19641965 dl_store $ splice_volcano(p )
19651966 make_splice_volcano_plot_hc(tbl , rbp_sel )
@@ -2516,17 +2517,12 @@ server <- function(input, output, session) {
25162517 p <- ggplot(dpsi_table , aes(x = Type , y = dPSI )) +
25172518 geom_jitter(width = 0.2 , alpha = 0.6 , size = 1.5 ) +
25182519 geom_violin(alpha = .7 ) +
2519- theme_minimal () +
2520+ theme_charm () +
25202521 ylab(" dPSI (shRNA - CTRL)" ) +
25212522 xlab(" Event Type" ) +
25222523 ggtitle(" Uploaded data" , subtitle = subtitle_text ) +
25232524 coord_flip() +
2524- geom_hline(yintercept = 0 , linetype = " dashed" ) +
2525- theme(
2526- plot.title = element_text(hjust = 0.5 ),
2527- text = element_text(size = 20 , family = " Arial MS" ),
2528- plot.subtitle = element_text(hjust = 0.5 )
2529- )
2525+ geom_hline(yintercept = 0 , linetype = " dashed" )
25302526 dl_store $ splice_initial(p )
25312527 p
25322528 })
@@ -2788,7 +2784,7 @@ server <- function(input, output, session) {
27882784 # example (bare-\r line endings normalised by read_user_table) lands
27892785 # here in the right shape; this surfaces a readable message if a
27902786 # malformed file ever slips through instead of erroring in the analysis.
2791- validate(
2787+ shiny :: validate(
27922788 need(all(c(" Event.ID" , " dPSI" ) %in% names(user_binding_df())),
27932789 " Uploaded file is missing required columns (Event.ID, dPSI)." )
27942790 )
@@ -2828,7 +2824,7 @@ server <- function(input, output, session) {
28282824 # example (bare-\r line endings normalised by read_user_table) lands
28292825 # here in the right shape; this surfaces a readable message if a
28302826 # malformed file ever slips through instead of erroring in the analysis.
2831- validate(
2827+ shiny :: validate(
28322828 need(all(c(" Event.ID" , " dPSI" ) %in% names(user_binding_df())),
28332829 " Uploaded file is missing required columns (Event.ID, dPSI)." )
28342830 )
@@ -2856,7 +2852,7 @@ server <- function(input, output, session) {
28562852 # ---- Volcano plot helper ----
28572853 make_volcano_plot <- function (tbl , rbp ) {
28582854 if (is.null(tbl ) || nrow(tbl ) == 0 ) {
2859- ggplot() + annotate(" text" , x = 0 , y = 0 , label = paste(" No results for" , rbp )) + theme_void ()
2855+ ggplot() + annotate(" text" , x = 0 , y = 0 , label = paste(" No results for" , rbp ), family = CHARM_FONT ) + theme_charm_void ()
28602856 } else {
28612857 ggplot(tbl , aes(x = logFC , y = B ,
28622858 text = paste0(" Gene: " , gene ,
@@ -2871,19 +2867,10 @@ server <- function(input, output, session) {
28712867 # bigger than the background cloud, matching the on-screen
28722868 # highcharter version below.
28732869 scale_size_manual(values = c(" None" = 1.5 , " RBP" = 4 , " Selected" = 2.5 )) +
2874- theme_bw () +
2870+ theme_charm () +
28752871 labs(title = paste(rbp ," KD" ), x = " Log2 Fold-Change" , y = " B-statistic" ) +
2876- theme(legend.position = " none" , plot.title = element_text(hjust = 0.5 )) +
2877- theme(
2878- axis.line = element_line(colour = " black" ),
2879- panel.grid = element_blank(),
2880- panel.border = element_blank(),
2881- panel.background = element_blank(),
2882- plot.title = element_text(hjust = 0.5 ),
2883- plot.subtitle = element_text(hjust = 0.5 ),
2884- text = element_text(size = 15 , face = " bold" ),
2885- legend.position = " none"
2886- )
2872+ theme(legend.position = " none" ) +
2873+ theme(legend.position = " none" )
28872874 }
28882875 }
28892876
@@ -2919,7 +2906,7 @@ server <- function(input, output, session) {
29192906 # is left untouched since it still feeds the PNG download handler.
29202907 make_volcano_plot_hc <- function (tbl , rbp , output_id = " volcano_plot" ) {
29212908 if (is.null(tbl ) || nrow(tbl ) == 0 ) {
2922- return (highcharter :: highchart() %> % highcharter :: hc_title(text = paste(" No results for" , rbp )))
2909+ return (highcharter :: highchart() %> % charm_hc_style() % > % highcharter :: hc_title(text = paste(" No results for" , rbp )))
29232910 }
29242911 # Per-point hex color (rather than group=highlight + hc_colors()) so
29252912 # coloring is exact regardless of which highlight categories happen to
@@ -2947,7 +2934,7 @@ server <- function(input, output, session) {
29472934 rbp_df <- plot_df [ is_rbp , , drop = FALSE ]
29482935
29492936 hc <- highcharter :: highchart() %> %
2950- highcharter :: hc_title(text = paste(rbp , " KD" )) %> %
2937+ charm_hc_style() % > % highcharter :: hc_title(text = paste(rbp , " KD" )) %> %
29512938 highcharter :: hc_xAxis(title = list (text = " Log2 Fold-Change" )) %> %
29522939 highcharter :: hc_yAxis(title = list (text = " B-statistic" )) %> %
29532940 highcharter :: hc_tooltip(pointFormat = " Gene: {point.gene}<br>logFC: {point.logfc_r}<br>B: {point.b_r}<br>P: {point.p_r}" ) %> %
@@ -2982,7 +2969,7 @@ server <- function(input, output, session) {
29822969 # (dPSI vs Pdiff, colored by highlight, tooltip keyed by Event.ID).
29832970 make_splice_volcano_plot_hc <- function (tbl , rbp , output_id = " plot_splice_volcano" ) {
29842971 if (is.null(tbl ) || nrow(tbl ) == 0 ) {
2985- return (highcharter :: highchart() %> % highcharter :: hc_title(text = paste(" No results for" , rbp )))
2972+ return (highcharter :: highchart() %> % charm_hc_style() % > % highcharter :: hc_title(text = paste(" No results for" , rbp )))
29862973 }
29872974 # See make_volcano_plot_hc() above for why this uses per-point hex
29882975 # color instead of group=highlight + hc_colors().
@@ -2995,7 +2982,7 @@ server <- function(input, output, session) {
29952982 highcharter :: hcaes(x = dPSI , y = Pdiff , color = point_color , key = Event.ID ),
29962983 fast = TRUE
29972984 ) %> %
2998- highcharter :: hc_title(text = paste0(" Volcano Plot: " , rbp , " KD" )) %> %
2985+ charm_hc_style() % > % highcharter :: hc_title(text = paste0(" Volcano Plot: " , rbp , " KD" )) %> %
29992986 highcharter :: hc_xAxis(title = list (text = " dPSI (shRNA - CTRL)" )) %> %
30002987 highcharter :: hc_yAxis(title = list (text = " PDiff" )) %> %
30012988 highcharter :: hc_tooltip(pointFormat = " Event: {point.key}" ) %> %
@@ -3178,11 +3165,11 @@ server <- function(input, output, session) {
31783165 expr_top_panel(" gene" )
31793166
31803167 output $ expr_gene_plot <- renderPlot({
3181- # on.exit fires even when validate()/need() below stops execution (an
3168+ # on.exit fires even when shiny:: validate()/need() below stops execution (an
31823169 # unrecognized gene) -- the plain hide_status() call after it would
31833170 # never run in that case, leaving the status banner stuck up.
31843171 on.exit(hide_status(), add = TRUE )
3185- validate(
3172+ shiny :: validate(
31863173 need(gene %in% unlist(lapply(charm_obj , function (x ) rownames(x $ DEGenes ))),
31873174 paste(" Gene" , gene , " not found in any RBP DEGenes tables." ))
31883175 )
@@ -3203,7 +3190,7 @@ server <- function(input, output, session) {
32033190
32043191 output $ expr_hallmark_plot <- renderPlot({
32053192 on.exit(hide_status(), add = TRUE )
3206- validate(
3193+ shiny :: validate(
32073194 need(geneset %in% unlist(lapply(charm_obj , function (x ) x $ GSEA $ pathway )),
32083195 paste0(" Geneset '" , geneset , " ' not found in any RBP GSEA tables." ))
32093196 )
@@ -3379,7 +3366,7 @@ server <- function(input, output, session) {
33793366 splice_res <- plot_splice_volcano(charm_obj , rbp_sel )
33803367 if (is.null(splice_res )) {
33813368 output $ plot_splice_volcano <- renderPlot({
3382- ggplot() + annotate(" text" , x = 0 , y = 0 , label = paste(" No results for" , rbp_sel )) + theme_void ()
3369+ ggplot() + annotate(" text" , x = 0 , y = 0 , label = paste(" No results for" , rbp_sel ), family = CHARM_FONT ) + theme_charm_void ()
33833370 })
33843371 output $ splice_volcano_table <- DT :: renderDataTable(NULL )
33853372 return ()
@@ -3393,7 +3380,7 @@ server <- function(input, output, session) {
33933380 p <- ggplot(tbl , aes(x = dPSI , y = Pdiff , key = Event.ID , color = highlight )) +
33943381 geom_point(alpha = 0.7 ) +
33953382 scale_color_manual(values = c(" None" = " #CCCCCC" ," RBP" = " #A10702" ," Selected" = " #008057" )) +
3396- theme_bw () +
3383+ theme_charm () +
33973384 theme(legend.position = " none" ) +
33983385 labs(title = paste0(" Volcano Plot: " , rbp_sel , " KD" ), x = " dPSI (shRNA - CTRL)" , y = " PDiff" )
33993386 dl_store $ splice_volcano(p )
@@ -3517,8 +3504,8 @@ server <- function(input, output, session) {
35173504 # RBP must both exist in THIS cell line's Charm object -- an
35183505 # RBP profiled in one line can be absent from another, which
35193506 # would otherwise throw a hard error in just that panel.
3520- # validate() turns that into a readable message instead.
3521- validate(
3507+ # shiny:: validate() turns that into a readable message instead.
3508+ shiny :: validate(
35223509 need(rbp1 %in% names(datasets [[ds_name ]]),
35233510 paste0(rbp1 , " is not available in " , ds_name , " ." )),
35243511 need(all(selected_rbps %in% names(datasets [[ds_name ]])),
@@ -3530,7 +3517,7 @@ server <- function(input, output, session) {
35303517 } else {
35313518 output [[plotname ]] <- renderPlot({
35323519 # Same cross-cell-line guard as the scatter branch above.
3533- validate(
3520+ shiny :: validate(
35343521 need(rbp1 %in% names(datasets [[ds_name ]]),
35353522 paste0(rbp1 , " is not available in " , ds_name , " ." ))
35363523 )
@@ -3960,7 +3947,7 @@ server <- function(input, output, session) {
39603947 }
39613948
39623949 if (length(inc_list ) == 0 && length(dec_list ) == 0 ) {
3963- return (ggplot() + theme_void () + ggtitle(" No heatmap data" ))
3950+ return (ggplot() + theme_charm_void () + ggtitle(" No heatmap data" ))
39643951 }
39653952
39663953 inc_mat <- pad_and_rbind(inc_list )
@@ -4035,14 +4022,9 @@ server <- function(input, output, session) {
40354022 geom_tile() +
40364023 scale_fill_gradient2(low = " #A6B1E1" , mid = " #EEEEEE" , high = " #B07156" , limits = lim , oob = scales :: squish ) +
40374024 labs(x = " Genomic position" , y = " " , fill = fill_label , title = title_text ) +
4038- theme_minimal(base_size = 14 ) +
4039- theme(
4040- text = element_text(size = 16 , face = " bold" ),
4041- axis.text.x = element_text(size = 14 , face = " bold" ),
4042- axis.text.y = if (hide_row_labels ) element_blank() else element_text(size = 14 , face = " bold" ),
4043- axis.title = element_text(size = 16 , face = " bold" ),
4044- panel.grid = element_blank()
4045- ) +
4025+ theme_charm() +
4026+ theme(axis.line = element_blank(), axis.ticks = element_blank(),
4027+ axis.text.y = if (hide_row_labels ) element_blank() else element_text()) +
40464028 geom_segment(data = vline_df ,
40474029 aes(x = x , xend = x , y = 1 , yend = n_rows ),
40484030 linetype = " dashed" , color = " black" , linewidth = 0.4 ,
@@ -4097,14 +4079,14 @@ server <- function(input, output, session) {
40974079 labels_plot <- ggplot() +
40984080 annotate(" text" , x = 1 , y = 0 ,
40994081 label = paste0(" Increased: " , inc_total , " \n " ),
4100- color = inc_color , size = 5 , fontface = " bold" , hjust = - 0.75 ) +
4082+ color = inc_color , size = CHARM_GEOM_TEXT , fontface = " bold" , hjust = - 0.75 , family = CHARM_FONT ) +
41014083 annotate(" text" , x = 1 , y = 0 ,
41024084 label = paste0(" Maintained: " , maint_total , " \n " ),
4103- color = maint_color , size = 5 , fontface = " bold" , hjust = 0.5 ) +
4085+ color = maint_color , size = CHARM_GEOM_TEXT , fontface = " bold" , hjust = 0.5 , family = CHARM_FONT ) +
41044086 annotate(" text" , x = 1 , y = 0 ,
41054087 label = paste0(" Decreased: " , dec_total , " \n " ),
4106- color = dec_color , size = 5 , fontface = " bold" , hjust = 1.75 ) +
4107- theme_void () +
4088+ color = dec_color , size = CHARM_GEOM_TEXT , fontface = " bold" , hjust = 1.75 , family = CHARM_FONT ) +
4089+ theme_charm_void () +
41084090 theme(plot.margin = margin(t = 0 , r = 0 , b = 0 , l = 0 ))
41094091
41104092 # -----------------------------
@@ -4134,14 +4116,14 @@ server <- function(input, output, session) {
41344116 footnote <- ggplot() +
41354117 annotate(" text" , x = 0.5 , y = 0.5 ,
41364118 label = paste(footnote_lines , collapse = " \n " ),
4137- size = 4 , fontface = " italic" , hjust = 0.5 ) +
4138- theme_void ()
4119+ size = CHARM_GEOM_TEXT , fontface = " italic" , hjust = 0.5 , family = CHARM_FONT ) +
4120+ theme_charm_void ()
41394121 return (ggpubr :: ggarrange(labels_plot , heat_row , footnote , ncol = 1 , heights = c(0.05 , 0.88 , 0.07 )))
41404122 }
41414123 return (ggpubr :: ggarrange(labels_plot , heat_row , ncol = 1 , heights = c(0.06 , 0.94 )))
41424124 }
41434125
4144- ggplot() + theme_void () + ggtitle(" No heatmap data" )
4126+ ggplot() + theme_charm_void () + ggtitle(" No heatmap data" )
41454127 }
41464128
41474129
@@ -4199,8 +4181,8 @@ server <- function(input, output, session) {
41994181 annotate(" text" , x = 0.5 , y = 0.5 ,
42004182 label = paste0(" dPSI option '" , input $ binding_dpsi ,
42014183 " ' is not available for " , rbp , " - " , targets , " ." ),
4202- size = 6 , hjust = 0.5 ) +
4203- theme_void ())
4184+ size = CHARM_GEOM_TEXT , hjust = 0.5 , family = CHARM_FONT ) +
4185+ theme_charm_void ())
42044186 }
42054187 dpsi_key <- dpsi_resolved $ key
42064188 dpsi_value <- suppressWarnings(as.numeric(sub(" .*" , " " , dpsi_key )))
@@ -4708,28 +4690,19 @@ server <- function(input, output, session) {
47084690 scale_size_manual( values = c(" Highlighted" = 4 , " Other" = 2.5 )) +
47094691 labs(title = title , subtitle = subtitle ,
47104692 x = xlab , y = ylab , caption = caption ) +
4711- theme_bw() +
4712- theme(
4713- plot.title = element_text(hjust = 0.5 , face = " bold" , size = 15 ),
4714- plot.subtitle = element_text(hjust = 0.5 , size = 11 , color = " #555555" ),
4715- plot.caption = element_text(hjust = 0.5 , size = 9 , color = " #888888" ),
4716- text = element_text(size = 12 ),
4717- panel.grid = element_blank(),
4718- axis.line = element_line(colour = " black" ),
4719- panel.border = element_blank(),
4720- legend.position = if (has_hl ) " right" else " none"
4721- )
4693+ theme_charm() +
4694+ theme(legend.position = if (has_hl ) " right" else " none" )
47224695
47234696 # Label every RBP regardless of highlight status (highlighting should
47244697 # only recolor points red, not remove everyone else's labels) --
47254698 # color/weight the text the same way as its point via the Highlight
47264699 # aesthetic instead of only repelling a filtered subset.
47274700 p <- p + ggrepel :: geom_text_repel(
47284701 aes(label = RBP , color = Highlight , fontface = Fontface ),
4729- size = 3.5 ,
4702+ size = CHARM_GEOM_TEXT ,
47304703 max.overlaps = 30 ,
47314704 show.legend = FALSE
4732- )
4705+ , family = CHARM_FONT )
47334706 p
47344707 }
47354708
@@ -4953,7 +4926,7 @@ server <- function(input, output, session) {
49534926 if (! is.null(res $ error )) {
49544927 return (ggplot() +
49554928 annotate(" text" , x = 0.5 , y = 0.5 , label = res $ error ,
4956- size = 6 , hjust = 0.5 ) + theme_void ())
4929+ size = CHARM_GEOM_TEXT , hjust = 0.5 , family = CHARM_FONT ) + theme_charm_void ())
49574930 }
49584931
49594932 hl_valid <- intersect(input $ network_highlight_rbps , res $ common_rbps )
0 commit comments