--- title: "Correlation Plots" output: rmarkdown::html_vignette: toc: true description: Visualize correlations between data prior to clustering. vignette: > %\VignetteIndexEntry{Correlation Plots} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ``` Download a copy of the vignette to follow along here: [correlation_plots.Rmd](https://raw.githubusercontent.com/BRANCHlab/metasnf/main/vignettes/correlation_plots.Rmd) In this vignette, we go through how you can visualize associations between the features included in your analyses. ## Data set-up ```{r} library(metasnf) # We'll just use the first few columns for this demo cort_sa_minimal <- cort_sa[, 1:5] # And one more mock categorical feature for demonstration purposes city <- fav_colour city$"city" <- sample( c("toronto", "montreal", "vancouver"), size = nrow(city), replace = TRUE ) city <- city |> dplyr::select(-"colour") # Make sure to throw in all the data you're interested in visualizing for this # data_list, including out-of-model measures and confounding features. data_list <- generate_data_list( list(cort_sa_minimal, "cortical_sa", "neuroimaging", "continuous"), list(income, "household_income", "demographics", "ordinal"), list(pubertal, "pubertal_status", "demographics", "continuous"), list(fav_colour, "favourite_colour", "demographics", "categorical"), list(city, "city", "demographics", "categorical"), list(anxiety, "anxiety", "behaviour", "ordinal"), list(depress, "depressed", "behaviour", "ordinal"), uid = "unique_id" ) summarize_dl(data_list) # This matrix contains all the pairwise association p-values assoc_pval_matrix <- calc_assoc_pval_matrix(data_list) assoc_pval_matrix[1:3, 1:3] ``` ## Heatmaps Here's what a basic heatmap looks like: ```{r eval = FALSE} ap_heatmap <- assoc_pval_heatmap( assoc_pval_matrix ) save_heatmap( ap_heatmap, "assoc_pval_heatmap.png", width = 650, height = 500, res = 100 ) ```