Prevent interactive variable collision
This commit is contained in:
@@ -357,23 +357,6 @@ calculate_interaction_scores <- function(df, max_conc, variables, group_vars = c
|
||||
calculations_joined <- df %>% select(-any_of(setdiff(names(calculations), c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))))
|
||||
calculations_joined <- left_join(calculations_joined, calculations, by = c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))
|
||||
|
||||
|
||||
|
||||
# # TODO for debug
|
||||
# df_duplicates <- df %>%
|
||||
# group_by(OrfRep, Gene, num) %>%
|
||||
# filter(n() > 1)
|
||||
|
||||
# interactions_duplicates <- interactions %>%
|
||||
# group_by(OrfRep, Gene, num) %>%
|
||||
# filter(n() > 1)
|
||||
|
||||
# print(df_duplicates)
|
||||
# print(interactions_duplicates)
|
||||
|
||||
|
||||
|
||||
|
||||
interactions_joined <- df %>% select(-any_of(setdiff(names(interactions), c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))))
|
||||
interactions_joined <- left_join(interactions_joined, interactions, by = c("OrfRep", "Gene", "num", "conc_num", "conc_num_factor"))
|
||||
|
||||
@@ -411,10 +394,10 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
|
||||
plot_base <- ggplot(df, aes_mapping)
|
||||
|
||||
# Function to generate the plot
|
||||
generate_plot <- function(interactive) {
|
||||
generate_plot <- function(is_interactive) {
|
||||
# Use appropriate helper function based on plot type
|
||||
plot <- switch(config$plot_type,
|
||||
"scatter" = generate_scatter_plot(plot_base, config, interactive = interactive),
|
||||
"scatter" = generate_scatter_plot(plot_base, config, is_interactive = is_interactive),
|
||||
"box" = generate_box_plot(plot_base, config),
|
||||
"density" = plot_base + geom_density(),
|
||||
"bar" = plot_base + geom_bar(),
|
||||
@@ -442,10 +425,10 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
|
||||
}
|
||||
|
||||
# Generate the static plot
|
||||
static_plot <- generate_plot(interactive = FALSE)
|
||||
static_plot <- generate_plot(is_interactive = FALSE)
|
||||
|
||||
# Generate the interactive plot
|
||||
interactive_plot <- generate_plot(interactive = TRUE)
|
||||
interactive_plot <- generate_plot(is_interactive = TRUE)
|
||||
|
||||
# Convert to plotly object
|
||||
plotly_plot <- ggplotly(interactive_plot, tooltip = "text")
|
||||
@@ -468,8 +451,7 @@ generate_and_save_plots <- function(output_dir, file_name, plot_configs, grid_la
|
||||
saveWidget(combined_plot, file = file.path(output_dir, paste0(file_name, ".html")), selfcontained = TRUE)
|
||||
}
|
||||
|
||||
|
||||
generate_scatter_plot <- function(plot, config, interactive = FALSE) {
|
||||
generate_scatter_plot <- function(plot, config, is_interactive = FALSE) {
|
||||
# Check for missing or out-of-range data
|
||||
missing_data <- config$df %>%
|
||||
filter(
|
||||
@@ -497,8 +479,8 @@ generate_scatter_plot <- function(plot, config, interactive = FALSE) {
|
||||
)
|
||||
}
|
||||
|
||||
# Add the interactive `text` aesthetic if `interactive` is TRUE
|
||||
if (interactive) {
|
||||
# Add the interactive `text` aesthetic if `is_interactive` is TRUE
|
||||
if (is_interactive) {
|
||||
if (!is.null(config$delta_bg_point) && config$delta_bg_point) {
|
||||
plot <- plot + geom_point(
|
||||
aes(text = paste("ORF:", OrfRep, "Gene:", Gene, "delta_bg:", delta_bg)),
|
||||
|
||||
Reference in New Issue
Block a user