renamed file to denote corr adjusted and plain
This commit is contained in:
parent
fb0646373b
commit
1b5280145b
2 changed files with 95 additions and 95 deletions
|
@ -14,6 +14,7 @@ getwd()
|
||||||
source("Header_TT.R")
|
source("Header_TT.R")
|
||||||
require(cowplot)
|
require(cowplot)
|
||||||
source("combining_dfs_plotting.R")
|
source("combining_dfs_plotting.R")
|
||||||
|
source("my_pairs_panel.R") # with lower panel turned off
|
||||||
# should return the following dfs, directories and variables
|
# should return the following dfs, directories and variables
|
||||||
|
|
||||||
# PS combined:
|
# PS combined:
|
||||||
|
@ -77,33 +78,76 @@ rm( merged_df2, merged_df2_comp, merged_df2_lig, merged_df2_comp_lig, my_df_u, m
|
||||||
# end of data extraction and cleaning for plots #
|
# end of data extraction and cleaning for plots #
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
#===========================
|
#============================
|
||||||
# Data for Correlation plots:PS
|
# adding foldx scaled values
|
||||||
#===========================
|
# scale data b/w -1 and 1
|
||||||
table(df_ps$duet_outcome)
|
#============================
|
||||||
|
n = which(colnames(df_ps) == "ddg"); n
|
||||||
|
|
||||||
|
my_min = min(df_ps[,n]); my_min
|
||||||
|
my_max = max(df_ps[,n]); my_max
|
||||||
|
|
||||||
|
df_ps$foldx_scaled = ifelse(df_ps[,n] < 0
|
||||||
|
, df_ps[,n]/abs(my_min)
|
||||||
|
, df_ps[,n]/my_max)
|
||||||
|
# sanity check
|
||||||
|
my_min = min(df_ps$foldx_scaled); my_min
|
||||||
|
my_max = max(df_ps$foldx_scaled); my_max
|
||||||
|
|
||||||
|
if (my_min == -1 && my_max == 1){
|
||||||
|
cat("PASS: foldx ddg successfully scaled b/w -1 and 1"
|
||||||
|
, "\nProceeding with assigning foldx outcome category")
|
||||||
|
}else{
|
||||||
|
cat("FAIL: could not scale foldx ddg values"
|
||||||
|
, "Aborting!")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#================================
|
||||||
|
# adding foldx outcome category
|
||||||
|
# ddg<0 = "Stabilising" (-ve)
|
||||||
|
#=================================
|
||||||
|
|
||||||
|
c1 = table(df_ps$ddg < 0)
|
||||||
|
df_ps$foldx_outcome = ifelse(df_ps$ddg < 0, "Stabilising", "Destabilising")
|
||||||
|
c2 = table(df_ps$ddg < 0)
|
||||||
|
|
||||||
|
if ( all(c1 == c2) ){
|
||||||
|
cat("PASS: foldx outcome successfully created")
|
||||||
|
}else{
|
||||||
|
cat("FAIL: foldx outcome could not be created. Aborting!")
|
||||||
|
exit()
|
||||||
|
}
|
||||||
|
|
||||||
|
table(df_ps$foldx_outcome)
|
||||||
|
|
||||||
|
#======================
|
||||||
# adding log cols
|
# adding log cols
|
||||||
|
#======================
|
||||||
|
|
||||||
df_ps$log10_or_mychisq = log10(df_ps$or_mychisq)
|
df_ps$log10_or_mychisq = log10(df_ps$or_mychisq)
|
||||||
df_ps$neglog_pval_fisher = -log10(df_ps$pval_fisher)
|
df_ps$neglog_pval_fisher = -log10(df_ps$pval_fisher)
|
||||||
|
|
||||||
df_ps$log10_or_kin = log10(df_ps$or_kin)
|
df_ps$log10_or_kin = log10(df_ps$or_kin)
|
||||||
df_ps$neglog_pwald_kin = -log10(df_ps$pwald_kin)
|
df_ps$neglog_pwald_kin = -log10(df_ps$pwald_kin)
|
||||||
|
|
||||||
|
#===========================
|
||||||
|
# Data for Correlation plots:PS
|
||||||
|
#===========================
|
||||||
# subset data to generate pairwise correlations
|
# subset data to generate pairwise correlations
|
||||||
cols_to_select = c("duet_scaled"
|
cols_to_select = c("duet_scaled"
|
||||||
|
|
||||||
|
, "foldx_scaled"
|
||||||
|
|
||||||
, "log10_or_mychisq"
|
, "log10_or_mychisq"
|
||||||
, "neglog_pval_fisher"
|
, "neglog_pval_fisher"
|
||||||
|
|
||||||
, "log10_or_kin"
|
|
||||||
, "neglog_pwald_kin"
|
|
||||||
|
|
||||||
, "af"
|
, "af"
|
||||||
|
|
||||||
, "duet_outcome"
|
, "duet_outcome"
|
||||||
, drug)
|
, drug)
|
||||||
|
|
||||||
corr_data_ps = df_ps[, cols_to_select]
|
corr_data_ps = df_ps[cols_to_select]
|
||||||
|
|
||||||
dim(corr_data_ps)
|
dim(corr_data_ps)
|
||||||
|
|
||||||
|
@ -113,12 +157,11 @@ dim(corr_data_ps)
|
||||||
# assign nice colnames (for display)
|
# assign nice colnames (for display)
|
||||||
my_corr_colnames = c("DUET"
|
my_corr_colnames = c("DUET"
|
||||||
|
|
||||||
|
, "Foldx"
|
||||||
|
|
||||||
, "Log(OR)"
|
, "Log(OR)"
|
||||||
, "-Log(P)"
|
, "-Log(P)"
|
||||||
|
|
||||||
, "Log(OR adjusted)"
|
|
||||||
, "-Log(P wald)"
|
|
||||||
|
|
||||||
, "AF"
|
, "AF"
|
||||||
|
|
||||||
, "duet_outcome"
|
, "duet_outcome"
|
||||||
|
@ -147,7 +190,8 @@ head(my_corr_ps)
|
||||||
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(my_corr_ps[1:(length(my_corr_ps)-1)]
|
#OutPlot1 = pairs.panels([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
|
||||||
|
@ -162,10 +206,11 @@ OutPlot1 = pairs.panels(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 = 2.5
|
, cex.axis = 1.5
|
||||||
, cex.labels = 2.1
|
, cex.labels = 2.1
|
||||||
, cex.cor = 1
|
, cex.cor = 1
|
||||||
, smooth = F
|
, smooth = F
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print(OutPlot1)
|
print(OutPlot1)
|
||||||
|
@ -190,9 +235,6 @@ cols_to_select = c("affinity_scaled"
|
||||||
, "log10_or_mychisq"
|
, "log10_or_mychisq"
|
||||||
, "neglog_pval_fisher"
|
, "neglog_pval_fisher"
|
||||||
|
|
||||||
, "log10_or_kin"
|
|
||||||
, "neglog_pwald_kin"
|
|
||||||
|
|
||||||
, "af"
|
, "af"
|
||||||
|
|
||||||
, "ligand_outcome"
|
, "ligand_outcome"
|
||||||
|
@ -209,9 +251,6 @@ my_corr_colnames = c("Ligand Affinity"
|
||||||
, "Log(OR)"
|
, "Log(OR)"
|
||||||
, "-Log(P)"
|
, "-Log(P)"
|
||||||
|
|
||||||
, "Log(OR adjusted)"
|
|
||||||
, "-Log(P wald)"
|
|
||||||
|
|
||||||
, "AF"
|
, "AF"
|
||||||
|
|
||||||
, "ligand_outcome"
|
, "ligand_outcome"
|
||||||
|
@ -237,7 +276,8 @@ head(my_corr_lig)
|
||||||
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)]
|
#OutPlot2 = pairs.panels(my_corr_lig[1:(length(my_corr_lig)-1)]
|
||||||
|
OutPlot2 = my_pp(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
|
||||||
|
@ -252,7 +292,7 @@ OutPlot2 = pairs.panels(my_corr_lig[1:(length(my_corr_lig)-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 = 2.5
|
, cex.axis = 1.5
|
||||||
, cex.labels = 2.1
|
, cex.labels = 2.1
|
||||||
, cex.cor = 1
|
, cex.cor = 1
|
||||||
, smooth = F
|
, smooth = F
|
||||||
|
@ -261,5 +301,4 @@ OutPlot2 = pairs.panels(my_corr_lig[1:(length(my_corr_lig)-1)]
|
||||||
print(OutPlot2)
|
print(OutPlot2)
|
||||||
dev.off()
|
dev.off()
|
||||||
#######################################################
|
#######################################################
|
||||||
|
library(lattice)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ getwd()
|
||||||
source("Header_TT.R")
|
source("Header_TT.R")
|
||||||
require(cowplot)
|
require(cowplot)
|
||||||
source("combining_dfs_plotting.R")
|
source("combining_dfs_plotting.R")
|
||||||
source("my_pairs_panel.R") # with lower panel turned off
|
|
||||||
# should return the following dfs, directories and variables
|
# should return the following dfs, directories and variables
|
||||||
|
|
||||||
# PS combined:
|
# PS combined:
|
||||||
|
@ -56,12 +55,12 @@ cat(paste0("Variables imported:"
|
||||||
#plot_corr_plot_combined = paste0(plotdir,"/", corr_plot_combined)
|
#plot_corr_plot_combined = paste0(plotdir,"/", corr_plot_combined)
|
||||||
|
|
||||||
# PS
|
# PS
|
||||||
corr_ps_s2 = "corr_PS_style2.svg"
|
corr_ps_adjusted = "corr_PS_adjusted.svg"
|
||||||
plot_corr_ps_s2 = paste0(plotdir,"/", corr_ps_s2)
|
plot_corr_ps_adjusted = paste0(plotdir,"/", corr_ps)
|
||||||
|
|
||||||
# LIG
|
# LIG
|
||||||
corr_lig_s2 = "corr_LIG_style2.svg"
|
corr_lig_adjusted = "corr_LIG_adjusted.svg"
|
||||||
plot_corr_lig_s2 = paste0(plotdir,"/", corr_lig_s2)
|
plot_corr_lig_adjusted = paste0(plotdir,"/", corr_lig)
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# end of loading libraries and functions #
|
# end of loading libraries and functions #
|
||||||
|
@ -78,76 +77,33 @@ rm( merged_df2, merged_df2_comp, merged_df2_lig, merged_df2_comp_lig, my_df_u, m
|
||||||
# end of data extraction and cleaning for plots #
|
# end of data extraction and cleaning for plots #
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
#============================
|
#===========================
|
||||||
# adding foldx scaled values
|
# Data for Correlation plots:PS
|
||||||
# scale data b/w -1 and 1
|
#===========================
|
||||||
#============================
|
table(df_ps$duet_outcome)
|
||||||
n = which(colnames(df_ps) == "ddg"); n
|
|
||||||
|
|
||||||
my_min = min(df_ps[,n]); my_min
|
|
||||||
my_max = max(df_ps[,n]); my_max
|
|
||||||
|
|
||||||
df_ps$foldx_scaled = ifelse(df_ps[,n] < 0
|
|
||||||
, df_ps[,n]/abs(my_min)
|
|
||||||
, df_ps[,n]/my_max)
|
|
||||||
# sanity check
|
|
||||||
my_min = min(df_ps$foldx_scaled); my_min
|
|
||||||
my_max = max(df_ps$foldx_scaled); my_max
|
|
||||||
|
|
||||||
if (my_min == -1 && my_max == 1){
|
|
||||||
cat("PASS: foldx ddg successfully scaled b/w -1 and 1"
|
|
||||||
, "\nProceeding with assigning foldx outcome category")
|
|
||||||
}else{
|
|
||||||
cat("FAIL: could not scale foldx ddg values"
|
|
||||||
, "Aborting!")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#================================
|
|
||||||
# adding foldx outcome category
|
|
||||||
# ddg<0 = "Stabilising" (-ve)
|
|
||||||
#=================================
|
|
||||||
|
|
||||||
c1 = table(df_ps$ddg < 0)
|
|
||||||
df_ps$foldx_outcome = ifelse(df_ps$ddg < 0, "Stabilising", "Destabilising")
|
|
||||||
c2 = table(df_ps$ddg < 0)
|
|
||||||
|
|
||||||
if ( all(c1 == c2) ){
|
|
||||||
cat("PASS: foldx outcome successfully created")
|
|
||||||
}else{
|
|
||||||
cat("FAIL: foldx outcome could not be created. Aborting!")
|
|
||||||
exit()
|
|
||||||
}
|
|
||||||
|
|
||||||
table(df_ps$foldx_outcome)
|
|
||||||
|
|
||||||
#======================
|
|
||||||
# adding log cols
|
# adding log cols
|
||||||
#======================
|
|
||||||
|
|
||||||
df_ps$log10_or_mychisq = log10(df_ps$or_mychisq)
|
df_ps$log10_or_mychisq = log10(df_ps$or_mychisq)
|
||||||
df_ps$neglog_pval_fisher = -log10(df_ps$pval_fisher)
|
df_ps$neglog_pval_fisher = -log10(df_ps$pval_fisher)
|
||||||
|
|
||||||
df_ps$log10_or_kin = log10(df_ps$or_kin)
|
df_ps$log10_or_kin = log10(df_ps$or_kin)
|
||||||
df_ps$neglog_pwald_kin = -log10(df_ps$pwald_kin)
|
df_ps$neglog_pwald_kin = -log10(df_ps$pwald_kin)
|
||||||
|
|
||||||
#===========================
|
|
||||||
# Data for Correlation plots:PS
|
|
||||||
#===========================
|
|
||||||
# subset data to generate pairwise correlations
|
# subset data to generate pairwise correlations
|
||||||
cols_to_select = c("duet_scaled"
|
cols_to_select = c("duet_scaled"
|
||||||
|
|
||||||
, "foldx_scaled"
|
|
||||||
|
|
||||||
, "log10_or_mychisq"
|
, "log10_or_mychisq"
|
||||||
, "neglog_pval_fisher"
|
, "neglog_pval_fisher"
|
||||||
|
|
||||||
|
#, "or_kin"
|
||||||
|
#, "neglog_pwald_kin"
|
||||||
|
|
||||||
, "af"
|
, "af"
|
||||||
|
|
||||||
, "duet_outcome"
|
, "duet_outcome"
|
||||||
, drug)
|
, drug)
|
||||||
|
|
||||||
corr_data_ps = df_ps[cols_to_select]
|
corr_data_ps = df_ps[, cols_to_select]
|
||||||
|
|
||||||
dim(corr_data_ps)
|
dim(corr_data_ps)
|
||||||
|
|
||||||
|
@ -157,11 +113,12 @@ dim(corr_data_ps)
|
||||||
# assign nice colnames (for display)
|
# assign nice colnames (for display)
|
||||||
my_corr_colnames = c("DUET"
|
my_corr_colnames = c("DUET"
|
||||||
|
|
||||||
, "Foldx"
|
|
||||||
|
|
||||||
, "Log(OR)"
|
, "Log(OR)"
|
||||||
, "-Log(P)"
|
, "-Log(P)"
|
||||||
|
|
||||||
|
#, "OR adjusted"
|
||||||
|
#, "-Log(P wald)"
|
||||||
|
|
||||||
, "AF"
|
, "AF"
|
||||||
|
|
||||||
, "duet_outcome"
|
, "duet_outcome"
|
||||||
|
@ -187,11 +144,10 @@ head(my_corr_ps)
|
||||||
# deep blue :#007d85
|
# deep blue :#007d85
|
||||||
# deep red: #ae301e
|
# deep red: #ae301e
|
||||||
|
|
||||||
cat("Corr plot PS:", plot_corr_ps_s2)
|
cat("Corr plot PS:", plot_corr_ps_adjusted)
|
||||||
svg(plot_corr_ps_s2, width = 15, height = 15)
|
svg(plot_corr_ps_adjusted, 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,11 +162,10 @@ 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.5
|
||||||
, cex.labels = 2.1
|
, cex.labels = 2.1
|
||||||
, cex.cor = 1
|
, cex.cor = 1
|
||||||
, smooth = F
|
, smooth = F
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
print(OutPlot1)
|
print(OutPlot1)
|
||||||
|
@ -235,6 +190,9 @@ cols_to_select = c("affinity_scaled"
|
||||||
, "log10_or_mychisq"
|
, "log10_or_mychisq"
|
||||||
, "neglog_pval_fisher"
|
, "neglog_pval_fisher"
|
||||||
|
|
||||||
|
#, "or_kin"
|
||||||
|
#, "neglog_pwald_kin"
|
||||||
|
|
||||||
, "af"
|
, "af"
|
||||||
|
|
||||||
, "ligand_outcome"
|
, "ligand_outcome"
|
||||||
|
@ -251,6 +209,9 @@ my_corr_colnames = c("Ligand Affinity"
|
||||||
, "Log(OR)"
|
, "Log(OR)"
|
||||||
, "-Log(P)"
|
, "-Log(P)"
|
||||||
|
|
||||||
|
#, "OR adjusted"
|
||||||
|
#, "-Log(P wald)"
|
||||||
|
|
||||||
, "AF"
|
, "AF"
|
||||||
|
|
||||||
, "ligand_outcome"
|
, "ligand_outcome"
|
||||||
|
@ -273,11 +234,10 @@ 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)
|
||||||
|
|
||||||
cat("Corr LIG plot:", plot_corr_lig_s2)
|
cat("Corr LIG plot:", plot_corr_lig_adjusted)
|
||||||
svg(plot_corr_lig_s2, width = 15, height = 15)
|
svg(plot_corr_lig_adjusted, width = 15, height = 15)
|
||||||
|
|
||||||
#OutPlot2 = pairs.panels(my_corr_lig[1:(length(my_corr_lig)-1)]
|
OutPlot2 = pairs.panels(my_corr_lig[1:(length(my_corr_lig)-1)]
|
||||||
OutPlot2 = my_pp(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
|
||||||
|
@ -292,7 +252,7 @@ OutPlot2 = my_pp(my_corr_lig[1:(length(my_corr_lig)-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.5
|
||||||
, cex.labels = 2.1
|
, cex.labels = 2.1
|
||||||
, cex.cor = 1
|
, cex.cor = 1
|
||||||
, smooth = F
|
, smooth = F
|
||||||
|
@ -301,4 +261,5 @@ OutPlot2 = my_pp(my_corr_lig[1:(length(my_corr_lig)-1)]
|
||||||
print(OutPlot2)
|
print(OutPlot2)
|
||||||
dev.off()
|
dev.off()
|
||||||
#######################################################
|
#######################################################
|
||||||
library(lattice)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue