From f11597dbfd4fd899b8241d6b215b188a08796072 Mon Sep 17 00:00:00 2001 From: ShixiangWang Date: Thu, 18 Jul 2024 17:20:33 +0800 Subject: [PATCH] Removed a mistake by Yi Xiong for setting problematic threshold parameter in unicox analysis --- DESCRIPTION | 2 +- NEWS.md | 3 ++- R/vis_pancan_value.R | 25 +++++-------------- R/vis_pcawg_value.R | 18 +------------ .../modules/02_quick/modules-1-tcga-10-Cox.R | 1 - .../modules/02_quick/modules-2-pcawg-04-Cox.R | 1 - man/vis_pancan_anatomy.Rd | 16 ++++++------ man/vis_pcawg_unicox_tree.Rd | 3 --- man/vis_unicox_tree.Rd | 3 --- vignettes/api.Rmd | 1 - 10 files changed, 18 insertions(+), 55 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0fbeb9c3..d3053a05 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -72,4 +72,4 @@ VignetteBuilder: Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 diff --git a/NEWS.md b/NEWS.md index a709811a..461a49b0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/vis_pancan_value.R b/R/vis_pancan_value.R index 98c25c07..5ebe89a4 100644 --- a/R/vis_pancan_value.R +++ b/R/vis_pancan_value.R @@ -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 @@ -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") @@ -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 %>% @@ -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) %>% diff --git a/R/vis_pcawg_value.R b/R/vis_pcawg_value.R index f7c4fe04..077b4e80 100644 --- a/R/vis_pcawg_value.R +++ b/R/vis_pcawg_value.R @@ -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 @@ -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) @@ -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, diff --git a/inst/shinyapp/modules/02_quick/modules-1-tcga-10-Cox.R b/inst/shinyapp/modules/02_quick/modules-1-tcga-10-Cox.R index 5b6e6476..c8ba1ce5 100644 --- a/inst/shinyapp/modules/02_quick/modules-1-tcga-10-Cox.R +++ b/inst/shinyapp/modules/02_quick/modules-1-tcga-10-Cox.R @@ -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) ) diff --git a/inst/shinyapp/modules/02_quick/modules-2-pcawg-04-Cox.R b/inst/shinyapp/modules/02_quick/modules-2-pcawg-04-Cox.R index 32c45b87..2d6333f9 100644 --- a/inst/shinyapp/modules/02_quick/modules-2-pcawg-04-Cox.R +++ b/inst/shinyapp/modules/02_quick/modules-2-pcawg-04-Cox.R @@ -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) ) diff --git a/man/vis_pancan_anatomy.Rd b/man/vis_pancan_anatomy.Rd index 8c4308bd..4b5c3a49 100644 --- a/man/vis_pancan_anatomy.Rd +++ b/man/vis_pancan_anatomy.Rd @@ -23,14 +23,14 @@ genomic signature (\code{"TP53 + 2 * KRAS - 1.3 * PTEN"}).} \item{option}{A character string indicating the color map option to use. Eight options are available: \itemize{ -\item \code{"magma"} (or \code{"A"}) -\item \code{"inferno"} (or \code{"B"}) -\item \code{"plasma"} (or \code{"C"}) -\item \code{"viridis"} (or \code{"D"}) -\item \code{"cividis"} (or \code{"E"}) -\item \code{"rocket"} (or \code{"F"}) -\item \code{"mako"} (or \code{"G"}) -\item \code{"turbo"} (or \code{"H"}) + \item "magma" (or "A") + \item "inferno" (or "B") + \item "plasma" (or "C") + \item "viridis" (or "D") + \item "cividis" (or "E") + \item "rocket" (or "F") + \item "mako" (or "G") + \item "turbo" (or "H") }} \item{opt_pancan}{specify one dataset for some molercular profiles} diff --git a/man/vis_pcawg_unicox_tree.Rd b/man/vis_pcawg_unicox_tree.Rd index dd7238b1..e59936d3 100644 --- a/man/vis_pcawg_unicox_tree.Rd +++ b/man/vis_pcawg_unicox_tree.Rd @@ -8,7 +8,6 @@ vis_pcawg_unicox_tree( Gene = "TP53", measure = "OS", data_type = "mRNA", - threshold = 0.5, values = c("grey", "#E31A1C", "#377DB8"), opt_pancan = .opt_pancan ) @@ -21,8 +20,6 @@ genomic signature (\code{"TP53 + 2 * KRAS - 1.3 * PTEN"}).} \item{data_type}{choose gene profile type, including "mRNA","transcript","methylation","miRNA","protein","cnv"} -\item{threshold}{a expression cutoff, \code{0.5} for median.} - \item{values}{the color to fill tumor or normal} \item{opt_pancan}{specify one dataset for some molercular profiles} diff --git a/man/vis_unicox_tree.Rd b/man/vis_unicox_tree.Rd index d1563fc1..34705704 100644 --- a/man/vis_unicox_tree.Rd +++ b/man/vis_unicox_tree.Rd @@ -8,7 +8,6 @@ vis_unicox_tree( Gene = "TP53", measure = "OS", data_type = "mRNA", - threshold = 0.5, values = c("grey", "#E31A1C", "#377DB8"), opt_pancan = .opt_pancan ) @@ -21,8 +20,6 @@ genomic signature (\code{"TP53 + 2 * KRAS - 1.3 * PTEN"}).} \item{data_type}{choose gene profile type, including "mRNA","transcript","methylation","miRNA","protein","cnv"} -\item{threshold}{a expression cutoff, \code{0.5} for median.} - \item{values}{the color to fill tumor or normal} \item{opt_pancan}{specify one dataset for some molercular profiles} diff --git a/vignettes/api.Rmd b/vignettes/api.Rmd index ad8887c5..af2753ee 100644 --- a/vignettes/api.Rmd +++ b/vignettes/api.Rmd @@ -121,7 +121,6 @@ if (require("gganatogram")) { vis_unicox_tree( Gene = "TP53", measure = "OS", - threshold = 0.5, values = c("grey", "#E31A1C", "#377DB8") ) ```