Skip to content

Commit

Permalink
Removed a mistake by Yi Xiong for setting problematic threshold param…
Browse files Browse the repository at this point in the history
…eter in unicox analysis
  • Loading branch information
ShixiangWang committed Jul 18, 2024
1 parent 6f746ed commit f11597d
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 55 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ VignetteBuilder:
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
- Added gene and pathway cross-omics analysis functions/modules.
- Added `app_run2()` function for custom app start with lightweight modules.
- Fixed `pdf()` parameter for KM plot
- Improve the UI of Custom TPC Modules.
- Improved the UI of Custom TPC Modules.
- Removed a mistake by Yi Xiong for setting problematic threshold parameter in unicox analysis.

# UCSCXenaShiny 2.1.0

Expand Down
25 changes: 6 additions & 19 deletions R/vis_pancan_value.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ vis_toil_TvsN <- function(Gene = "TP53", Mode = c("Boxplot", "Violinplot"),
#'
#' @inheritParams vis_toil_TvsN
#' @param measure a survival measure, e.g. "OS".
#' @param threshold a expression cutoff, `0.5` for median.
#' @param data_type choose gene profile type, including "mRNA","transcript","methylation","miRNA","protein","cnv"
#' @return a `ggplot` object
#' @examples
Expand All @@ -228,7 +227,7 @@ vis_toil_TvsN <- function(Gene = "TP53", Mode = c("Boxplot", "Violinplot"),
#' }
#' @export
vis_unicox_tree <- function(Gene = "TP53", measure = "OS", data_type = "mRNA",
threshold = 0.5, values = c("grey", "#E31A1C", "#377DB8"), opt_pancan = .opt_pancan) {
values = c("grey", "#E31A1C", "#377DB8"), opt_pancan = .opt_pancan) {
tcga_surv <- load_data("tcga_surv")
tcga_gtex <- load_data("tcga_gtex")

Expand All @@ -254,23 +253,10 @@ vis_unicox_tree <- function(Gene = "TP53", measure = "OS", data_type = "mRNA",
dplyr::inner_join(tcga_gtex[, c("tissue", "sample")], by = "sample")
sss <- split(ss, ss$tissue)
tissues <- names(sss)
unicox_res_all_cancers <- purrr::map(tissues, purrr::safely(function(cancer) {
# cancer = "ACC"
.f = function(cancer) {
sss_can <- sss[[cancer]]
if (threshold == 0.5) {
sss_can <- sss_can %>%
dplyr::mutate(group = ifelse(.data$values > stats::median(.data$values), "high", "low")) %>%
dplyr::mutate(group = factor(.data$group, levels = c("low", "high")))
}

if (threshold == 0.25) {
sss_can <- sss_can %>%
dplyr::mutate(group = ifelse(.data$values > stats::quantile(.data$values)[4], "high",
ifelse(.data$values < stats::quantile(.data$values)[2], "low", "middle")
)) %>%
dplyr::filter(group != "middle") %>%
dplyr::mutate(group = factor(.data$group, levels = c("low", "high")))
}



unicox_res_genes <- ezcox::ezcox(
sss_can %>%
Expand All @@ -285,7 +271,8 @@ vis_unicox_tree <- function(Gene = "TP53", measure = "OS", data_type = "mRNA",
unicox_res_genes$cancer <- cancer
unicox_res_genes$measure <- measure
return(unicox_res_genes)
})) %>% magrittr::set_names(tissues)
}
unicox_res_all_cancers <- purrr::map(tissues, purrr::safely(.f)) %>% magrittr::set_names(tissues)

unicox_res_all_cancers <- unicox_res_all_cancers %>%
purrr::map(~ .x$result) %>%
Expand Down
18 changes: 1 addition & 17 deletions R/vis_pcawg_value.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ vis_pcawg_dist <- function(Gene = "TP53",
#'
#' @inheritParams vis_toil_TvsN
#' @param measure a survival measure, e.g. "OS".
#' @param threshold a expression cutoff, `0.5` for median.
#' @param data_type choose gene profile type, including "mRNA","transcript","methylation","miRNA","protein","cnv"
#' @return a `ggplot` object
#' @examples
Expand All @@ -224,7 +223,7 @@ vis_pcawg_dist <- function(Gene = "TP53",


vis_pcawg_unicox_tree <- function(Gene = "TP53", measure = "OS", data_type = "mRNA",
threshold = 0.5, values = c("grey", "#E31A1C", "#377DB8"), opt_pancan = .opt_pancan) {
values = c("grey", "#E31A1C", "#377DB8"), opt_pancan = .opt_pancan) {
pcawg_info <- load_data("pcawg_info")

# t1 <- query_pcawg_pancan_value(Gene, data_type)
Expand Down Expand Up @@ -252,21 +251,6 @@ vis_pcawg_unicox_tree <- function(Gene = "TP53", measure = "OS", data_type = "mR
tissues <- names(sss)
unicox_res_all_cancers <- purrr::map(tissues, purrr::safely(function(cancer) {
sss_can <- sss[[cancer]]
if (threshold == 0.5) {
sss_can <- sss_can %>%
dplyr::mutate(group = ifelse(.data$values > stats::median(.data$values), "high", "low")) %>%
dplyr::mutate(group = factor(.data$group, levels = c("low", "high")))
}

if (threshold == 0.25) {
sss_can <- sss_can %>%
dplyr::mutate(group = ifelse(.data$values > stats::quantile(.data$values)[4], "high",
ifelse(.data$values < stats::quantile(.data$values)[2], "low", "middle")
)) %>%
dplyr::filter(group != "middle") %>%
dplyr::mutate(group = factor(.data$group, levels = c("low", "high")))
}


unicox_res_genes <- ezcox::ezcox(
sss_can,
Expand Down
1 change: 0 additions & 1 deletion inst/shinyapp/modules/02_quick/modules-1-tcga-10-Cox.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ server.modules_1_tcga_10 = function(input, output, session){
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)
)
Expand Down
1 change: 0 additions & 1 deletion inst/shinyapp/modules/02_quick/modules-2-pcawg-04-Cox.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ server.modules_2_pcawg_04 = function(input, output, session){
p <- vis_pcawg_unicox_tree(
Gene = mol_info$molecule(),
measure = "OS",
threshold = 0.5,
data_type = mol_info$profile(),
values = c(input$first_col, input$second_col, input$third_col)
)
Expand Down
16 changes: 8 additions & 8 deletions man/vis_pancan_anatomy.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions man/vis_pcawg_unicox_tree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions man/vis_unicox_tree.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion vignettes/api.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ if (require("gganatogram")) {
vis_unicox_tree(
Gene = "TP53",
measure = "OS",
threshold = 0.5,
values = c("grey", "#E31A1C", "#377DB8")
)
```
Expand Down

0 comments on commit f11597d

Please sign in to comment.