Skip to content

Commit

Permalink
Merge pull request #306 from lishensuo/develop22
Browse files Browse the repository at this point in the history
add shiny visualize params & update NEWS.md
  • Loading branch information
lishensuo authored Jan 28, 2024
2 parents 2611fdd + 4c79557 commit 3b24ee0
Show file tree
Hide file tree
Showing 24 changed files with 792 additions and 182 deletions.
40 changes: 38 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,47 @@ https://github.com/openbiox/UCSCXenaShiny/commit/147f4612943df940d3bbd409e82a492

### Datasets

- `load_data("tcga_PW")`: ssGSEA scores of HALLMARK, KEGG, IOBR terms for TCGA samples.
- `load_data("tcga_PW_meta")`: metadata annotation for HALLMARK, KEGG, IOBR terms.
- `load_data("pcawg_TIL")`: PCAWG TIL data.
- `load_data("pcawg_PW")`: ssGSEA scores of HALLMARK, KEGG, IOBR terms for PCAWG samples.

### R Package Functions

- `vis_dim_dist()` function and corresponding shiny module.
- `.opt_pancan` : Default setting for alternative TPC datasets.
- `mol_quick_analysis()`: Quick molecule analysis and report generation based on TCGA dataset.
- `query_tcga_group()`: Group TPC samples by build-in or custom phenotype and support filtering or merging operations.
- `vis_dim_dist()`: Visualize the distribution difference of TCGA samples after dimension reduction analysis.
- `vis_identifier_dim_dist()`: Visualize the distribution difference of samples after Molecule Identifier dimension reduction analysis.
- `vis_toil_Mut()`: Visualize molecular profile difference between mutation and wild status of queried gene.
- `vis_toil_Mut_cancer()`: Visualize molecular profile difference between mutation and wild status of queried gene in Single Cancer Type

### Shiny application

- abc
- Homepage
- Added slicker gallery to display page summary;
- Added report generation for TCGA pan-cancer exploration.

- General Dataset Analysis

- Added one general dimension reduction analysis module.

- Quick TPC Analysis

- Added one module for association analysis between molecule and pathway;
- Added one module for association analysis between molecule and mutation;
- Added one module for dimension reduction analysis.

- Personalized Analysis

- Designed personalized TPC analysis pipelines for based on 3 methods and 3 modes.

- Download

- Added two modules for exact subset of integrated TPC data and UCSCXena datasets.




## Enhancements

Expand All @@ -26,6 +60,8 @@ UCSCXenaShiny::get_pancan_methylation_value(
)
```

- Supported alternative molecular profiling datasets for quick and personalized TPC analysis.

## Bug Fixes

- Merged data with unequal size in pan-cancer data query with a gene signature (#283), the fix also enhance the sample names match.
Expand Down
8 changes: 8 additions & 0 deletions R/load_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
#' **Builtin datasets**:
#' - `ccle_absolute`: CCLE ABSOLUTE result.
#' - `ccle_info`: CCLE information.
#' - `ccle_info_fine`: cleaned CCLE information for TPC analysis.
#' - `pcawg_info`: PCAWG information.
#' - `pcawg_info_fine`: cleaned PCAWG information for TPC analysis.
#' - `pcawg_purity`: PCAWG tumor purity, ploidy and WGD data.
#' - `tcga_clinical`: TCGA clinical data.
#' - `tcga_clinical_fine`: cleaned TCGA information for TPC analysis.
#' - `tcga_genome_instability`: TCGA genome instability data.
#' - `tcga_gtex`: TCGA and GTEX sample info.
#' - `tcga_purity`: TCGA tumor purity data.
Expand All @@ -31,10 +34,15 @@
#' - `tcga_pan_immune_signature`: TCGA pan-cancer immune signature.
#' - `tcga_stemness`: TCGA tumor stemness data.
#' - `tcga_TIL`: TCGA TIL data.
#' - `tcga_PW`: ssGSEA scores of HALLMARK, KEGG, IOBR terms for TCGA samples.
#' - `tcga_PW_meta`: metadata annotation for HALLMARK, KEGG, IOBR terms.
#' - `tcga_tmb`: TCGA TMB data.
#' - `tcga_armcalls`: TCGA arm alteration calls and Aneuploidy data.
#' - `tcga_dna_repair`: TCGA DNA repair data.
#' - `pancancer_conserved_immune_subtype`: Pan-cancer conserved immune subtypes.
#' - `pcawg_TIL`: PCAWG TIL data.
#' - `pcawg_PW`: ssGSEA scores of HALLMARK, KEGG, IOBR terms for PCAWG samples.

#'
#' @return a dataset, typically a `data.frame`.
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/query_general.R
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ query_general_value = function(L1, L2, L3, database = c("toil","pcawg","ccle"),



#' Title quick molecule analysis and report generation
#' Quick molecule analysis and report generation
#'
#' @inheritParams query_pancan_value
#' @param out_dir path to save analysis result and report, default is '.'
Expand Down
2 changes: 1 addition & 1 deletion R/query_tcga_group.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Group TCGA samples by build-in or custom phenotype and support filtering or merging operations
#' Group TPC samples by build-in or custom phenotype and support filtering or merging operations
#'
#' @param cancer select cancer cohort(s)
#' @param custom upload custom phenotype data
Expand Down
2 changes: 1 addition & 1 deletion R/vis_dim_dist.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Visualize the distribution difference of samples after dimension reduction analysis
#'
#' @param ids molecular identifiers (>=3)
#' @param data_type molecular types, refer to query_pancan_value() fuuntion
#' @param data_type molecular types, refer to query_pancan_value() function
#' @param return.data whether to reture the raw meta/matrix data (list) instead of plot
#' @param DR_method the dimension reduction method
#' @param palette the color setting of RColorBrewer
Expand Down
46 changes: 36 additions & 10 deletions inst/shinyapp/modules/ccle/modules-ccle-comp-o2o.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,32 @@ ui.modules_ccle_comp_o2o = function(id) {
h4(strong("S3.1 Set analysis parameters")),
selectInput(ns("comp_method"), "Comparison method:",choices = c("t-test", "wilcoxon")),
h4(strong("S3.2 Set visualization parameters")),
column(3, colourpicker::colourInput(inputId = ns("group_1_color"), "Color (Group 1):", "#E69F00")),
column(3, colourpicker::colourInput(inputId = ns("group_2_color"), "Color (Group 2):", "#56B4E9")),
column(3, numericInput(inputId = ns("point_size"), label = "Point size:", value = 3, step = 0.5)),
column(3, numericInput(inputId = ns("point_alpha"), label = "Point alpha:", value = 0.4, step = 0.1, min = 0, max = 1)),

fluidRow(
column(3, colourpicker::colourInput(inputId = ns("group_1_color"), "Color (Group 1):", "#E69F00")),
column(3, colourpicker::colourInput(inputId = ns("group_2_color"), "Color (Group 2):", "#56B4E9")),
),
dropMenu(
actionButton(ns("more_visu"), "Set more visualization params"),
div(h3("1. Adjust points:"),style="width:400px;"),
fluidRow(
column(3, numericInput(inputId = ns("point_size"), label = "Point size:", value = 3, step = 0.5)),
column(3, numericInput(inputId = ns("point_alpha"), label = "Point alpha:", value = 0.4, step = 0.1, min = 0, max = 1)),
),
div(h3("2. Adjust text size:"),style="width:400px;"),
fluidRow(
column(4, numericInput(inputId = ns("axis_size"), label = "Text size:", value = 18, step = 0.5)),
column(4, numericInput(inputId = ns("title_size"), label = "Title size:", value = 20, step = 0.5))
),
div(h3("3. Adjust lab and title name:"),style="width:400px;"),
fluidRow(
column(4, textInput(inputId = ns("x_name"), label = "X-axis name:")),
column(4, textInput(inputId = ns("y_name"), label = "Y-axis name:")),
column(4, textInput(inputId = ns("title_name"), label = "Title name:"))
),
div(h5("Note: You can download the raw data and plot in local R environment for more detailed adjustment.")),

),
br(),
# verbatimTextOutput(ns("tmp123")),
shinyWidgets::actionBttn(
ns("step3_plot_box"), "Run",
Expand Down Expand Up @@ -230,6 +251,11 @@ server.modules_ccle_comp_o2o = function(input, output, session) {
cancer_choose$single_cancer_ok = min(table(merge_data_box()$group))>=3
})

observe({
updateTextInput(session, "x_name", value = "group")
updateTextInput(session, "y_name", value = unique(y_axis_data()$id))
updateTextInput(session, "title_name", value = "CCLE")
})

comp_plot_box = eventReactive(input$step3_plot_box, {
shiny::validate(
Expand All @@ -247,9 +273,9 @@ server.modules_ccle_comp_o2o = function(input, output, session) {
data = merge_data_box,
x = "group",
y = "value",
xlab = cancer_choose$group,
ylab = unique(merge_data_box$id),
title = unique(merge_data_box$cancer),
xlab = isolate(input$x_name),
ylab = isolate(input$y_name),
title = isolate(input$title_name),
bf.message = FALSE,
type = comp_method,
centrality.plotting = FALSE,
Expand All @@ -258,8 +284,8 @@ server.modules_ccle_comp_o2o = function(input, output, session) {
position = ggplot2::position_jitterdodge(dodge.width = 0.6), stroke = 0, na.rm = TRUE)
) +
ggplot2::scale_color_manual(values = c(isolate(input$group_1_color), isolate(input$group_2_color))) +
theme(text = element_text(size=18),
plot.title = element_text(size=20, hjust = 0.5),
theme(text = element_text(size=isolate(input$axis_size)),
plot.title = element_text(size=isolate(input$title_size), hjust = 0.5),
plot.subtitle = element_text(size = 12))
return(p)
}
Expand Down
40 changes: 32 additions & 8 deletions inst/shinyapp/modules/ccle/modules-ccle-cor-o2o.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,27 @@ ui.modules_ccle_cor_o2o = function(id) {
column(3, colourpicker::colourInput(inputId = ns("x_hist_color"), "Hist color(x):", "#009E73")),
column(3, colourpicker::colourInput(inputId = ns("y_hist_color"), "Hist color(y):", "#D55E00"))
),
fluidRow(
column(3, numericInput(inputId = ns("point_size"), label = "Point size:", value = 3, step = 0.5)),
column(3, numericInput(inputId = ns("point_alpha"), label = "Point alpha:", value = 0.4, step = 0.1, min = 0, max = 1))
dropMenu(
actionButton(ns("more_visu"), "Set more visualization params"),
div(h3("1. Adjust points:"),style="width:400px;"),
fluidRow(
column(4, numericInput(inputId = ns("point_size"), label = "Point size:", value = 3, step = 0.5)),
column(3, numericInput(inputId = ns("point_alpha"), label = "Point alpha:", value = 0.4, step = 0.1, min = 0, max = 1))
),
div(h3("2. Adjust text size:"),style="width:400px;"),
fluidRow(
column(4, numericInput(inputId = ns("axis_size"), label = "Text size:", value = 18, step = 0.5)),
column(4, numericInput(inputId = ns("title_size"), label = "Title size:", value = 20, step = 0.5))
),
div(h3("3. Adjust lab and title name:"),style="width:400px;"),
fluidRow(
column(4, textInput(inputId = ns("x_name"), label = "X-axis name:")),
column(4, textInput(inputId = ns("y_name"), label = "Y-axis name:")),
column(4, textInput(inputId = ns("title_name"), label = "Title name:"))
),
div(h5("Note: You can download the raw data and plot in local R environment for more detailed adjustment.")),
),
br(),
shinyWidgets::actionBttn(
ns("step3_plot_sct"), "Run",
style = "gradient",
Expand Down Expand Up @@ -226,6 +243,13 @@ server.modules_ccle_cor_o2o = function(input, output, session) {
data
})


observe({
updateTextInput(session, "x_name", value = unique(x_axis_data()$id))
updateTextInput(session, "y_name", value = unique(y_axis_data()$id))
updateTextInput(session, "title_name", value = "CCLE")
})

cor_plot_sct = eventReactive(input$step3_plot_sct, {
shiny::validate(
need(try(nrow(merge_data_sct())>0),
Expand All @@ -240,18 +264,18 @@ server.modules_ccle_cor_o2o = function(input, output, session) {
merge_data_sct,
x = "x_value",
y = "y_value",
xlab = unique(merge_data_sct$x_id),
ylab = unique(merge_data_sct$y_id),
# title = unique(merge_data_sct$cancer),
xlab = isolate(input$x_name),
ylab = isolate(input$y_name),
title = isolate(input$title_name),
type = cor_method,
point.args = list(size = isolate(input$point_size), alpha = isolate(input$point_alpha)),
smooth.line.args = list(color = isolate(input$line_color),linewidth = 1.5,method = "lm",formula = y ~ x),
xsidehistogram.args = list(fill = isolate(input$x_hist_color), color = "black", na.rm = TRUE),
ysidehistogram.args = list(fill = isolate(input$y_hist_color), color = "black", na.rm = TRUE),
bf.message = FALSE
) +
theme(text = element_text(size=18),
plot.title = element_text(size=20, hjust = 0.5))
theme(text = element_text(size=isolate(input$axis_size)),
plot.title = element_text(size=isolate(input$title_size), hjust = 0.5))
return(p)
})
output$cor_plot_sct = renderPlot({cor_plot_sct()})
Expand Down
60 changes: 39 additions & 21 deletions inst/shinyapp/modules/pcawg/modules-pcawg-comp-o2m.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,32 @@ ui.modules_pcawg_comp_o2m = function(id) {
h4(strong("S3.1 Set analysis parameters")),
selectInput(ns("comp_method"), "Comparison method:",choices = c("t-test", "wilcoxon")),
h4(strong("S3.2 Set visualization parameters")),
column(3, colourpicker::colourInput(inputId = ns("group_1_color_2"), "Color (Group 1):", "#E69F00")),
column(3, colourpicker::colourInput(inputId = ns("group_2_color_2"), "Color (Group 2):", "#56B4E9")),
column(6, radioButtons(inputId = ns("significance"), label = "Significance:",
choices = c("Value", "Symbol"), selected="Symbol",inline = TRUE)),

fluidRow(
column(3, colourpicker::colourInput(inputId = ns("group_1_color_2"), "Color (Group 1):", "#E69F00")),
column(3, colourpicker::colourInput(inputId = ns("group_2_color_2"), "Color (Group 2):", "#56B4E9")),
),
dropMenu(
actionButton(ns("more_visu"), "Set more visualization params"),
div(h3("1. Significance display:"),style="width:400px;"),
fluidRow(
column(6, radioButtons(inputId = ns("significance"), label = "Significance:",
choices = c("Value", "Symbol"), selected="Symbol",inline = TRUE)),
),
div(h3("2. Adjust text size:"),style="width:400px;"),
fluidRow(
column(4, numericInput(inputId = ns("axis_size"), label = "Text size:", value = 18, step = 0.5)),
column(4, numericInput(inputId = ns("title_size"), label = "Title size:", value = 20, step = 0.5)),
column(4, numericInput(inputId = ns("label_size"), label = "Label size:", value = 5, step = 0.5)),
),
div(h3("3. Adjust lab and title name:"),style="width:400px;"),
fluidRow(
column(4, textInput(inputId = ns("x_name"), label = "X-axis name:")),
column(4, textInput(inputId = ns("title_name"), label = "Title name:",
value = NULL))
),
div(h5("Note: You can download the raw data and plot in local R environment for more detailed adjustment.")),
),
br(),
shinyWidgets::actionBttn(
ns("step3_plot_line"), "Run",
style = "gradient",
Expand Down Expand Up @@ -272,16 +293,6 @@ server.modules_pcawg_comp_o2m = function(input, output, session) {
comp_method = switch(isolate(input$comp_method),
`t-test` = "parametric", wilcoxon = "nonparametric")
valid_cancer_choose = sort(cancer_choose$multi_cancer_ok)
# stat_comp = lapply(sort(valid_cancer_choose), function(tcga_type){
# p = ggbetweenstats(
# subset(merge_data_line, cancer==tcga_type),
# x = "group",
# y = "value",
# type = comp_method)
# extract_stats(p)$subtitle_data
# }) %>% do.call(rbind, .) %>%
# dplyr::select(!expression) %>%
# dplyr::mutate(cancer = sort(valid_cancer_choose), .before=1)
withProgress(message = "Please wait for a while.",{
stat_comp = lapply(seq(valid_cancer_choose), function(i){
tcga_type = valid_cancer_choose[i]
Expand All @@ -299,7 +310,11 @@ server.modules_pcawg_comp_o2m = function(input, output, session) {
})
})


observe({
updateTextInput(session, "x_name", value = unique(y_axis_data()$id))
# updateTextInput(session, "y_name", value = unique(y_axis_data()$id))
updateTextInput(session, "title_name", value = "")
})
comp_plot_line = eventReactive(input$step3_plot_line, {
shiny::validate(
need(try(nrow(merge_data_line())>0),
Expand All @@ -311,18 +326,21 @@ server.modules_pcawg_comp_o2m = function(input, output, session) {
p1 = ggplot(merge_data_line_sub) +
stat_summary(aes(x=cancer, y=value, color=group),
position=position_dodge(width=0.5)) +
xlab("") + ylab("TP53") +
xlab("") + ylab(isolate(input$x_name)) + #转置
ggtitle(label = isolate(input$title_name)) +
ggplot2::scale_color_manual(values = c(isolate(input$group_1_color_2), isolate(input$group_2_color_2))) +
coord_flip() +
theme_minimal() +
theme(legend.position = "top",
plot.margin = margin(0,0,0,0),
text = element_text(size=15))
text = element_text(size=isolate(input$axis_size)),
plot.title = element_text(size=isolate(input$title_size), hjust = 0.5)
)

if(isolate(input$significance)=="Value"){
p2 = comp_data_line() %>% ggplot() +
geom_text(aes(label=formatC(p.value, format = "e", digits = 2),
x=cancer,y=1),) +
x=cancer,y=1), size = isolate(input$label_size)) +
coord_flip()
} else if (isolate(input$significance)=="Symbol"){
p2 = comp_data_line() %>%
Expand All @@ -332,7 +350,7 @@ server.modules_pcawg_comp_o2m = function(input, output, session) {
p.value < 0.05 ~ "*",
TRUE ~ "ns"
)) %>% ggplot() +
geom_text(aes(label=p.label, x=cancer,y=1),) +
geom_text(aes(label=p.label, x=cancer,y=1), size = isolate(input$label_size)) +
coord_flip()
}
p2 = p2 +
Expand All @@ -346,7 +364,7 @@ server.modules_pcawg_comp_o2m = function(input, output, session) {
theme(panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank())

p = p1 + p2 + patchwork::plot_layout(widths = c(5,1))
p = p1 + p2 + patchwork::plot_layout(widths = c(5,0.3))

return(p)
})
Expand Down
Loading

0 comments on commit 3b24ee0

Please sign in to comment.