Skip to content

Commit

Permalink
Merge pull request #310 from lishensuo/develop24
Browse files Browse the repository at this point in the history
add daily-gene module
  • Loading branch information
lishensuo authored Feb 23, 2024
2 parents 062751d + 24207c7 commit 7cea773
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 23 deletions.
2 changes: 1 addition & 1 deletion R/tcga_surv.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tcga_surv_get <- function(item,
install.packages("stringr")
}

print(head(TCGA_cli_data))
# print(head(TCGA_cli_data))
# type 有几种额外的 Xena 做过聚合的结果
# "COADREAD" "FPPP" "GBMLGG" "LUNG" "PANCAN"
# FPPP 好像不是正常的样本,不推荐使用,已去除
Expand Down
138 changes: 138 additions & 0 deletions inst/shinyapp/modules/hom-daily-gene.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
ui.home_daily_gene <- function(id) {
ns <- NS(id)
tagList(
# h3("Daily Gene", icon = "dice", align = "center"),
fluidRow(
column(6, #offset = 1,
uiOutput(ns("gene_tip")),

fluidRow(
column(12, align = "center",
actionBttn(
inputId = ns("change_gene"),
label = "Sample another one",
style = "bordered",
color = "primary",
icon = icon("dice"),
size = "sm"
)
)
)
),
column(6, #offset = 2,
uiOutput(ns("gene_cancer"))
)
),
# fluidRow(
# column(8, offset = 2,
# uiOutput(ns("gene_cancer"))
# )
# ),
)
}





server.home_daily_gene <- function(input, output, session) {
ns <- session$ns


gene_sp = reactiveValues(gene="TP53")


gene_sp = reactive({
if(input$change_gene==0){
current_date <- Sys.Date()
formatted_date <- as.integer(format(current_date, "%Y%m%d"))
set.seed(formatted_date)
gene_sp = sample(pancan_identifiers$gene,size = 1)
} else {
current_time <- Sys.time()
total_seconds <- as.integer(difftime(current_time, as.POSIXct("1970-01-01"), units = "secs"))
set.seed(total_seconds)
gene_sp = sample(pancan_identifiers$gene,size = 1)
}
gene_sp
})

gene_data = reactive({
data.list = get_pancan_gene_value(gene_sp(), norm = "tpm")
data = data.list$expression
shiny::validate(
need(try(!all(is.na(data))),
"Sorry, no valid value for the sampling gene. Pleaese click the button again."),
)
data = data.frame(value=data) %>%
tibble::rownames_to_column("sample") %>%
dplyr::inner_join(tcga_gtex) %>%
dplyr::mutate(tissue = as.character(tissue))
data
})



stat_res = reactive({
data = gene_data()
stat_res = compare_means(value ~ type2, data = data,
group.by = "tissue") %>%
dplyr::arrange(p)
stat_res
})


output$gene_cancer = renderUI({
output$box_plot = renderPlotly({
data = gene_data()
p = data %>%
dplyr::filter(tissue == stat_res()$tissue[1]) %>%
dplyr::filter(value > -9.966) %>%
ggboxplot(x = "type2", y = "value",
fill = "type2",
color = "black",
width = 0.5,
palette = "aaas") +
xlab(paste0("TCGA-",stat_res()$tissue[1])) +
ylab("TPM value (TCGA+GTEx)") +
ggtitle(gene_sp(),
subtitle = paste0("Wilcoxon, p=",
formatC(stat_res()$p[1], format = "e", digits = 2))) +
theme(legend.position = "none",
text = element_text(size = 12),
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(size = 12, hjust = 0.5))
subtitle_txt = paste0("Wilcoxon, p=", formatC(stat_res()$p[1], format = "e", digits = 2))
title_text =
p = ggplotly(p) %>%
layout(title = list(text = paste0(gene_sp(),'<br>','<sup>', subtitle_txt,'</sup>'),
font = list(size = 18)),
xaxis = list(font=list(size = 15)),
yaxis = list(font=list(size = 10)))
p
})
plotlyOutput(ns("box_plot"), height = "220px")
})


output$gene_tip = renderUI({

tcga_link = "https://gdc.cancer.gov/resources-tcga-users/tcga-code-tables/tcga-study-abbreviations"
gc_link = paste0("https://www.genecards.org/cgi-bin/carddisp.pl?gene=", gene_sp())
pm_link = paste0("https://pubmed.ncbi.nlm.nih.gov/?term=%28",gene_sp(),"%29+AND+%28cancer%29")
tagList(
tags$ul(
tags$li(gene_sp()," is most differentially expressed in ",
a(paste0("TCGA-",stat_res()$tissue[1]), href = tcga_link), ".",
style = "font-size: 16px;"),
tags$li("Explore its pan-cancer feature in right panel. ☞",style = "font-size: 16px;"),
tags$li("Search more about the gene in ",
a("GeneCards", href = gc_link), " or ",
a("PubMed", href = pm_link), ".",
style = "font-size: 16px;")
)
)
})
}


3 changes: 2 additions & 1 deletion inst/shinyapp/modules/home-pancan-search.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ui.home_search_box <- function(id) {
)
)
),
br(),
fluidRow(
column(11, offset = 1,
h5(strong("2.Run two explorations:"))
Expand Down Expand Up @@ -214,7 +215,7 @@ server.home_search_box <- function(input, output, session) {
br(),
h3("NOTEs:"),
h4("1. It will take about ",strong("one minute",style="color:red")," for the general analysis which includes the relationships between queried molecule and ",
"(1) chinical phenotypes, (2) survival influence, (3) tumor index (4) immune infiltration, (5) pathway activity.",
"(1) clinical phenotypes, (2) survival influence, (3) tumor index (4) immune infiltration, (5) pathway activity.",
"You can see the ",a("example report", href = "https://lishensuo.github.io/book_test/UCSCXenaShiny_example_report.html")," while waiting."),
h4("2. It will take about ", strong("10 seconds",style="color:red"), " for the generation of organized report in html format."),
h4("3. Final, the analyzed result under the report can be directly downloaded in zip format.")
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/server/modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@ observeEvent(req(input$navbar %in% c(


callModule(server.home_search_box, "homepage_pancan_search")

callModule(server.home_daily_gene, "homepage_daily_gene")
48 changes: 30 additions & 18 deletions inst/shinyapp/ui/home.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ui.page_home <- function() {
tags$link(rel = "stylesheet", type = "text/css", href = "bootstrap4.css")
),
fluidRow(
column(5,
column(4,
tags$div(
column(
12,
Expand All @@ -34,29 +34,21 @@ ui.page_home <- function() {
)
)
),
column(4,
wellPanel(
style = "background: #b3cde3",
h3("❤ Daily Gene", icon = "dice", align = "center"),
ui.home_daily_gene("homepage_daily_gene"),
)
),
column(4,
wellPanel(
style = "background: #a6cee3",
h2("TCGA Pan-Cancer Query!", align = "center"),
h3(" Pan-Cancer Query", align = "center"),
# br(),
ui.home_search_box("homepage_pancan_search"),
)
),
column(3,
wellPanel(
style = "background: #b3cde3",
h2("Latest Release Notes", align = "center"),
br(),
tags$ul(
tags$li("2024-01-21: Adjust homepge with slick gallery to show basic page help.",style = "font-size: 14px;"),
tags$li("2024-01-16: Introduce MSigDB genesets for molecule batch analysis.",style = "font-size: 14px;"),
tags$li("2023-12-20: Add download modules that support data requisition.",style = "font-size: 14px;"),
tags$li("See more update logs in",
a("Github", href="https://github.com/openbiox/UCSCXenaShiny"),
style = "font-size: 16px;")
)
)
)
),
tags$br(),
h2(strong("※ Shiny Page Gallery")),
Expand All @@ -68,7 +60,7 @@ ui.page_home <- function() {
)
),
br(),br(),
h2(strong("Quick TCGA modules with specific functions")),
h2(strong("Custom TCGA modules with specific functions")),
tags$hr(style = "border:none; border-top:5px solid #5E81AC;"),
fluidRow(
column(
Expand Down Expand Up @@ -240,8 +232,28 @@ ui.page_home <- function() {
"similar versatile pipeline analyses (including comparison, correlation, survival) with personalized operations for PCAWG and CCLE databases."))
)
)
),
br(),
h2(strong("※ Latest significant release notes")),
tags$hr(style = "border:none; border-top:5px solid #5E81AC;"),
fluidRow(
column(12, #offset = 1,
tags$ul(
tags$li("2024-02-14: Incorporate the PharmacoGenomics analysis modules",style = "font-size: 20px;"),
tags$li("2024-01-21: Adjust homepge with slick gallery to show basic page help.",style = "font-size: 20px;"),
tags$li("2024-01-16: Introduce MSigDB genesets for molecule batch analysis.",style = "font-size: 20px;"),
tags$li("2023-12-20: Add download modules that support data requisition.",style = "font-size: 20px;"),
tags$li("See more update logs in our",
a("Github", href="https://github.com/openbiox/UCSCXenaShiny"), ".",
"If you have any questions, please report the ",
a("issue", href = "https://github.com/openbiox/UCSCXenaShiny/issues"),
" or email at [email protected]. We will get back to you ASAP.",
style = "font-size: 20px;")
)
)
)
)
)
}


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 = "Quick T·P·C Analysis",
title = "Custom T·P·C Modules",
icon = icon("buromobelexperte"),
# tabPanel(
# "Combo: Single Gene Analysis",
Expand Down
2 changes: 1 addition & 1 deletion inst/shinyapp/ui/pancan-analysis-tcga.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 Analysis",
title = "Personalized T·P·C Pipelines",
icon = icon("buromobelexperte"),
#### TCGA
tabPanel(
Expand Down

0 comments on commit 7cea773

Please sign in to comment.