Skip to content

Commit

Permalink
improve ui of TPC analysis and navigation bar (openbiox#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
lishensuo authored Jul 10, 2024
1 parent e55a5fb commit 6f746ed
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 39 deletions.
18 changes: 9 additions & 9 deletions R/query_general.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ query_general_id = function(){
# pcawg_id_referrence = load_data("pcawg_identifier")
pcawg_id_referrence = load_data("v2_pcawg_id")
pcawg_id_option$`Molecular profile` = list(
`mRNA Expression` = list(all = sort(v2_pcawg_id$L3[v2_pcawg_id$L2=="Gene"]), default = "TP53"),
`Promoter Activity` = list(all = sort(v2_pcawg_id$L3[v2_pcawg_id$L2=="Promoter"]), default = "prmtr.1"),
`Gene Fusion` = list(all = sort(v2_pcawg_id$L3[v2_pcawg_id$L2=="Fusion"]), default = "SAMD11"),
`miRNA Expression` = list(all = sort(v2_pcawg_id$L3[v2_pcawg_id$L2=="miRNA"]), default = "hsa-let-7a-2-3p"),
`APOBEC Mutagenesis` = list(all = sort(v2_pcawg_id$L3[v2_pcawg_id$L2=="Muta"]), default = "A3A_or_A3B")
`mRNA Expression` = list(all = sort(pcawg_id_referrence$L3[pcawg_id_referrence$L2=="Gene"]), default = "TP53"),
`Promoter Activity` = list(all = sort(pcawg_id_referrence$L3[pcawg_id_referrence$L2=="Promoter"]), default = "prmtr.1"),
`Gene Fusion` = list(all = sort(pcawg_id_referrence$L3[pcawg_id_referrence$L2=="Fusion"]), default = "SAMD11"),
`miRNA Expression` = list(all = sort(pcawg_id_referrence$L3[pcawg_id_referrence$L2=="miRNA"]), default = "hsa-let-7a-2-3p"),
`APOBEC Mutagenesis` = list(all = sort(pcawg_id_referrence$L3[pcawg_id_referrence$L2=="Muta"]), default = "A3A_or_A3B")
)
pcawg_id_option$`Tumor index` = list(
`Tumor Purity` = list(all = c("purity", "ploidy", "purity_conf_mad", "wgd_status", "wgd_uncertain"),
Expand All @@ -201,10 +201,10 @@ query_general_id = function(){
# ccle_id_referrence = load_data("ccle_identifier")
ccle_id_referrence = load_data("v2_ccle_id")
ccle_id_option$`Molecular profile` = list(
`mRNA Expression` = list(all = sort(v2_pcawg_id$L3[v2_pcawg_id$L2=="Gene"]), default = "TP53"),
`Protein Expression` = list(all = sort(v2_ccle_id$L3[v2_ccle_id$L2=="Protein"]), default = "14-3-3_beta"),
`Copy Number Variation` = list(all = sort(v2_pcawg_id$L3[v2_pcawg_id$L2=="Gene"]), default = "TP53"),
`Mutation status` = list(all = sort(v2_pcawg_id$L3[v2_pcawg_id$L2=="Gene"]), default = "TP53")
`mRNA Expression` = list(all = sort(ccle_id_referrence$L3[ccle_id_referrence$L2=="Gene"]), default = "TP53"),
`Protein Expression` = list(all = sort(ccle_id_referrence$L3[ccle_id_referrence$L2=="Protein"]), default = "14-3-3_beta"),
`Copy Number Variation` = list(all = sort(ccle_id_referrence$L3[ccle_id_referrence$L2=="Gene"]), default = "TP53"),
`Mutation status` = list(all = sort(ccle_id_referrence$L3[ccle_id_referrence$L2=="Gene"]), default = "TP53")
)
ccle_id_option$`Tumor index` = list(
`Tumor Purity` = list(all = c("Purity", "Ploidy", "Genome Doublings", "Lineage"),
Expand Down
4 changes: 2 additions & 2 deletions R/vis_pancan_value.R
Original file line number Diff line number Diff line change
Expand Up @@ -1166,13 +1166,13 @@ vis_gene_cor_cancer <- function(Gene1 = "CSF1R",
dplyr::distinct(.data$sample, .keep_all = TRUE)

t1 <- query_pancan_value(Gene1, data_type = data_type1, opt_pancan = opt_pancan)
if (is.null(t1[[1]])) {
if (length(na.omit(t1[[1]]))==0) {
warning("No data available", immediate. = TRUE)
return(NULL)
}
if (is.list(t1)) t1 <- t1[[1]]
t3 <- query_pancan_value(Gene2, data_type = data_type2, opt_pancan = opt_pancan)
if (is.null(t3[[1]])) {
if (length(na.omit(t1[[3]]))==0) {
warning("No data available", immediate. = TRUE)
return(NULL)
}
Expand Down
4 changes: 2 additions & 2 deletions inst/shinyapp/App.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ ui <- tagList(
# inst/shinyapp/ui
ui.page_home(),
ui.page_repository(),
ui.page_general_analysis(),
ui.page_pancan_quick(),
ui.page_pancan_tcga(),
ui.page_PharmacoGenomics(),
ui.page_general_analysis(),
ui.page_download(),
ui.page_PharmacoGenomics(),
ui.page_help(),
ui.page_developers(),
footer = ui.footer(),
Expand Down
1 change: 1 addition & 0 deletions inst/shinyapp/modules/02_quick/modules-1-tcga-03-Cor.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ server.modules_1_tcga_03 = function(input, output, session){
color = input$color,
alpha = input$alpha
)
if(is.null(p)){return(NULL)}
p <- p + themes_list[[input$theme]] +
theme(text = element_text(size = 20),
legend.position = "none")
Expand Down
18 changes: 15 additions & 3 deletions inst/shinyapp/modules/02_quick/modules-1-tcga-09-KM.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,19 @@ server.modules_1_tcga_09 = function(input, output, session){
load_data("tcga_surv"),
by = "sample"
)

dat1 = tcga_surv_get(
TCGA_cohort = input$Cancer, item = mol_info$molecule(),
profile = mol_info$profile(), TCGA_cli_data = TCGA_cli_merged
)
if(is.null(dat1)){dat1 = data.frame(
sampleID=NA, value=NA,
OS=NA, OS.time=NA,
DSS=NA, DSS.time=NA,
DFI=NA, DFI.time=NA,
PFI=NA, PFI.time=NA,
gender=NA, age=NA, stage=NA)
}
# filter
dat2 = dat_filter(data = dat1, age = input$age,
gender = input$sex, stage = input$stage,
Expand All @@ -159,6 +168,10 @@ server.modules_1_tcga_09 = function(input, output, session){


tips = eventReactive(input$submit_bt, {
shiny::validate(
need(try(nrow(sur_dat())>0),
"Error: Please select a valid molecule.")
)
if(mol_info$profile() == "mutation"){
sur_dat2 = sur_dat() %>%
dplyr::mutate(group = value)
Expand Down Expand Up @@ -197,14 +210,12 @@ server.modules_1_tcga_09 = function(input, output, session){

output$msg = renderPrint({cat(tips())})




plot_func = eventReactive(input$submit_bt, {
req(grep("Note", tips()))
id <- showNotification(h3("The task is running..."), duration = NULL, closeButton = FALSE, type = "message")
on.exit(removeNotification(id), add = TRUE) #reactive语句执行完毕时,运行remove命令
cutoff_mode = ifelse(input$groupby=="Optimal cutoff","Auto","Custom")

p <- tcga_surv_plot(sur_dat(),
cutoff_mode = cutoff_mode, #"Custom",
cutpoint = c(50, 50),
Expand All @@ -218,6 +229,7 @@ server.modules_1_tcga_09 = function(input, output, session){
w <- waiter::Waiter$new(id = ns("surplot"), html = waiter::spin_hexdots(), color = "black")
observeEvent(input$submit_bt,{
shinyjs::disable("submit_bt")

output$surplot <- renderUI({
w$show()
output$plot = renderPlot(plot_func())
Expand Down
2 changes: 2 additions & 0 deletions inst/shinyapp/modules/02_quick/modules-1-tcga-10-Cox.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ server.modules_1_tcga_10 = function(input, output, session){
plot_func = eventReactive(input$search_bttn, {
id <- showNotification(h3("The task is running..."), duration = NULL, closeButton = FALSE, type = "message")
on.exit(removeNotification(id), add = TRUE) #reactive语句执行完毕时,运行remove命令

p <- vis_unicox_tree(
Gene = mol_info$molecule(),
measure = input$measure,
threshold = 0.5,
data_type = mol_info$profile(),
values = c(input$first_col, input$second_col, input$third_col)
)
if(is.null(p)){return(NULL)}
pdata <- p$data %>%
as.data.frame() %>%
dplyr::select(cancer, measure, n_contrast, n_ref, beta, HR_log, lower_95_log, upper_95_log, Type, p.value)
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/modules/03_tcga/modules-pancan-comp-m2o.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ui.modules_pancan_comp_m2o = function(id) {
h4(strong("S3.1 Set analysis parameters")),
# br(),br(),
# h4("1. Set method"),
selectInput(ns("comp_method"), "Correlation method:",choices = c("t.test", "wilcox.test")),
selectInput(ns("comp_method"), "Comparison method:",choices = c("wilcox.test", "t.test"),selected="wilcoxon"),
shinyWidgets::actionBttn(
ns("cal_batch_comp"), "Run",
style = "gradient",
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2m.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ ui.modules_pancan_comp_o2m = function(id) {
style = "height:1100px",

h4(strong("S3.1 Set analysis parameters")),
selectInput(ns("comp_method"), "Comparison method:",choices = c("t-test", "wilcoxon")),
selectInput(ns("comp_method"), "Comparison method:",choices = c("wilcoxon","t-test"),selected="wilcoxon"),
shinyWidgets::actionBttn(
ns("step3_plot_line_1"), "Run (Calculate)",
style = "gradient",
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/modules/03_tcga/modules-pancan-comp-o2o.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ui.modules_pancan_comp_o2o = function(id) {
content = "analyze_comp_1"),
style = "height:1100px",
h4(strong("S3.1 Set analysis parameters")),
selectInput(ns("comp_method"), "Comparison method:",choices = c("wilcoxon","t-test")),
selectInput(ns("comp_method"), "Comparison method:",choices = c("wilcoxon","t-test"),selected="wilcoxon"),

h4(strong("S3.2 Set visualization parameters")),
fluidRow(
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/modules/03_tcga/modules-pancan-cor-m2o.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ui.modules_pancan_cor_m2o = function(id) {
content = "analyze_cor_3"),

h4(strong("S3.1 Set analysis parameters")),
selectInput(ns("cor_method"),"Correlation method:",choices = c("pearson", "spearman")),
selectInput(ns("cor_method"),"Correlation method:",choices = c("spearman","pearson"), selected="Spearman"),
shinyWidgets::actionBttn(
ns("cal_batch_cor"), "Run",
style = "gradient",
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2m.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ ui.modules_pancan_cor_o2m = function(id) {
style = "height:1100px",
h4(strong("S3.1 Set analysis parameters")),
# br(),
selectInput(ns("cor_method"), "Correlation method:",choices = c("Pearson", "Spearman")),
selectInput(ns("cor_method"), "Correlation method:",choices = c("Spearman","Pearson"), selected="Spearman"),
shinyWidgets::actionBttn(
ns("step3_plot_bar_1"), "Run (Calculate)",
style = "gradient",
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/modules/03_tcga/modules-pancan-cor-o2o.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ui.modules_pancan_cor_o2o = function(id) {
content = "analyze_cor_1"),
style = "height:1100px",
h4(strong("S3.1 Set analysis parameters")),
selectInput(ns("cor_method"), "Correlation method:",choices = c("Spearman", "Pearson")),
selectInput(ns("cor_method"), "Correlation method:",choices = c("Spearman", "Pearson"),selected="Spearman"),
h4(strong("S3.2 Set visualization parameters")),
fluidRow(
column(3, colourpicker::colourInput(inputId = ns("line_color"), "Line color:", "#0000FF")),
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/server/general-analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ output$ga_dataset_table <- DT::renderDataTable(


# Individual analysis pages -------------------------------------------------------------
observeEvent(req(input$navbar=="General Dataset Analysis"),{
observeEvent(req(input$navbar=="General Analysis"),{
callModule(
server.modules_ga_scatter_correlation, "module_ga_scatter_correlation",
selected_database_rm_phenotype, selected_database_add_url_and_phenotype,
Expand Down
16 changes: 7 additions & 9 deletions inst/shinyapp/server/modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ observeEvent(req(input$navbar=="CCLE: Drug analysis"),{
html_spin = tagList(spin_1(), br(),
h2("Loading (Only needed for the first time)"))
# TCGA pancan
observeEvent(req(input$navbar=="TCGA: Cross-Omics Analysis"),{
waiter <- waiter::Waiter$new(color = "grey", fadeout = TRUE, html = html_spin)
waiter$show()
callModule(server.modules_pancan_cross_gene_o2m, "modules_pancan_cross_gene_o2m")
callModule(server.modules_pancan_cross_pw_o2m, "modules_pancan_cross_pw_o2m")
on.exit(waiter$hide())
}, once = TRUE)

observeEvent(req(input$navbar=="TCGA: Correlation Analysis"),{
waiter <- waiter::Waiter$new(color = "grey", fadeout = TRUE, html = html_spin)
waiter$show()
Expand Down Expand Up @@ -98,7 +90,13 @@ observeEvent(req(input$navbar=="TCGA: Survival Analysis"),{
on.exit(waiter$hide())
}, once = TRUE)


observeEvent(req(input$navbar=="TCGA: Cross-Omics Analysis"),{
waiter <- waiter::Waiter$new(color = "grey", fadeout = TRUE, html = html_spin)
waiter$show()
callModule(server.modules_pancan_cross_gene_o2m, "modules_pancan_cross_gene_o2m")
callModule(server.modules_pancan_cross_pw_o2m, "modules_pancan_cross_pw_o2m")
on.exit(waiter$hide())
}, once = TRUE)

# PCAWG
observeEvent(req(input$navbar=="PCAWG: Correlation Analysis"),{
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/server/repository.R
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ observeEvent(input$show_R_code, {

# ref: https://stackoverflow.com/questions/38706965/is-there-any-way-for-an-actionbutton-to-navigate-to-another-tab-within-a-r-shi
observeEvent(input$analyze_data, {
updateNavbarPage(session = session, inputId = "navbar", selected = "General Dataset Analysis")
updateNavbarPage(session = session, inputId = "navbar", selected = "General Analysis")
})

# Show alert info when select rows from table -----------------------------
Expand Down
6 changes: 3 additions & 3 deletions inst/shinyapp/shiny-doc/intro_personal_pips.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
</center>


<font size="5">Here, we introduced a series of personalized TPC pipelines for comprehensive and precise TPC molecule exploration with various operations. In general, 8 panels for common analytical scenario are available, as follows:</font>
<font size="5">Here, we introduced a series of personalized TPC pipelines for comprehensive and precise TPC molecule exploration with various operations. In general, 9 panels for common analytical scenario are available, as follows:</font>


<center>
<img src="https://raw.githubusercontent.com/lishensuo/images2/main/img01/image-20240413163342892.png" alt="image-20240413163342892" style="zoom:50%";/>
<img src="https://raw.githubusercontent.com/lishensuo/images2/main/img01/image-20240708162416954.png" alt="image-20240413163342892" style="zoom:50%";/>
</center>


<font size="5">Each analytical pipeline comprises of three main subpanels (S1, S2, S3).</font>
<font size="5">Generally, each analytical pipeline comprises of three main subpanels (S1, S2, S3).</font>

- <font size="5">In S1 subpanel, you can prepare and select the expected data and sample ranges;</font>
- <font size="5">In S2 subpanel, you can fetch the specific tumor data for downstream analysis;</font>
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/ui/general-analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ui.page_general_analysis <- function() {
# # ui.sg.pancan.analysis("sg.pancan.analysis"))
# )
tabPanel(
title = "General Dataset Analysis",
title = "General Analysis",
icon = icon("angle-double-down"),
fluidRow(
column(
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/ui/pancan-analysis-quick.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ui.page_pancan_quick <- function() {
navbarMenu(
title = "Custom T·P·C Modules",
title = "T·P·C Modules",
icon = icon("buromobelexperte"),

tabPanel(
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/ui/pancan-analysis-tpc.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ui.page_pancan_tcga <- function() {
navbarMenu(
title = "Personalized T·P·C Pipelines",
title = "T·P·C Pipelines",
icon = icon("buromobelexperte"),
tabPanel(
"Introduction",
Expand Down

0 comments on commit 6f746ed

Please sign in to comment.