From ea922f2d9920a18f762dd42184bf02d10e73228f Mon Sep 17 00:00:00 2001 From: Travis Blimkie Date: Thu, 25 Apr 2024 14:03:33 -0700 Subject: [PATCH] Changes to size scaling method for dot and split dot plots. --- DESCRIPTION | 2 +- R/2_upload.R | 2 +- R/3_results.R | 34 ++++++++++++++++++---------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 92c0151..2a14ae7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ABCindex Title: A Shiny app to calculate ABCI for checkerboard assays -Version: 0.99.80 +Version: 0.99.801 Authors@R: person(given = "Travis", family = "Blimkie", diff --git a/R/2_upload.R b/R/2_upload.R index a9304ff..892dff9 100644 --- a/R/2_upload.R +++ b/R/2_upload.R @@ -133,7 +133,7 @@ abci_analysis_single <- function( ) if (!normalize) { - if (max(data_clean[[col.data]]) >= 50) { + if (max(data_clean[[col.data]]) - min(data_clean[[col.data]]) > 10) { data_clean[[col.data]] <- data_clean[[col.data]] / 100 } } diff --git a/R/3_results.R b/R/3_results.R index dbe70ea..54df3a8 100644 --- a/R/3_results.R +++ b/R/3_results.R @@ -544,12 +544,14 @@ plot_dot <- function( # Fix up the variable being mapped to size. Define labels and breaks. data <- data %>% - group_by(.data[[col.analysis]]) %>% mutate( across(all_of(c(x.drug, y.drug)), forcats::fct_inseq), - reference = ceiling(scales::rescale(.data[[col.size]], to = c(0, 100))) + reference = ifelse( + test = ceiling(.data[[col.size]] * 100) <= 100, + yes = ceiling(.data[[col.size]] * 100), + no = 100 + ) ) %>% - ungroup() %>% left_join(size_mapping, by = "reference") proper_labels <- seq(0, 100, 20) @@ -830,12 +832,14 @@ plot_dot_split <- function( # Fix up the variable being mapped to size. Define labels and breaks. data <- data %>% - group_by(.data[[col.analysis]]) %>% mutate( across(all_of(c(x.drug, y.drug)), forcats::fct_inseq), - reference = ceiling(scales::rescale(.data[[col.size]], to = c(0, 100))) + reference = ifelse( + test = ceiling(.data[[col.size]] * 100) <= 100, + yes = ceiling(.data[[col.size]] * 100), + no = 100 + ) ) %>% - ungroup() %>% left_join(size_mapping, by = "reference") proper_labels <- seq(0, 100, 20) @@ -849,13 +853,11 @@ plot_dot_split <- function( if (!large.effect) { data <- mutate(data, large_chr = rep(0)) } else { - data <- data %>% - mutate( - large_chr = ifelse( - (effect_avg > large.effect.val & data[[col.fill]] > abci.val), - yes = 1, - no = 0) - ) + data <- mutate(data, large_chr = ifelse( + test = (effect_avg > large.effect.val & data[[col.fill]] > abci.val), + yes = 1, + no = 0 + )) } # MICs are calculated by `get_mic()` and converted to positions on the axes @@ -976,9 +978,9 @@ plot_dot_split <- function( x, col_size = scales::rescale(N1S2, to = size.range), col_size = ifelse( - !is.na(col_fill), - col_size, - 0 + test = !is.na(col_fill), + yes = col_size, + no = 0 ) ) })