added foldx scaled and foldx outcome to plotting_data.R

This commit is contained in:
Tanushree Tunstall 2020-09-23 11:12:41 +01:00
parent 5579e9527b
commit 6d08b646fc
3 changed files with 48 additions and 17 deletions

View file

@ -63,6 +63,52 @@ my_df = read.csv(infile_params, header = T)
cat("\nInput dimensions:", dim(my_df))
###########################
# add foldx outcome category
# and foldx scaled values
# This will enable to always have these variables available
# when calling for plots
###########################
#------------------------------
# adding foldx scaled values
# scale data b/w -1 and 1
#------------------------------
n = which(colnames(my_df) == "ddg"); n
my_min = min(my_df[,n]); my_min
my_max = max(my_df[,n]); my_max
my_df$foldx_scaled = ifelse(my_df[,n] < 0
, my_df[,n]/abs(my_min)
, my_df[,n]/my_max)
# sanity check
my_min = min(my_df$foldx_scaled); my_min
my_max = max(my_df$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(my_df$ddg < 0)
my_df$foldx_outcome = ifelse(my_df$ddg < 0, "Stabilising", "Destabilising")
c2 = table(my_df$ddg < 0)
if ( all(c1 == c2) ){
cat("PASS: foldx outcome successfully created")
}else{
cat("FAIL: foldx outcome could not be created. Aborting!")
exit()
}
###########################
# extract unique mutation entries