Skip to content

rewrite scatterplotmatrix so it uses ggally#985

Closed
m7pr wants to merge 4 commits into
mainfrom
ggally
Closed

rewrite scatterplotmatrix so it uses ggally#985
m7pr wants to merge 4 commits into
mainfrom
ggally

Conversation

@m7pr

@m7pr m7pr commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Part of

Satisfies last comment from 2025

Alternative to

This PR rewrite scatterplotmatrix so it uses ggally

Coe do generate plots
library(ggplot2)
library(GGally)
library(dplyr)

set.seed(42)
n <- 200
demo_data <- data.frame(
  AGE = rnorm(n, mean = 55, sd = 12),
  BMRKR1 = rlnorm(n, meanlog = 1.5, sdlog = 0.8),
  AVAL = rnorm(n, mean = 100, sd = 25),
  BMRKR2 = sample(c("LOW", "MEDIUM", "HIGH"), n, replace = TRUE, prob = c(0.3, 0.4, 0.3))
) %>%
  mutate(BMRKR2 = factor(BMRKR2, levels = c("LOW", "MEDIUM", "HIGH")))

demo_data$AGE[sample(n, 10)] <- NA
demo_data$BMRKR1[sample(n, 5)] <- NA

plot_with_cor <- GGally::ggpairs(
  demo_data,
  columnLabels = c("Age", "Biomarker 1", "Analysis Value", "Biomarker 2"),
  upper = list(
    continuous = GGally::wrap("cor", method = "pearson", use = "pairwise.complete.obs")
  ),
  lower = list(
    continuous = GGally::wrap("points", alpha = 0.5, size = 1.5)
  ),
  diag = list(
    continuous = GGally::wrap("densityDiag", alpha = 0.5)
  )
) +
  ggplot2::ggtitle("Scatterplot Matrix - With Correlation (Pearson)") +
  ggplot2::theme(plot.title = element_text(hjust = 0.5, face = "bold", size = 14))

plot_without_cor <- GGally::ggpairs(
  demo_data,
  columnLabels = c("Age", "Biomarker 1", "Analysis Value", "Biomarker 2"),
  upper = list(
    continuous = GGally::wrap("points", alpha = 0.5, size = 1.5)
  ),
  lower = list(
    continuous = GGally::wrap("points", alpha = 0.5, size = 1.5)
  ),
  diag = list(
    continuous = GGally::wrap("densityDiag", alpha = 0.5)
  )
) +
  ggplot2::ggtitle("Scatterplot Matrix - Without Correlation") +
  ggplot2::theme(plot.title = element_text(hjust = 0.5, face = "bold", size = 14))

plot_spearman <- GGally::ggpairs(
  demo_data,
  columnLabels = c("Age", "Biomarker 1", "Analysis Value", "Biomarker 2"),
  upper = list(
    continuous = GGally::wrap("cor", method = "spearman", use = "pairwise.complete.obs")
  ),
  lower = list(
    continuous = GGally::wrap("points", alpha = 0.5, size = 1.5)
  ),
  diag = list(
    continuous = GGally::wrap("densityDiag", alpha = 0.5)
  )
) +
  ggplot2::ggtitle("Scatterplot Matrix - With Correlation (Spearman)") +
  ggplot2::theme(plot.title = element_text(hjust = 0.5, face = "bold", size = 14))

numeric_data <- demo_data %>% select(AGE, BMRKR1, AVAL)

plot_numeric_only <- GGally::ggpairs(
  numeric_data,
  columnLabels = c("Age", "Biomarker 1", "Analysis Value"),
  upper = list(
    continuous = GGally::wrap("cor", method = "pearson", use = "pairwise.complete.obs")
  ),
  lower = list(
    continuous = GGally::wrap("points", alpha = 0.5, size = 1.5)
  ),
  diag = list(
    continuous = GGally::wrap("densityDiag", alpha = 0.5)
  )
) +
  ggplot2::ggtitle("Numeric Only - Correlation Matrix Style") +
  ggplot2::theme(plot.title = element_text(hjust = 0.5, face = "bold", size = 14))

output_dir <- file.path("dev", "demo_plots")
dir.create(output_dir, showWarnings = FALSE, recursive = TRUE)

ggsave(file.path(output_dir, "1_with_correlation_pearson.png"), plot_with_cor, width = 10, height = 10, dpi = 150)
ggsave(file.path(output_dir, "2_without_correlation.png"), plot_without_cor, width = 10, height = 10, dpi = 150)
ggsave(file.path(output_dir, "3_with_correlation_spearman.png"), plot_spearman, width = 10, height = 10, dpi = 150)
ggsave(file.path(output_dir, "4_numeric_only_correlation.png"), plot_numeric_only, width = 8, height = 8, dpi = 150)

Plots below

1_with_correlation_pearson 2_without_correlation 3_with_correlation_spearman 4_numeric_only_correlation

@m7pr m7pr requested a review from donyunardi February 23, 2026 13:03
@m7pr m7pr added the core label Feb 23, 2026
@github-actions

github-actions Bot commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Unit Tests Summary

    1 files     38 suites   22m 44s ⏱️
  686 tests   680 ✅ 5 💤 0 ❌ 1 🔥
1 307 runs  1 301 ✅ 5 💤 0 ❌ 1 🔥

For more details on these errors, see this check.

Results for commit 2e5ff84.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
shinytest2-tm_a_pca 💚 $220.36$ $-3.27$ $0$ $0$ $0$ $0$
shinytest2-tm_a_regression 💚 $86.24$ $-3.26$ $0$ $0$ $0$ $0$
shinytest2-tm_file_viewer 💚 $42.25$ $-1.43$ $0$ $0$ $0$ $0$
shinytest2-tm_g_bivariate 💚 $102.56$ $-38.13$ $-11$ $0$ $0$ $+1$
shinytest2-tm_g_distribution 💚 $117.29$ $-67.46$ $0$ $0$ $0$ $0$
shinytest2-tm_g_scatterplot 💚 $137.99$ $-2.34$ $0$ $0$ $0$ $0$
shinytest2-tm_g_scatterplotmatrix 💔 $44.09$ $+12.22$ $0$ $0$ $0$ $0$
shinytest2-tm_missing_data 💚 $67.03$ $-1.93$ $0$ $0$ $0$ $0$
shinytest2-tm_outliers 💚 $170.99$ $-5.07$ $0$ $0$ $0$ $0$
shinytest2-tm_t_crosstable 💚 $48.25$ $-1.20$ $0$ $0$ $0$ $0$
shinytest2-tm_variable_browser 💚 $97.43$ $-4.33$ $0$ $0$ $0$ $0$
tm_g_association 💚 $12.94$ $-1.14$ $0$ $0$ $0$ $0$
tm_g_scatterplotmatrix 💔 $1.50$ $+1.37$ $0$ $0$ $0$ $0$
tm_outliers 💚 $53.04$ $-2.45$ $0$ $0$ $0$ $0$
variable_browser 💚 $69.33$ $-3.97$ $0$ $0$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
shinytest2-tm_g_bivariate 💚 $10.66$ $-1.19$ e2e_tm_g_bivariate_Module_is_initialised_with_the_specified_defaults.
shinytest2-tm_g_bivariate 💚 $39.19$ $-35.34$ e2e_tm_g_bivariate_Setting_encoding_inputs_produces_outputs_without_validation_errors.
shinytest2-tm_g_distribution 💚 $77.64$ $-66.47$ e2e_tm_g_distribution_Module_is_initialised_with_the_specified_defaults.
shinytest2-tm_g_scatterplotmatrix 💔 $13.06$ $+6.60$ e2e_tm_g_scatterplotmatrix_Change_plot_settings
shinytest2-tm_g_scatterplotmatrix 💔 $9.04$ $+1.65$ e2e_tm_g_scatterplotmatrix_Initializes_without_errors
shinytest2-tm_g_scatterplotmatrix 💔 $10.73$ $+2.43$ e2e_tm_g_scatterplotmatrix_Verify_default_values_and_settings_data_extracts_for_data_selection
shinytest2-tm_g_scatterplotmatrix 💔 $11.26$ $+1.53$ e2e_tm_g_scatterplotmatrix_Verify_module_displays_data_table
shinytest2-tm_variable_browser 💚 $22.26$ $-1.10$ e2e_tm_variable_browser_changing_plot_setting_encodings_doesn_t_show_errors.
variable_browser 💚 $13.12$ $-1.39$ UI_switches_and_controls_server_handles_different_outlier_definition_thresholds

Results for commit 2f335b3

♻️ This comment has been updated with latest results.

@donyunardi

Copy link
Copy Markdown
Contributor

User prefer that patchwork solution. Closing without merging.

@donyunardi donyunardi closed this Mar 6, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 6, 2026
@insights-engineering-bot insights-engineering-bot deleted the ggally branch May 31, 2026 05:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants