From 462d6070bd36a1717a8974bf92b92798d41a4114 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Tue, 1 Oct 2024 18:54:19 -0400 Subject: [PATCH] Fix discrete x_var mapping --- qhtcp-workflow/apps/r/calculate_interaction_zscores.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/qhtcp-workflow/apps/r/calculate_interaction_zscores.R b/qhtcp-workflow/apps/r/calculate_interaction_zscores.R index 6ee1a9da..ee6a70af 100644 --- a/qhtcp-workflow/apps/r/calculate_interaction_zscores.R +++ b/qhtcp-workflow/apps/r/calculate_interaction_zscores.R @@ -608,7 +608,8 @@ generate_scatter_plot <- function(plot, config) { # Customize X-axis if specified if (!is.null(config$x_breaks) && !is.null(config$x_labels) && !is.null(config$x_label)) { - if (is.factor(df[[config$x_var]]) || is.character(df[[config$x_var]])) { + # Check if x_var is factor or character (for discrete x-axis) + if (is.factor(plot$data[[config$x_var]]) || is.character(plot$data[[config$x_var]])) { plot <- plot + scale_x_discrete( name = config$x_label, @@ -624,6 +625,7 @@ generate_scatter_plot <- function(plot, config) { ) } } + # Set Y-axis limits if specified if (!is.null(config$ylim_vals)) { @@ -656,7 +658,8 @@ generate_boxplot <- function(plot, config) { # Customize X-axis if specified if (!is.null(config$x_breaks) && !is.null(config$x_labels) && !is.null(config$x_label)) { - if (is.factor(df[[config$x_var]]) || is.character(df[[config$x_var]])) { + # Check if x_var is factor or character (for discrete x-axis) + if (is.factor(plot$data[[config$x_var]]) || is.character(plot$data[[config$x_var]])) { plot <- plot + scale_x_discrete( name = config$x_label,