saving work

This commit is contained in:
Tanushree Tunstall 2020-09-18 11:55:08 +01:00
parent 5e1c920a0c
commit 24b1cc2440

View file

@ -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")
# should return the following dfs, directories and variables # should return the following dfs, directories and variables
# PS combined: # PS combined:
@ -82,7 +83,58 @@ rm( merged_df2, merged_df2_comp, merged_df2_lig, merged_df2_comp_lig, my_df_u, m
#=========================== #===========================
table(df_ps$duet_outcome) table(df_ps$duet_outcome)
#===========================
# Data for Correlation plots:foldx
#===========================
#============================
# adding foldx scaled values
# scale data b/w -1 and 1
#============================
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)
@ -92,14 +144,21 @@ df_ps$neglog_pwald_kin = -log10(df_ps$pwald_kin)
# subset data to generate pairwise correlations # subset data to generate pairwise correlations
cols_to_select = c("duet_scaled" cols_to_select = c("duet_scaled"
, "log10_or_mychisq" , "foldx_scaled"
, "neglog_pval_fisher"
#, "or_kin" #, "log10_or_mychisq"
#, "neglog_pwald_kin" #, "neglog_pval_fisher"
, "or_kin"
, "neglog_pwald_kin"
, "af" , "af"
, "asa"
, "rsa"
, "kd_values"
, "rd_values"
, "duet_outcome" , "duet_outcome"
, drug) , drug)
@ -113,14 +172,20 @@ dim(corr_data_ps)
# assign nice colnames (for display) # assign nice colnames (for display)
my_corr_colnames = c("DUET" my_corr_colnames = c("DUET"
, "Log(OR)" , "Foldx"
, "-Log(P)" #, "Log(OR)"
#, "-Log(P)"
#, "OR adjusted" , "OR adjusted"
#, "-Log(P wald)" , "-Log(P wald)"
, "AF" , "AF"
, "ASA"
, "RSA"
, "KD"
, "RD"
, "duet_outcome" , "duet_outcome"
, drug) , drug)
@ -161,9 +226,9 @@ OutPlot1 = pairs.panels(my_corr_ps[1:(length(my_corr_ps)-1)]
, 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 = 2
, cex.axis = 2.5 , cex.axis = 1.5
, cex.labels = 2.1 , cex.labels = 1.5
, cex.cor = 1 , cex.cor = 1
, smooth = F , smooth = F
) )