gg pairs fixup for alr

This commit is contained in:
Tanushree Tunstall 2022-08-27 17:15:31 +01:00
parent 5b89beb2b5
commit c3067b9176

View file

@ -1,6 +1,6 @@
#source("~/git/LSHTM_analysis/config/embb.R")
#source("~/git/LSHTM_analysis/scripts/plotting/plotting_colnames.R")
#source("~/git/LSHTM_analysis/config/alr.R")
#source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R")
#source("~/git/LSHTM_analysis/scripts/plotting/plotting_colnames.R")
#=======
# output
@ -8,20 +8,38 @@
outdir_images = paste0("/home/pub/Work/LSHTM/Thesis_Plots/pairs/")
#cat("plots will output to:", outdir_images)
custom_cor <- function(data, mapping, method, ...){
x <- eval_data_col(data, mapping$x)
y <- eval_data_col(data, mapping$y)
corr <- cor(x, y, method=method, use='complete.obs')
ggally_text(
label = paste0("ρ: ",as.character(round(corr, 2))),
mapping = aes(),
xP = 0.5, yP = 0.5,
color = 'black',
...
)
}
my_gg_pairs=function(plot_df, plot_title
, tt_args_size = 2.5
, gp_args_size = 2.5){
ggpairs(plot_df,
columns = 1:(ncol(plot_df)-1),
upper = list(
continuous = wrap('cor', # ggally_cor()
method = "spearman",
use = "pairwise.complete.obs",
title="ρ",
digits=2,
justify_labels = "centre",
title_args=list(size=tt_args_size, colour="black")#,#2.5
#group_args=list(size=gp_args_size)#2.5
continuous = wrap(custom_cor, method="spearman"
# ggally_cor, # ggally_cor()
# method = "spearman",
# use = "pairwise.complete.obs",
# title="XXX ρ",
# digits=2,
# justify_labels = "centre",
# title_args=list(size=tt_args_size, colour="black")#,#2.5
# #group_args=list(size=gp_args_size)#2.5
)
),
lower = list(
@ -40,11 +58,11 @@ my_gg_pairs=function(plot_df, plot_title
# "R") ),
# alpha = 0.5),
title=plot_title) #+
#
# scale_colour_manual(values = c("red", "blue")) +
# scale_fill_manual(values = c("red", "blue")) #+
# theme(text = element_text(size=7,
# face="bold"))
#
# scale_colour_manual(values = c("red", "blue")) +
# scale_fill_manual(values = c("red", "blue")) #+
# theme(text = element_text(size=7,
# face="bold"))
}
DistCutOff = 10