updated corr_PS_LIG.R to output both styles of corr plots
This commit is contained in:
parent
ea5d5bda44
commit
883207bc4b
1 changed files with 105 additions and 38 deletions
|
@ -59,10 +59,16 @@ cat(paste0("Variables imported:"
|
||||||
corr_ps = "corr_PS.svg"
|
corr_ps = "corr_PS.svg"
|
||||||
plot_corr_ps = paste0(plotdir,"/", corr_ps)
|
plot_corr_ps = paste0(plotdir,"/", corr_ps)
|
||||||
|
|
||||||
|
corr_upper_ps = "corr_upper_PS.svg"
|
||||||
|
plot_corr_upper_ps = paste0(plotdir,"/", corr_upper_ps)
|
||||||
|
|
||||||
# LIG
|
# LIG
|
||||||
corr_lig = "corr_LIG.svg"
|
corr_lig = "corr_LIG.svg"
|
||||||
plot_corr_lig = paste0(plotdir,"/", corr_lig)
|
plot_corr_lig = paste0(plotdir,"/", corr_lig)
|
||||||
|
|
||||||
|
corr_upper_lig = "corr_upper_LIG.svg"
|
||||||
|
plot_corr_upper_lig = paste0(plotdir,"/", corr_upper_lig)
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# end of loading libraries and functions #
|
# end of loading libraries and functions #
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -159,8 +165,8 @@ my_corr_colnames = c("DUET"
|
||||||
|
|
||||||
, "Foldx"
|
, "Foldx"
|
||||||
|
|
||||||
, "Log(OR)"
|
, "Log (OR)"
|
||||||
, "-Log(P)"
|
, "-Log (P)"
|
||||||
|
|
||||||
, "AF"
|
, "AF"
|
||||||
|
|
||||||
|
@ -173,9 +179,6 @@ colnames(corr_data_ps)
|
||||||
colnames(corr_data_ps) <- my_corr_colnames
|
colnames(corr_data_ps) <- my_corr_colnames
|
||||||
colnames(corr_data_ps)
|
colnames(corr_data_ps)
|
||||||
|
|
||||||
#-----------------
|
|
||||||
# generate corr PS plot
|
|
||||||
#-----------------
|
|
||||||
start = 1
|
start = 1
|
||||||
end = which(colnames(corr_data_ps) == drug); end # should be the last column
|
end = which(colnames(corr_data_ps) == drug); end # should be the last column
|
||||||
offset = 1
|
offset = 1
|
||||||
|
@ -187,11 +190,14 @@ head(my_corr_ps)
|
||||||
# deep blue :#007d85
|
# deep blue :#007d85
|
||||||
# deep red: #ae301e
|
# deep red: #ae301e
|
||||||
|
|
||||||
|
#---------------------------------------
|
||||||
|
# generate corr PS plot 1: both panels
|
||||||
|
#---------------------------------------
|
||||||
|
|
||||||
cat("Corr plot PS:", plot_corr_ps)
|
cat("Corr plot PS:", plot_corr_ps)
|
||||||
svg(plot_corr_ps, width = 15, height = 15)
|
svg(plot_corr_ps, width = 15, height = 15)
|
||||||
|
|
||||||
#OutPlot1 = pairs.panels([1:(length(my_corr_ps)-1)]
|
OutPlot1 = pairs.panels(my_corr_ps[1:(length(my_corr_ps)-1)]
|
||||||
OutPlot1 = my_pp(my_corr_ps[1:(length(my_corr_ps)-1)]
|
|
||||||
, method = "spearman" # correlation method
|
, method = "spearman" # correlation method
|
||||||
, hist.col = "grey" ##00AFBB
|
, hist.col = "grey" ##00AFBB
|
||||||
, density = TRUE # show density plots
|
, density = TRUE # show density plots
|
||||||
|
@ -206,8 +212,8 @@ OutPlot1 = my_pp(my_corr_ps[1:(length(my_corr_ps)-1)]
|
||||||
#, alpha = .05
|
#, alpha = .05
|
||||||
#, points(pch = 19, col = c("#f8766d", "#00bfc4"))
|
#, points(pch = 19, col = c("#f8766d", "#00bfc4"))
|
||||||
, cex = 3
|
, cex = 3
|
||||||
, cex.axis = 1.5
|
, cex.axis = 2
|
||||||
, cex.labels = 2.1
|
, cex.labels = 4
|
||||||
, cex.cor = 1
|
, cex.cor = 1
|
||||||
, smooth = F
|
, smooth = F
|
||||||
|
|
||||||
|
@ -216,6 +222,39 @@ OutPlot1 = my_pp(my_corr_ps[1:(length(my_corr_ps)-1)]
|
||||||
print(OutPlot1)
|
print(OutPlot1)
|
||||||
dev.off()
|
dev.off()
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------
|
||||||
|
# generate corr PS plot 2: upper_panel only
|
||||||
|
#----------------------------------------------
|
||||||
|
cat("Corr plot upper PS:", plot_corr_upper_ps)
|
||||||
|
svg(plot_corr_upper_ps, width = 15, height = 15)
|
||||||
|
|
||||||
|
OutPlot1_upper = my_pp(my_corr_ps[1:(length(my_corr_ps)-1)] # no lower panel
|
||||||
|
, method = "spearman" # correlation method
|
||||||
|
, hist.col = "grey" ##00AFBB
|
||||||
|
, density = TRUE # show density plots
|
||||||
|
, ellipses = F # show correlation ellipses
|
||||||
|
, stars = T
|
||||||
|
, rug = F
|
||||||
|
, breaks = "Sturges"
|
||||||
|
, show.points = T
|
||||||
|
, bg = c("#f8766d", "#00bfc4")[unclass(factor(my_corr_ps$duet_outcome))]
|
||||||
|
, pch = 21
|
||||||
|
, jitter = T
|
||||||
|
#, alpha = .05
|
||||||
|
#, points(pch = 19, col = c("#f8766d", "#00bfc4"))
|
||||||
|
, cex = 3
|
||||||
|
, cex.axis = 1.6
|
||||||
|
, cex.labels = 4
|
||||||
|
, cex.cor = 1
|
||||||
|
, smooth = F
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
print(OutPlot1_upper)
|
||||||
|
dev.off()
|
||||||
|
|
||||||
|
################################################################################################
|
||||||
#===========================
|
#===========================
|
||||||
# Data for Correlation plots: LIG
|
# Data for Correlation plots: LIG
|
||||||
#===========================
|
#===========================
|
||||||
|
@ -224,11 +263,9 @@ table(df_lig$ligand_outcome)
|
||||||
df_lig$log10_or_mychisq = log10(df_lig$or_mychisq)
|
df_lig$log10_or_mychisq = log10(df_lig$or_mychisq)
|
||||||
df_lig$neglog_pval_fisher = -log10(df_lig$pval_fisher)
|
df_lig$neglog_pval_fisher = -log10(df_lig$pval_fisher)
|
||||||
|
|
||||||
|
|
||||||
df_lig$log10_or_kin = log10(df_lig$or_kin)
|
df_lig$log10_or_kin = log10(df_lig$or_kin)
|
||||||
df_lig$neglog_pwald_kin = -log10(df_lig$pwald_kin)
|
df_lig$neglog_pwald_kin = -log10(df_lig$pwald_kin)
|
||||||
|
|
||||||
|
|
||||||
# subset data to generate pairwise correlations
|
# subset data to generate pairwise correlations
|
||||||
cols_to_select = c("affinity_scaled"
|
cols_to_select = c("affinity_scaled"
|
||||||
|
|
||||||
|
@ -248,8 +285,8 @@ dim(corr_data_lig)
|
||||||
# assign nice colnames (for display)
|
# assign nice colnames (for display)
|
||||||
my_corr_colnames = c("Ligand Affinity"
|
my_corr_colnames = c("Ligand Affinity"
|
||||||
|
|
||||||
, "Log(OR)"
|
, "Log (OR)"
|
||||||
, "-Log(P)"
|
, "-Log (P)"
|
||||||
|
|
||||||
, "AF"
|
, "AF"
|
||||||
|
|
||||||
|
@ -262,10 +299,6 @@ colnames(corr_data_lig)
|
||||||
colnames(corr_data_lig) <- my_corr_colnames
|
colnames(corr_data_lig) <- my_corr_colnames
|
||||||
colnames(corr_data_lig)
|
colnames(corr_data_lig)
|
||||||
|
|
||||||
#-----------------
|
|
||||||
# generate corr LIG plot
|
|
||||||
#-----------------
|
|
||||||
|
|
||||||
start = 1
|
start = 1
|
||||||
end = which(colnames(corr_data_lig) == drug); end # should be the last column
|
end = which(colnames(corr_data_lig) == drug); end # should be the last column
|
||||||
offset = 1
|
offset = 1
|
||||||
|
@ -273,32 +306,66 @@ offset = 1
|
||||||
my_corr_lig = corr_data_lig[start:(end-offset)]
|
my_corr_lig = corr_data_lig[start:(end-offset)]
|
||||||
head(my_corr_lig)
|
head(my_corr_lig)
|
||||||
|
|
||||||
|
#---------------------------------------
|
||||||
|
# generate corr LIG plot 1: both panels
|
||||||
|
#---------------------------------------
|
||||||
cat("Corr LIG plot:", plot_corr_lig)
|
cat("Corr LIG plot:", plot_corr_lig)
|
||||||
svg(plot_corr_lig, width = 15, height = 15)
|
svg(plot_corr_lig, width = 15, height = 15)
|
||||||
|
|
||||||
#OutPlot2 = pairs.panels(my_corr_lig[1:(length(my_corr_lig)-1)]
|
# uncomment as necessary
|
||||||
OutPlot2 = my_pp(my_corr_lig[1:(length(my_corr_lig)-1)]
|
OutPlot2 = pairs.panels(my_corr_lig[1:(length(my_corr_lig)-1)]
|
||||||
, method = "spearman" # correlation method
|
, method = "spearman" # correlation method
|
||||||
, hist.col = "grey" ##00AFBB
|
, hist.col = "grey" ##00AFBB
|
||||||
, density = TRUE # show density plots
|
, density = TRUE # show density plots
|
||||||
, ellipses = F # show correlation ellipses
|
, ellipses = F # show correlation ellipses
|
||||||
, stars = T
|
, stars = T
|
||||||
, rug = F
|
, rug = F
|
||||||
, breaks = "Sturges"
|
, breaks = "Sturges"
|
||||||
, show.points = T
|
, show.points = T
|
||||||
, bg = c("#f8766d", "#00bfc4")[unclass(factor(my_corr_lig$ligand_outcome))]
|
, bg = c("#f8766d", "#00bfc4")[unclass(factor(my_corr_lig$ligand_outcome))]
|
||||||
, pch = 21
|
, pch = 21
|
||||||
, jitter = T
|
, jitter = T
|
||||||
#, alpha = .05
|
#, alpha = .05
|
||||||
#, points(pch = 19, col = c("#f8766d", "#00bfc4"))
|
#, points(pch = 19, col = c("#f8766d", "#00bfc4"))
|
||||||
, cex = 3
|
, cex = 3
|
||||||
, cex.axis = 1.5
|
, cex.axis = 2
|
||||||
, cex.labels = 2.1
|
, cex.labels = 4
|
||||||
, cex.cor = 1
|
, cex.cor = 1
|
||||||
, smooth = F
|
, smooth = F
|
||||||
)
|
)
|
||||||
|
|
||||||
print(OutPlot2)
|
print(OutPlot2)
|
||||||
dev.off()
|
dev.off()
|
||||||
|
|
||||||
|
|
||||||
|
#---------------------------------------
|
||||||
|
# generate corr LIG plot 2: upper panels
|
||||||
|
#---------------------------------------
|
||||||
|
cat("Corr LIG plot:", plot_corr_upper_lig)
|
||||||
|
svg(plot_corr_upper_lig, width = 15, height = 15)
|
||||||
|
|
||||||
|
# uncomment as necessary
|
||||||
|
OutPlot2_upper = my_pp(my_corr_lig[1:(length(my_corr_lig)-1)]
|
||||||
|
, method = "spearman" # correlation method
|
||||||
|
, hist.col = "grey" ##00AFBB
|
||||||
|
, density = TRUE # show density plots
|
||||||
|
, ellipses = F # show correlation ellipses
|
||||||
|
, stars = T
|
||||||
|
, rug = F
|
||||||
|
, breaks = "Sturges"
|
||||||
|
, show.points = T
|
||||||
|
, bg = c("#f8766d", "#00bfc4")[unclass(factor(my_corr_lig$ligand_outcome))]
|
||||||
|
, pch = 21
|
||||||
|
, jitter = T
|
||||||
|
#, alpha = .05
|
||||||
|
#, points(pch = 19, col = c("#f8766d", "#00bfc4"))
|
||||||
|
, cex = 3
|
||||||
|
, cex.axis = 1.6
|
||||||
|
, cex.labels = 4
|
||||||
|
, cex.cor = 1
|
||||||
|
, smooth = F
|
||||||
|
)
|
||||||
|
|
||||||
|
print(OutPlot2_upper)
|
||||||
|
dev.off()
|
||||||
#######################################################
|
#######################################################
|
||||||
library(lattice)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue