playing with dm_om (other)plots data and graph on gid branch
This commit is contained in:
parent
1e3670f935
commit
e36e7736db
4 changed files with 502 additions and 410 deletions
|
@ -32,7 +32,8 @@ import_dirs <- function(drug_name, gene_name) {
|
||||||
#===============================
|
#===============================
|
||||||
# mcsm ligand distance cut off
|
# mcsm ligand distance cut off
|
||||||
#===============================
|
#===============================
|
||||||
#mcsm_lig_cutoff <<- 10
|
LigDist_colname <<- "ligand_distance"
|
||||||
|
LigDist_cutoff <<- 10
|
||||||
|
|
||||||
#==================
|
#==================
|
||||||
# Angstroms symbol
|
# Angstroms symbol
|
||||||
|
|
|
@ -25,8 +25,8 @@ source("../functions/bp_subcolours.R")
|
||||||
# variables for lig
|
# variables for lig
|
||||||
#====================
|
#====================
|
||||||
|
|
||||||
LigDist_colname = "ligand_distance"
|
#LigDist_colname = "ligand_distance"
|
||||||
LigDist_cutoff = 10
|
#LigDist_cutoff = 10
|
||||||
|
|
||||||
#===========
|
#===========
|
||||||
# input
|
# input
|
||||||
|
@ -56,8 +56,13 @@ pd_df = plotting_data(mcsm_df
|
||||||
|
|
||||||
my_df = pd_df[[1]]
|
my_df = pd_df[[1]]
|
||||||
my_df_u = pd_df[[2]] # this forms one of the input for combining_dfs_plotting()
|
my_df_u = pd_df[[2]] # this forms one of the input for combining_dfs_plotting()
|
||||||
my_df_u_lig = pd_df[[3]]
|
|
||||||
dup_muts = pd_df[[4]]
|
max_ang <- round(max(my_df_u[LigDist_colname]))
|
||||||
|
min_ang <- round(min(my_df_u[LigDist_colname]))
|
||||||
|
|
||||||
|
cat("\nLigand distance cut off, colname:", LigDist_colname
|
||||||
|
, "\nThe max distance", gene, "structure df" , ":", max_ang, "\u212b"
|
||||||
|
, "\nThe min distance", gene, "structure df" , ":", min_ang, "\u212b")
|
||||||
|
|
||||||
#--------------------------------
|
#--------------------------------
|
||||||
# call: combining_dfs_plotting()
|
# call: combining_dfs_plotting()
|
||||||
|
@ -83,12 +88,20 @@ all_plot_dfs = combining_dfs_plotting(my_df_u
|
||||||
|
|
||||||
merged_df2 = all_plot_dfs[[1]]
|
merged_df2 = all_plot_dfs[[1]]
|
||||||
merged_df3 = all_plot_dfs[[2]]
|
merged_df3 = all_plot_dfs[[2]]
|
||||||
merged_df2_comp = all_plot_dfs[[3]]
|
#======================================================================
|
||||||
merged_df3_comp = all_plot_dfs[[4]]
|
# read other files
|
||||||
merged_df2_lig = all_plot_dfs[[5]]
|
infilename_dynamut = paste0("~/git/Data/", drug, "/output/dynamut_results/", gene
|
||||||
merged_df3_lig = all_plot_dfs[[6]]
|
, "_complex_dynamut_norm.csv")
|
||||||
merged_df2_comp_lig = all_plot_dfs[[7]]
|
|
||||||
merged_df3_comp_lig = all_plot_dfs[[8]]
|
infilename_dynamut2 = paste0("~/git/Data/", drug, "/output/dynamut_results/dynamut2/", gene
|
||||||
|
, "_complex_dynamut2_norm.csv")
|
||||||
|
|
||||||
|
infilename_mcsm_na = paste0("~/git/Data/", drug, "/output/mcsm_na_results/", gene
|
||||||
|
, "_complex_mcsm_na_norm.csv")
|
||||||
|
|
||||||
|
dynamut_df = read.csv(infilename_dynamut)
|
||||||
|
dynamut2_df = read.csv(infilename_dynamut2)
|
||||||
|
mcsm_na_df = read.csv(infilename_mcsm_na)
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# Data for subcols barplot (~heatmpa)
|
# Data for subcols barplot (~heatmpa)
|
||||||
|
@ -168,61 +181,6 @@ subcolsR_ps <- ColourPalleteMulti(subcols_df_ps, "duet_outcome", "my_grp_r")
|
||||||
print(paste0("Colour palette generated for my_grp: ", length(subcols_ps), " colours"))
|
print(paste0("Colour palette generated for my_grp: ", length(subcols_ps), " colours"))
|
||||||
print(paste0("Colour palette generated for my_grp_r: ", length(subcolsR_ps), " colours"))
|
print(paste0("Colour palette generated for my_grp_r: ", length(subcolsR_ps), " colours"))
|
||||||
|
|
||||||
#=======================
|
|
||||||
# Data for sub colours
|
|
||||||
# barplot: LIG
|
|
||||||
#=======================
|
|
||||||
cat("\nNo. of cols to select:", length(cols_to_select))
|
|
||||||
|
|
||||||
subcols_df_lig = merged_df3_lig[, cols_to_select]
|
|
||||||
|
|
||||||
cat("\nNo of unique positions for LIG:"
|
|
||||||
, length(unique(subcols_df_lig$position)))
|
|
||||||
|
|
||||||
# should be a factor
|
|
||||||
if (is.factor(subcols_df_lig$ligand_outcome)){
|
|
||||||
cat("\nLigand_outcome is factor")
|
|
||||||
table(subcols_df_lig$ligand_outcome)
|
|
||||||
}else{
|
|
||||||
cat("\nConverting ligand_outcome to factor")
|
|
||||||
subcols_df_lig$ligand_outcome = as.factor(subcols_df_lig$ligand_outcome)
|
|
||||||
table(subcols_df_lig$ligand_outcome)
|
|
||||||
}
|
|
||||||
|
|
||||||
# should be -1 and 1
|
|
||||||
min(subcols_df_lig$affinity_scaled)
|
|
||||||
max(subcols_df_lig$affinity_scaled)
|
|
||||||
|
|
||||||
tapply(subcols_df_lig$affinity_scaled, subcols_df_lig$ligand_outcome, min)
|
|
||||||
tapply(subcols_df_lig$affinity_scaled, subcols_df_lig$ligand_outcome, max)
|
|
||||||
|
|
||||||
# check unique values in normalised data
|
|
||||||
cat("\nNo. of unique values in affinity scaled, no rounding:"
|
|
||||||
, length(unique(subcols_df_lig$affinity_scaled)))
|
|
||||||
|
|
||||||
# No rounding
|
|
||||||
my_grp_lig = subcols_df_lig$affinity_scaled; length(my_grp_lig)
|
|
||||||
|
|
||||||
# Add rounding is to be used
|
|
||||||
n = 3
|
|
||||||
subcols_df_lig$affinity_scaledR = round(subcols_df_lig$affinity_scaled, n)
|
|
||||||
|
|
||||||
cat("\nNo. of unique values in duet scaled", n, "places rounding:"
|
|
||||||
, length(unique(subcols_df_lig$affinity_scaledR)))
|
|
||||||
|
|
||||||
my_grp_lig_r = subcols_df_lig$affinity_scaledR # rounding
|
|
||||||
|
|
||||||
# Add grp cols
|
|
||||||
subcols_df_lig$group_lig <- paste0(subcols_df_lig$ligand_outcome, "_", my_grp_lig, sep = "")
|
|
||||||
subcols_df_lig$group_ligR <- paste0(subcols_df_lig$ligand_outcome, "_", my_grp_lig_r, sep = "")
|
|
||||||
|
|
||||||
# Call the function to create the palette based on the group defined above
|
|
||||||
subcols_lig <- ColourPalleteMulti(subcols_df_lig, "ligand_outcome", "my_grp_lig")
|
|
||||||
subcolsR_lig <- ColourPalleteMulti(subcols_df_lig, "ligand_outcome", "my_grp_lig_r")
|
|
||||||
|
|
||||||
print(paste0("Colour palette generated for my_grp: ", length(subcols_lig), " colours"))
|
|
||||||
print(paste0("Colour palette generated for my_grp_r: ", length(subcolsR_lig), " colours"))
|
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
# Data for logoplots
|
# Data for logoplots
|
||||||
####################################################################
|
####################################################################
|
||||||
|
@ -472,113 +430,6 @@ if (nrow(corr_ps_df3) == nrow(merged_df3) && nrow(merged_df3_comp) == check1) {
|
||||||
, "\nGot: ", check1)
|
, "\nGot: ", check1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================
|
|
||||||
# Data for Correlation plots: LIG
|
|
||||||
#=================================
|
|
||||||
cat("\n=========================================="
|
|
||||||
, "\nCORR PLOTS data: LIG"
|
|
||||||
, "\n===========================================")
|
|
||||||
|
|
||||||
df_lig = merged_df2_lig
|
|
||||||
|
|
||||||
table(df_lig$ligand_outcome)
|
|
||||||
|
|
||||||
#--------------------
|
|
||||||
# adding log cols : NEW UNCOMMENT
|
|
||||||
#--------------------
|
|
||||||
#df_lig$log10_or_mychisq = log10(df_lig$or_mychisq)
|
|
||||||
#df_lig$neglog_pval_fisher = -log10(df_lig$pval_fisher)
|
|
||||||
|
|
||||||
##df_lig$log10_or_kin = log10(df_lig$or_kin)
|
|
||||||
##df_lig$neglog_pwald_kin = -log10(df_lig$pwald_kin)
|
|
||||||
|
|
||||||
#----------------------------
|
|
||||||
# columns for corr plots:PS
|
|
||||||
#----------------------------
|
|
||||||
# subset data to generate pairwise correlations
|
|
||||||
cols_to_select = c("mutationinformation"
|
|
||||||
, "affinity_scaled"
|
|
||||||
#, "mutation_info_labels"
|
|
||||||
, "asa"
|
|
||||||
, "rsa"
|
|
||||||
, "rd_values"
|
|
||||||
, "kd_values"
|
|
||||||
, "log10_or_mychisq"
|
|
||||||
, "neglog_pval_fisher"
|
|
||||||
##, "or_kin"
|
|
||||||
##, "neglog_pwald_kin"
|
|
||||||
, "af"
|
|
||||||
##, "af_kin"
|
|
||||||
, "ligand_outcome"
|
|
||||||
, drug)
|
|
||||||
|
|
||||||
corr_data_lig = df_lig[, cols_to_select]
|
|
||||||
|
|
||||||
dim(corr_data_lig)
|
|
||||||
|
|
||||||
#--------------------------------------
|
|
||||||
# assign nice colnames (for display)
|
|
||||||
#--------------------------------------
|
|
||||||
my_corr_colnames = c("Mutation"
|
|
||||||
, "Ligand Affinity"
|
|
||||||
#, "Mutation class"
|
|
||||||
, "ASA"
|
|
||||||
, "RSA"
|
|
||||||
, "RD"
|
|
||||||
, "KD"
|
|
||||||
, "Log (OR)"
|
|
||||||
, "-Log (P)"
|
|
||||||
##, "Adjusted (OR)"
|
|
||||||
##, "-Log (P wald)"
|
|
||||||
, "MAF"
|
|
||||||
##, "MAF_kin"
|
|
||||||
, "ligand_outcome"
|
|
||||||
, drug)
|
|
||||||
|
|
||||||
length(my_corr_colnames)
|
|
||||||
|
|
||||||
colnames(corr_data_lig)
|
|
||||||
colnames(corr_data_lig) <- my_corr_colnames
|
|
||||||
colnames(corr_data_lig)
|
|
||||||
|
|
||||||
start = 1
|
|
||||||
end = which(colnames(corr_data_lig) == drug); end # should be the last column
|
|
||||||
offset = 1
|
|
||||||
|
|
||||||
#=============================
|
|
||||||
# Corr data for plots: LIG
|
|
||||||
# big_df lig: ~ merged_df2_lig
|
|
||||||
#==============================
|
|
||||||
#corr_lig_df2 = corr_data_lig[start:(end-offset)] # without drug
|
|
||||||
corr_lig_df2 = corr_data_lig[start:end]
|
|
||||||
head(corr_lig_df2)
|
|
||||||
|
|
||||||
#=============================
|
|
||||||
# Corr data for plots: LIG
|
|
||||||
# short_df lig: ~ merged_df3_lig
|
|
||||||
#==============================
|
|
||||||
corr_lig_df3 = corr_lig_df2[!duplicated(corr_lig_df2$Mutation),]
|
|
||||||
|
|
||||||
na_or_lig = sum(is.na(corr_lig_df3$`Log (OR)`))
|
|
||||||
check1_lig = nrow(corr_lig_df3) - na_or_lig
|
|
||||||
|
|
||||||
if (nrow(corr_lig_df3) == nrow(merged_df3_lig) && nrow(merged_df3_comp_lig) == check1_lig) {
|
|
||||||
cat( "\nPASS: No. of rows for corr_lig_df3 match"
|
|
||||||
, "\nPASS: No. of OR values checked: " , check1_lig)
|
|
||||||
} else {
|
|
||||||
cat("\nFAIL: Numbers mismatch:"
|
|
||||||
, "\nExpected nrows: ", nrow(merged_df3_lig)
|
|
||||||
, "\nGot: ", nrow(corr_ps_df3_lig)
|
|
||||||
, "\nExpected OR values: ", nrow(merged_df3_comp_lig)
|
|
||||||
, "\nGot: ", check1_lig)
|
|
||||||
}
|
|
||||||
|
|
||||||
# remove unnecessary columns
|
|
||||||
identical(corr_data_lig, corr_lig_df2)
|
|
||||||
identical(corr_data_ps, corr_ps_df2)
|
|
||||||
|
|
||||||
#rm(df_ps, df_lig, corr_data_ps, corr_data_lig)
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# End of script
|
# End of script
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
|
@ -45,12 +45,15 @@ my_pts = 22 # plot title size
|
||||||
#===========
|
#===========
|
||||||
# Plot1: PS
|
# Plot1: PS
|
||||||
#===========
|
#===========
|
||||||
my_stat_ps = compare_means(param_value~mutation_info, group.by = "param_type"
|
# my_stat_ps = compare_means(param_value~mutation_info
|
||||||
, data = df_lf_ps, paired = FALSE, p.adjust.method = "BH")
|
# , group.by = "param_type"
|
||||||
|
# , data = df_lf_ps
|
||||||
|
# , paired = FALSE
|
||||||
|
# , p.adjust.method = "BH")
|
||||||
|
|
||||||
y_value = "param_value"
|
y_value = "param_value"
|
||||||
|
|
||||||
p1 = ggplot(df_lf_ps, aes(x = mutation_info
|
p1 = ggplot(lf_duet, aes(x = mutation_info
|
||||||
, y = eval(parse(text=y_value)) )) +
|
, y = eval(parse(text=y_value)) )) +
|
||||||
facet_wrap(~ param_type
|
facet_wrap(~ param_type
|
||||||
, nrow = 1
|
, nrow = 1
|
||||||
|
@ -61,7 +64,7 @@ p1 = ggplot(df_lf_ps, aes(x = mutation_info
|
||||||
geom_point(position = position_jitterdodge(dodge.width=0.01)
|
geom_point(position = position_jitterdodge(dodge.width=0.01)
|
||||||
, alpha = 0.5
|
, alpha = 0.5
|
||||||
, show.legend = FALSE
|
, show.legend = FALSE
|
||||||
, aes(colour = factor(duet_outcome))) +
|
, aes(colour = duet_outcome)) +
|
||||||
theme(axis.text.x = element_text(size = my_ats)
|
theme(axis.text.x = element_text(size = my_ats)
|
||||||
, axis.text.y = element_text(size = my_ats
|
, axis.text.y = element_text(size = my_ats
|
||||||
, angle = 0
|
, angle = 0
|
||||||
|
|
|
@ -5,21 +5,18 @@
|
||||||
#########################################################
|
#########################################################
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
# working dir and loading libraries
|
# working dir and loading libraries
|
||||||
getwd()
|
# getwd()
|
||||||
setwd("~/git/LSHTM_analysis/scripts/plotting")
|
# setwd("~/git/LSHTM_analysis/scripts/plotting")
|
||||||
getwd()
|
# getwd()
|
||||||
|
|
||||||
#source("Header_TT.R")
|
# make cmd
|
||||||
library(ggplot2)
|
# globals
|
||||||
library(data.table)
|
# drug = "streptomycin"
|
||||||
library(dplyr)
|
# gene = "gid"
|
||||||
library(tidyverse)
|
|
||||||
source("combining_dfs_plotting.R")
|
|
||||||
|
|
||||||
rm(merged_df2, merged_df2_comp, merged_df2_lig, merged_df2_comp_lig
|
|
||||||
, merged_df3_comp, merged_df3_comp_lig
|
|
||||||
, my_df_u, my_df_u_lig)
|
|
||||||
|
|
||||||
|
#source("get_plotting_dfs.R")
|
||||||
|
#=======================================================================
|
||||||
|
# MOVE TO COMBINE or singular file for deepddg
|
||||||
|
|
||||||
cols_to_select = c("mutation", "mutationinformation"
|
cols_to_select = c("mutation", "mutationinformation"
|
||||||
, "wild_type", "position", "mutant_type"
|
, "wild_type", "position", "mutant_type"
|
||||||
|
@ -27,275 +24,515 @@ cols_to_select = c("mutation", "mutationinformation"
|
||||||
|
|
||||||
merged_df3_short = merged_df3[, cols_to_select]
|
merged_df3_short = merged_df3[, cols_to_select]
|
||||||
|
|
||||||
# write merged_df3 to generate structural figure
|
infilename_mcsm_f_snps <- paste0("~/git/Data/", drug, "/output/", gene
|
||||||
write.csv(merged_df3_short, "merged_df3_short.csv")
|
, "_mcsm_formatted_snps.csv")
|
||||||
|
|
||||||
|
mcsm_f_snps<- read.csv(infilename_mcsm_f_snps, header = F)
|
||||||
|
names(mcsm_f_snps) <- "mutationinformation"
|
||||||
|
|
||||||
|
# write merged_df3 to generate structural figure on chimera
|
||||||
|
#write.csv(merged_df3_short, "merged_df3_short.csv")
|
||||||
#========================================================================
|
#========================================================================
|
||||||
#%%%%%%%%%%%%%%%%%%%
|
# MOVE TO COMBINE or singular file for deepddg
|
||||||
# REASSIGNMENT: PS
|
|
||||||
#%%%%%%%%%%%%%%%%%%%%
|
|
||||||
df_ps = merged_df3
|
|
||||||
|
|
||||||
#============================
|
#============================
|
||||||
# adding foldx scaled values
|
# adding deepddg scaled values
|
||||||
# scale data b/w -1 and 1
|
# scale data b/w -1 and 1
|
||||||
#============================
|
#============================
|
||||||
n = which(colnames(df_ps) == "ddg"); n
|
n = which(colnames(merged_df3) == "deepddg"); n
|
||||||
|
|
||||||
my_min = min(df_ps[,n]); my_min
|
my_min = min(merged_df3[,n]); my_min
|
||||||
my_max = max(df_ps[,n]); my_max
|
my_max = max(merged_df3[,n]); my_max
|
||||||
|
|
||||||
df_ps$foldx_scaled = ifelse(df_ps[,n] < 0
|
merged_df3$deepddg_scaled = ifelse(merged_df3[,n] < 0
|
||||||
, df_ps[,n]/abs(my_min)
|
, merged_df3[,n]/abs(my_min)
|
||||||
, df_ps[,n]/my_max)
|
, merged_df3[,n]/my_max)
|
||||||
# sanity check
|
# sanity check
|
||||||
my_min = min(df_ps$foldx_scaled); my_min
|
my_min = min(merged_df3$deepddg_scaled); my_min
|
||||||
my_max = max(df_ps$foldx_scaled); my_max
|
my_max = max(merged_df3$deepddg_scaled); my_max
|
||||||
|
|
||||||
if (my_min == -1 && my_max == 1){
|
if (my_min == -1 && my_max == 1){
|
||||||
cat("PASS: foldx ddg successfully scaled b/w -1 and 1"
|
cat("PASS: DeepDDG successfully scaled b/w -1 and 1"
|
||||||
, "\nProceeding with assigning foldx outcome category")
|
#, "\nProceeding with assigning deep outcome category")
|
||||||
|
, "\n")
|
||||||
}else{
|
}else{
|
||||||
cat("FAIL: could not scale foldx ddg values"
|
cat("FAIL: could not scale DeepDDG ddg values"
|
||||||
, "Aborting!")
|
, "Aborting!")
|
||||||
}
|
}
|
||||||
|
|
||||||
#================================
|
#========================================================================
|
||||||
# adding foldx outcome category
|
# cols to select
|
||||||
# ddg<0 = "Stabilising" (-ve)
|
|
||||||
#=================================
|
|
||||||
|
|
||||||
c1 = table(df_ps$ddg < 0)
|
cols_mcsm_df <- merged_df3[, c("mutationinformation", "mutation"
|
||||||
df_ps$foldx_outcome = ifelse(df_ps$ddg < 0, "Stabilising", "Destabilising")
|
, "mutation_info", "position"
|
||||||
c2 = table(df_ps$ddg < 0)
|
, LigDist_colname
|
||||||
|
, "duet_stability_change", "duet_scaled", "duet_outcome"
|
||||||
|
, "ligand_affinity_change", "affinity_scaled", "ligand_outcome"
|
||||||
|
, "ddg_foldx", "foldx_scaled", "foldx_outcome"
|
||||||
|
, "deepddg", "deepddg_scaled", "deepddg_outcome"
|
||||||
|
, "asa", "rsa"
|
||||||
|
, "rd_values", "kd_values"
|
||||||
|
, "log10_or_mychisq", "neglog_pval_fisher", "af")]
|
||||||
|
|
||||||
|
cols_mcsm_na_df <- mcsm_na_df[, c("mutationinformation"
|
||||||
|
, "mcsm_na_affinity", "mcsm_na_scaled"
|
||||||
|
, "mcsm_na_outcome")]
|
||||||
|
# entire dynamut_df
|
||||||
|
|
||||||
|
cols_dynamut2_df <- dynamut2_df[, c("mutationinformation"
|
||||||
|
, "ddg_dynamut2", "ddg_dynamut2_scaled"
|
||||||
|
, "ddg_dynamut2_outcome")]
|
||||||
|
|
||||||
|
n_comb_cols = length(cols_mcsm_df) + length(cols_mcsm_na_df) +
|
||||||
|
length(dynamut_df) + length(cols_dynamut2_df); n_comb_cols
|
||||||
|
|
||||||
|
i1<- intersect(names(cols_mcsm_df), names(cols_mcsm_na_df))
|
||||||
|
i2<- intersect(names(dynamut_df), names(cols_dynamut2_df))
|
||||||
|
merging_cols <- intersect(i1, i2)
|
||||||
|
cat("\nmerging_cols:", merging_cols)
|
||||||
|
|
||||||
|
if (merging_cols == "mutationinformation") {
|
||||||
|
cat("\nStage 1: Found common col between dfs, checking values in it...")
|
||||||
|
c1 <- all(mcsm_f_snps[[merging_cols]]%in%cols_mcsm_df[[merging_cols]])
|
||||||
|
c2 <- all(mcsm_f_snps[[merging_cols]]%in%cols_mcsm_na_df[[merging_cols]])
|
||||||
|
c3 <- all(mcsm_f_snps[[merging_cols]]%in%dynamut_df[[merging_cols]])
|
||||||
|
c4 <- all(mcsm_f_snps[[merging_cols]]%in%cols_dynamut2_df[[merging_cols]])
|
||||||
|
cols_check <- c(c1, c2, c3, c4)
|
||||||
|
expected_cols = n_comb_cols - ( length(cols_check) - 1)
|
||||||
|
if (all(cols_check)){
|
||||||
|
cat("\nStage 2:Proceeding with merging dfs:\n")
|
||||||
|
comb_df <- Reduce(inner_join, list(cols_mcsm_df
|
||||||
|
, cols_mcsm_na_df
|
||||||
|
, dynamut_df
|
||||||
|
, cols_dynamut2_df))
|
||||||
|
comb_df_s = arrange(comb_df, position)
|
||||||
|
|
||||||
|
# if ( nrow(comb_df_s) == nrow(mcsm_f_snps) && ncol(comb_df_s) == expected_cols) {
|
||||||
|
# cat("\Stage3, PASS: dfs merged sucessfully"
|
||||||
|
# , "\nnrow of merged_df: ", nrow(comb_df_s)
|
||||||
|
# , "\nncol of merged_df:", ncol(comb_df_s))
|
||||||
|
# }
|
||||||
|
|
||||||
if ( all(c1 == c2) ){
|
|
||||||
cat("PASS: foldx outcome successfully created")
|
|
||||||
}else{
|
|
||||||
cat("FAIL: foldx outcome could not be created. Aborting!")
|
|
||||||
exit()
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
names(comb_df_s)
|
||||||
#=======================================================================
|
#=======================================================================
|
||||||
# name tidying
|
fact_cols = colnames(comb_df_s)[grepl( "_outcome|_info", colnames(comb_df_s) )]
|
||||||
df_ps$mutation_info = as.factor(df_ps$mutation_info)
|
fact_cols
|
||||||
df_ps$duet_outcome = as.factor(df_ps$duet_outcome)
|
lapply(comb_df_s[, fact_cols], class)
|
||||||
df_ps$foldx_outcome = as.factor(df_ps$foldx_outcome)
|
comb_df_s[,fact_cols] <- lapply(comb_df_s[,cols],as.factor)
|
||||||
df_ps$ligand_outcome = as.factor(df_ps$ligand_outcome)
|
|
||||||
|
|
||||||
# check
|
if (any(lapply(comb_df_s[, fact_cols], class) == "character")){
|
||||||
table(df_ps$mutation_info)
|
cat("\nChanging cols to factor")
|
||||||
|
comb_df_s[, fact_cols] <- lapply(comb_df_s[, fact_cols],as.factor)
|
||||||
|
if (all(lapply(comb_df_s[, fact_cols], class) == "factor")){
|
||||||
|
cat("\nSuccessful: cols changed to factor")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lapply(comb_df_s[, fact_cols], class)
|
||||||
|
|
||||||
|
#=======================================================================
|
||||||
|
table(comb_df_s$mutation_info)
|
||||||
|
|
||||||
# further checks to make sure dr and other muts are indeed unique
|
# further checks to make sure dr and other muts are indeed unique
|
||||||
dr_muts = df_ps[df_ps$mutation_info == dr_muts_col,]
|
dr_muts = comb_df_s[comb_df_s$mutation_info == dr_muts_col,]
|
||||||
dr_muts_names = unique(dr_muts$mutation)
|
dr_muts_names = unique(dr_muts$mutation)
|
||||||
|
|
||||||
other_muts = df_ps[df_ps$mutation_info == other_muts_col,]
|
other_muts = comb_df_s[comb_df_s$mutation_info == other_muts_col,]
|
||||||
other_muts_names = unique(other_muts$mutation)
|
other_muts_names = unique(other_muts$mutation)
|
||||||
|
|
||||||
if ( table(dr_muts_names%in%other_muts_names)[[1]] == length(dr_muts_names) &&
|
if ( table(dr_muts_names%in%other_muts_names)[[1]] == length(dr_muts_names) &&
|
||||||
table(other_muts_names%in%dr_muts_names)[[1]] == length(other_muts_names) ){
|
table(other_muts_names%in%dr_muts_names)[[1]] == length(other_muts_names) ){
|
||||||
cat("PASS: dr and other muts are indeed unique")
|
cat("PASS: dr and other muts are indeed unique")
|
||||||
}else{
|
}else{
|
||||||
cat("FAIL: dr adn others muts are NOT unique!")
|
cat("FAIL: dr and others muts are NOT unique!")
|
||||||
quit()
|
quit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# pretty display names i.e. labels to reduce major code duplication later
|
||||||
|
foo_cnames = data.frame(colnames(comb_df_s))
|
||||||
|
names(foo_cnames) <- "old_name"
|
||||||
|
|
||||||
#%%%%%%%%%%%%%%%%%%%
|
stability_suffix <- paste0(delta_symbol, delta_symbol, "G")
|
||||||
# REASSIGNMENT: LIG
|
flexibility_suffix <- paste0(delta_symbol, delta_symbol, "S")
|
||||||
#%%%%%%%%%%%%%%%%%%%%
|
|
||||||
|
|
||||||
df_lig = merged_df3_lig
|
lig_dn = paste0("Ligand distance (", angstroms_symbol, ")"); lig_dn
|
||||||
|
duet_dn = paste0("DUET ", stability_suffix); duet_dn
|
||||||
|
foldx_dn = paste0("FoldX ", stability_suffix); foldx_dn
|
||||||
|
deepddg_dn = paste0("Deepddg " , stability_suffix); deepddg_dn
|
||||||
|
mcsm_na_dn = paste0("mCSM-NA affinity ", stability_suffix); mcsm_na_dn
|
||||||
|
dynamut_dn = paste0("Dynamut ", stability_suffix); dynamut_dn
|
||||||
|
dynamut2_dn = paste0("Dynamut2 " , stability_suffix); dynamut2_dn
|
||||||
|
encom_ddg_dn = paste0("EnCOM " , stability_suffix); encom_ddg_dn
|
||||||
|
encom_dds_dn = paste0("EnCOM " , flexibility_suffix ); encom_dds_dn
|
||||||
|
sdm_dn = paste0("SDM " , stability_suffix); sdm_dn
|
||||||
|
mcsm_dn = paste0("mCSM " , stability_suffix ); mcsm_dn
|
||||||
|
|
||||||
# name tidying
|
# Change colnames of some columns using datatable
|
||||||
df_lig$mutation_info = as.factor(df_lig$mutation_info)
|
comb_df_sl = comb_df_s
|
||||||
df_lig$duet_outcome = as.factor(df_lig$duet_outcome)
|
names(comb_df_sl)
|
||||||
#df_lig$ligand_outcome = as.factor(df_lig$ligand_outcome)
|
|
||||||
|
|
||||||
# check
|
|
||||||
table(df_lig$mutation_info)
|
|
||||||
|
|
||||||
#========================================================================
|
|
||||||
#===========
|
|
||||||
# Data: ps
|
|
||||||
#===========
|
|
||||||
# keep similar dtypes cols together
|
|
||||||
cols_to_select_ps = c("mutationinformation", "mutation", "position", "mutation_info"
|
|
||||||
, "duet_outcome"
|
|
||||||
|
|
||||||
|
setnames(comb_df_sl
|
||||||
|
, old = c("asa", "rsa", "rd_values", "kd_values"
|
||||||
|
, "log10_or_mychisq", "neglog_pval_fisher", "af"
|
||||||
|
, LigDist_colname
|
||||||
, "duet_scaled"
|
, "duet_scaled"
|
||||||
, "ligand_distance"
|
, "foldx_scaled"
|
||||||
, "asa"
|
, "deepddg_scaled"
|
||||||
, "rsa"
|
, "mcsm_na_scaled"
|
||||||
, "rd_values"
|
, "ddg_dynamut_scaled"
|
||||||
, "kd_values")
|
, "ddg_dynamut2_scaled"
|
||||||
|
, "ddg_encom_scaled"
|
||||||
|
, "dds_encom_scaled"
|
||||||
|
, "ddg_sdm"
|
||||||
|
, "ddg_mcsm")
|
||||||
|
|
||||||
df_wf_ps = df_ps[, cols_to_select_ps]
|
, new = c("ASA", "RSA", "RD", "KD"
|
||||||
|
, "Log10 (OR)", "-Log (P)", "MAF"
|
||||||
|
, lig_dn
|
||||||
|
, duet_dn
|
||||||
|
, foldx_dn
|
||||||
|
, deepddg_dn
|
||||||
|
, mcsm_na_dn
|
||||||
|
, dynamut_dn
|
||||||
|
, dynamut2_dn
|
||||||
|
, encom_ddg_dn
|
||||||
|
, encom_dds_dn
|
||||||
|
, sdm_dn
|
||||||
|
, mcsm_dn)
|
||||||
|
)
|
||||||
|
|
||||||
pivot_cols_ps = cols_to_select_ps[1:5]; pivot_cols_ps
|
foo_cnames <- cbind(foo_cnames, colnames(comb_df_sl))
|
||||||
|
|
||||||
expected_rows_lf_ps = nrow(df_wf_ps) * (length(df_wf_ps) - length(pivot_cols_ps))
|
# some more pretty labels
|
||||||
expected_rows_lf_ps
|
table(comb_df_sl$mutation_info)
|
||||||
|
|
||||||
|
levels(comb_df_sl$mutation_info)[levels(comb_df_sl$mutation_info)==dr_muts_col] <- "DM"
|
||||||
|
levels(comb_df_sl$mutation_info)[levels(comb_df_sl$mutation_info)==other_muts_col] <- "OM"
|
||||||
|
|
||||||
|
table(comb_df_sl$mutation_info)
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
#======================
|
||||||
|
# Selecting dfs
|
||||||
|
# with appropriate cols
|
||||||
|
#=======================
|
||||||
|
static_cols_start = c("mutationinformation"
|
||||||
|
, "position"
|
||||||
|
, "mutation"
|
||||||
|
, "mutation_info")
|
||||||
|
|
||||||
|
static_cols_end = c(lig_dn
|
||||||
|
, "ASA"
|
||||||
|
, "RSA"
|
||||||
|
, "RD"
|
||||||
|
, "KD")
|
||||||
|
|
||||||
|
# ordering is important!
|
||||||
|
|
||||||
|
#########################################################################
|
||||||
|
#==============
|
||||||
|
# DUET: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_duet = c(static_cols_start, c("duet_outcome", duet_dn), static_cols_end)
|
||||||
|
wf_duet = comb_df_sl[, cols_to_select_duet]
|
||||||
|
|
||||||
|
#pivot_cols_ps = cols_to_select_ps[1:5]; pivot_cols_ps
|
||||||
|
pivot_cols_duet = cols_to_select_duet[1: (length(static_cols_start) + 1)]; pivot_cols_duet
|
||||||
|
|
||||||
|
expected_rows_lf = nrow(wf_duet) * (length(wf_duet) - length(pivot_cols_duet))
|
||||||
|
expected_rows_lf
|
||||||
|
|
||||||
# LF data: duet
|
# LF data: duet
|
||||||
df_lf_ps = gather(df_wf_ps, param_type, param_value, duet_scaled:kd_values, factor_key=TRUE)
|
lf_duet = gather(wf_duet
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(duet_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
if (nrow(df_lf_ps) == expected_rows_lf_ps){
|
if (nrow(lf_duet) == expected_rows_lf){
|
||||||
cat("PASS: long format data created for duet")
|
cat("\nPASS: long format data created for ", duet_dn)
|
||||||
}else{
|
}else{
|
||||||
cat("FAIL: long format data could not be created for duet")
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
exit()
|
quit()
|
||||||
}
|
}
|
||||||
|
|
||||||
str(df_wf_ps)
|
|
||||||
str(df_lf_ps)
|
|
||||||
|
|
||||||
# assign pretty labels: param_type
|
|
||||||
levels(df_lf_ps$param_type); table(df_lf_ps$param_type)
|
|
||||||
|
|
||||||
ligand_dist_colname = paste0("Distance to ligand (", angstroms_symbol, ")")
|
|
||||||
ligand_dist_colname
|
|
||||||
|
|
||||||
duet_stability_name = paste0(delta_symbol, delta_symbol, "G")
|
|
||||||
duet_stability_name
|
|
||||||
|
|
||||||
#levels(df_lf_ps$param_type)[levels(df_lf_ps$param_type)=="duet_scaled"] <- "Stability"
|
|
||||||
levels(df_lf_ps$param_type)[levels(df_lf_ps$param_type)=="duet_scaled"] <- duet_stability_name
|
|
||||||
#levels(df_lf_ps$param_type)[levels(df_lf_ps$param_type)=="ligand_distance"] <- "Ligand Distance"
|
|
||||||
levels(df_lf_ps$param_type)[levels(df_lf_ps$param_type)=="ligand_distance"] <- ligand_dist_colname
|
|
||||||
levels(df_lf_ps$param_type)[levels(df_lf_ps$param_type)=="asa"] <- "ASA"
|
|
||||||
levels(df_lf_ps$param_type)[levels(df_lf_ps$param_type)=="rsa"] <- "RSA"
|
|
||||||
levels(df_lf_ps$param_type)[levels(df_lf_ps$param_type)=="rd_values"] <- "RD"
|
|
||||||
levels(df_lf_ps$param_type)[levels(df_lf_ps$param_type)=="kd_values"] <- "KD"
|
|
||||||
# check
|
|
||||||
levels(df_lf_ps$param_type); table(df_lf_ps$param_type)
|
|
||||||
|
|
||||||
# assign pretty labels: mutation_info
|
|
||||||
levels(df_lf_ps$mutation_info); table(df_lf_ps$mutation_info)
|
|
||||||
sum(table(df_lf_ps$mutation_info)) == nrow(df_lf_ps)
|
|
||||||
|
|
||||||
levels(df_lf_ps$mutation_info)[levels(df_lf_ps$mutation_info)==dr_muts_col] <- "DM"
|
|
||||||
levels(df_lf_ps$mutation_info)[levels(df_lf_ps$mutation_info)==other_muts_col] <- "OM"
|
|
||||||
# check
|
|
||||||
levels(df_lf_ps$mutation_info); table(df_lf_ps$mutation_info)
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
#==============
|
||||||
|
# FoldX: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_foldx= c(static_cols_start, c("foldx_outcome", foldx_dn), static_cols_end)
|
||||||
|
wf_foldx = comb_df_sl[, cols_to_select_foldx]
|
||||||
|
|
||||||
#===========
|
pivot_cols_foldx = cols_to_select_foldx[1: (length(static_cols_start) + 1)]; pivot_cols_foldx
|
||||||
# LF data: LIG
|
|
||||||
#===========
|
|
||||||
# keep similar dtypes cols together
|
|
||||||
cols_to_select_lig = c("mutationinformation", "mutation", "position", "mutation_info"
|
|
||||||
, "ligand_outcome"
|
|
||||||
|
|
||||||
, "affinity_scaled"
|
expected_rows_lf = nrow(wf_foldx) * (length(wf_foldx) - length(pivot_cols_foldx))
|
||||||
#, "ligand_distance"
|
expected_rows_lf
|
||||||
, "asa"
|
|
||||||
, "rsa"
|
|
||||||
, "rd_values"
|
|
||||||
, "kd_values")
|
|
||||||
|
|
||||||
df_wf_lig = df_lig[, cols_to_select_lig]
|
# LF data: duet
|
||||||
|
print("TESTXXXXXXXXXXXXXXXXXXXXX---------------------->>>>")
|
||||||
|
lf_foldx <<- gather(wf_foldx
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(foldx_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
pivot_cols_lig = cols_to_select_lig[1:5]; pivot_cols_lig
|
if (nrow(lf_foldx) == expected_rows_lf){
|
||||||
|
cat("\nPASS: long format data created for ", foldx_dn)
|
||||||
expected_rows_lf_lig = nrow(df_wf_lig) * (length(df_wf_lig) - length(pivot_cols_lig))
|
|
||||||
expected_rows_lf_lig
|
|
||||||
|
|
||||||
# LF data: foldx
|
|
||||||
df_lf_lig = gather(df_wf_lig, param_type, param_value, affinity_scaled:kd_values, factor_key=TRUE)
|
|
||||||
|
|
||||||
if (nrow(df_lf_lig) == expected_rows_lf_lig){
|
|
||||||
cat("PASS: long format data created for foldx")
|
|
||||||
}else{
|
}else{
|
||||||
cat("FAIL: long format data could not be created for foldx")
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
exit()
|
quit()
|
||||||
}
|
}
|
||||||
|
|
||||||
# assign pretty labels: param_type
|
|
||||||
levels(df_lf_lig$param_type); table(df_lf_lig$param_type)
|
|
||||||
|
|
||||||
levels(df_lf_lig$param_type)[levels(df_lf_lig$param_type)=="affinity_scaled"] <- "Ligand Affinity"
|
|
||||||
#levels(df_lf_lig$param_type)[levels(df_lf_lig$param_type)=="ligand_distance"] <- "Ligand Distance"
|
|
||||||
levels(df_lf_lig$param_type)[levels(df_lf_lig$param_type)=="asa"] <- "ASA"
|
|
||||||
levels(df_lf_lig$param_type)[levels(df_lf_lig$param_type)=="rsa"] <- "RSA"
|
|
||||||
levels(df_lf_lig$param_type)[levels(df_lf_lig$param_type)=="rd_values"] <- "RD"
|
|
||||||
levels(df_lf_lig$param_type)[levels(df_lf_lig$param_type)=="kd_values"] <- "KD"
|
|
||||||
#check
|
|
||||||
levels(df_lf_lig$param_type); table(df_lf_lig$param_type)
|
|
||||||
|
|
||||||
# assign pretty labels: mutation_info
|
|
||||||
levels(df_lf_lig$mutation_info); table(df_lf_lig$mutation_info)
|
|
||||||
sum(table(df_lf_lig$mutation_info)) == nrow(df_lf_lig)
|
|
||||||
|
|
||||||
levels(df_lf_lig$mutation_info)[levels(df_lf_lig$mutation_info)==dr_muts_col] <- "DM"
|
|
||||||
levels(df_lf_lig$mutation_info)[levels(df_lf_lig$mutation_info)==other_muts_col] <- "OM"
|
|
||||||
# check
|
|
||||||
levels(df_lf_lig$mutation_info); table(df_lf_lig$mutation_info)
|
|
||||||
|
|
||||||
#############################################################################
|
|
||||||
#===========
|
|
||||||
# Data: foldx
|
|
||||||
#===========
|
|
||||||
# keep similar dtypes cols together
|
|
||||||
cols_to_select_foldx = c("mutationinformation", "mutation", "position", "mutation_info"
|
|
||||||
, "foldx_outcome"
|
|
||||||
|
|
||||||
, "foldx_scaled")
|
|
||||||
#, "ligand_distance"
|
|
||||||
#, "asa"
|
|
||||||
#, "rsa"
|
|
||||||
#, "rd_values"
|
|
||||||
#, "kd_values")
|
|
||||||
|
|
||||||
|
|
||||||
df_wf_foldx = df_ps[, cols_to_select_foldx]
|
|
||||||
|
|
||||||
pivot_cols_foldx = cols_to_select_foldx[1:5]; pivot_cols_foldx
|
|
||||||
|
|
||||||
expected_rows_lf_foldx = nrow(df_wf_foldx) * (length(df_wf_foldx) - length(pivot_cols_foldx))
|
|
||||||
expected_rows_lf_foldx
|
|
||||||
|
|
||||||
# LF data: foldx
|
|
||||||
df_lf_foldx = gather(df_wf_foldx, param_type, param_value, foldx_scaled, factor_key=TRUE)
|
|
||||||
|
|
||||||
if (nrow(df_lf_foldx) == expected_rows_lf_foldx){
|
|
||||||
cat("PASS: long format data created for foldx")
|
|
||||||
}else{
|
|
||||||
cat("FAIL: long format data could not be created for foldx")
|
|
||||||
exit()
|
|
||||||
}
|
|
||||||
|
|
||||||
foldx_stability_name = paste0(delta_symbol, delta_symbol, "G")
|
|
||||||
foldx_stability_name
|
|
||||||
|
|
||||||
# assign pretty labels: param type
|
|
||||||
levels(df_lf_foldx$param_type); table(df_lf_foldx$param_type)
|
|
||||||
|
|
||||||
#levels(df_lf_foldx$param_type)[levels(df_lf_foldx$param_type)=="foldx_scaled"] <- "Stability"
|
|
||||||
levels(df_lf_foldx$param_type)[levels(df_lf_foldx$param_type)=="foldx_scaled"] <- foldx_stability_name
|
|
||||||
#levels(df_lf_foldx$param_type)[levels(df_lf_foldx$param_type)=="ligand_distance"] <- "Ligand Distance"
|
|
||||||
#levels(df_lf_foldx$param_type)[levels(df_lf_foldx$param_type)=="asa"] <- "ASA"
|
|
||||||
#levels(df_lf_foldx$param_type)[levels(df_lf_foldx$param_type)=="rsa"] <- "RSA"
|
|
||||||
#levels(df_lf_foldx$param_type)[levels(df_lf_foldx$param_type)=="rd_values"] <- "RD"
|
|
||||||
#levels(df_lf_foldx$param_type)[levels(df_lf_foldx$param_type)=="kd_values"] <- "KD"
|
|
||||||
# check
|
|
||||||
levels(df_lf_foldx$param_type); table(df_lf_foldx$param_type)
|
|
||||||
|
|
||||||
# assign pretty labels: mutation_info
|
|
||||||
levels(df_lf_foldx$mutation_info); table(df_lf_foldx$mutation_info)
|
|
||||||
sum(table(df_lf_foldx$mutation_info)) == nrow(df_lf_foldx)
|
|
||||||
|
|
||||||
levels(df_lf_foldx$mutation_info)[levels(df_lf_foldx$mutation_info)==dr_muts_col] <- "DM"
|
|
||||||
levels(df_lf_foldx$mutation_info)[levels(df_lf_foldx$mutation_info)==other_muts_col] <- "OM"
|
|
||||||
# check
|
|
||||||
levels(df_lf_foldx$mutation_info); table(df_lf_foldx$mutation_info)
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
#==============
|
||||||
|
# Deepddg: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_deepddg = c(static_cols_start, c("deepddg_outcome", deepddg_dn), static_cols_end)
|
||||||
|
wf_deepddg = comb_df_sl[, cols_to_select_deepddg]
|
||||||
|
|
||||||
# clear excess variables
|
pivot_cols_deepddg = cols_to_select_deepddg[1: (length(static_cols_start) + 1)]; pivot_cols_deepddg
|
||||||
rm(cols_to_select_ps, cols_to_select_foldx, cols_to_select_lig
|
|
||||||
, pivot_cols_ps, pivot_cols_foldx, pivot_cols_lig
|
expected_rows_lf = nrow(wf_deepddg) * (length(wf_deepddg) - length(pivot_cols_deepddg))
|
||||||
, expected_rows_lf_ps, expected_rows_lf_foldx, expected_rows_lf_lig
|
expected_rows_lf
|
||||||
, my_max, my_min, na_count, na_count_df2, na_count_df3, dup_muts_nu
|
|
||||||
, c1, c2, n)
|
# LF data: duet
|
||||||
|
lf_deepddg = gather(wf_deepddg
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(deepddg_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
|
if (nrow(lf_deepddg) == expected_rows_lf){
|
||||||
|
cat("\nPASS: long format data created for ", deepddg_dn)
|
||||||
|
}else{
|
||||||
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
#==============
|
||||||
|
# mCSM-NA: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_mcsm_na = c(static_cols_start, c("mcsm_na_outcome", mcsm_na_dn), static_cols_end)
|
||||||
|
wf_mcsm_na = comb_df_sl[, cols_to_select_mcsm_na]
|
||||||
|
|
||||||
|
pivot_cols_mcsm_na = cols_to_select_mcsm_na[1: (length(static_cols_start) + 1)]; pivot_cols_mcsm_na
|
||||||
|
|
||||||
|
expected_rows_lf = nrow(wf_mcsm_na) * (length(wf_mcsm_na) - length(pivot_cols_mcsm_na))
|
||||||
|
expected_rows_lf
|
||||||
|
|
||||||
|
# LF data: duet
|
||||||
|
lf_mcsm_na = gather(wf_mcsm_na
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(mcsm_na_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
|
if (nrow(lf_mcsm_na) == expected_rows_lf){
|
||||||
|
cat("\nPASS: long format data created for ", mcsm_na_dn)
|
||||||
|
}else{
|
||||||
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
#==============
|
||||||
|
# Dynamut: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_dynamut = c(static_cols_start, c("ddg_dynamut_outcome", dynamut_dn), static_cols_end)
|
||||||
|
wf_dynamut = comb_df_sl[, cols_to_select_dynamut]
|
||||||
|
|
||||||
|
pivot_cols_dynamut = cols_to_select_dynamut[1: (length(static_cols_start) + 1)]; pivot_cols_dynamut
|
||||||
|
|
||||||
|
expected_rows_lf = nrow(wf_dynamut) * (length(wf_dynamut) - length(pivot_cols_dynamut))
|
||||||
|
expected_rows_lf
|
||||||
|
|
||||||
|
# LF data: duet
|
||||||
|
lf_dynamut = gather(wf_dynamut
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(dynamut_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
|
if (nrow(lf_dynamut) == expected_rows_lf){
|
||||||
|
cat("\nPASS: long format data created for ", dynamut_dn)
|
||||||
|
}else{
|
||||||
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
#==============
|
||||||
|
# Dynamut2: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_dynamut2 = c(static_cols_start, c("ddg_dynamut2_outcome", dynamut2_dn), static_cols_end)
|
||||||
|
|
||||||
|
wf_dynamut2 = comb_df_sl[, cols_to_select_dynamut2]
|
||||||
|
|
||||||
|
pivot_cols_dynamut2 = cols_to_select_dynamut2[1: (length(static_cols_start) + 1)]; pivot_cols_dynamut2
|
||||||
|
|
||||||
|
expected_rows_lf = nrow(wf_dynamut2) * (length(wf_dynamut2) - length(pivot_cols_dynamut2))
|
||||||
|
expected_rows_lf
|
||||||
|
|
||||||
|
# LF data: duet
|
||||||
|
lf_dynamut2 = gather(wf_dynamut2
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(dynamut2_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
|
if (nrow(lf_dynamut2) == expected_rows_lf){
|
||||||
|
cat("\nPASS: long format data created for ", dynamut2_dn)
|
||||||
|
}else{
|
||||||
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
#==============
|
||||||
|
# EnCOM ddg: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_encomddg = c(static_cols_start, c("ddg_encom_outcome", encom_ddg_dn), static_cols_end)
|
||||||
|
wf_encomddg = comb_df_sl[, cols_to_select_encomddg]
|
||||||
|
|
||||||
|
pivot_cols_encomddg = cols_to_select_encomddg[1: (length(static_cols_start) + 1)]; pivot_cols_encomddg
|
||||||
|
|
||||||
|
expected_rows_lf = nrow(wf_encomddg ) * (length(wf_encomddg ) - length(pivot_cols_encomddg))
|
||||||
|
expected_rows_lf
|
||||||
|
|
||||||
|
# LF data: encomddg
|
||||||
|
lf_encomddg = gather(wf_encomddg
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(encom_ddg_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
|
if (nrow(lf_encomddg) == expected_rows_lf){
|
||||||
|
cat("\nPASS: long format data created for ", encom_ddg_dn)
|
||||||
|
}else{
|
||||||
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
############################################################################
|
||||||
|
#==============
|
||||||
|
# EnCOM dds: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_encomdds = c(static_cols_start, c("dds_encom_outcome", encom_dds_dn), static_cols_end)
|
||||||
|
wf_encomdds = comb_df_sl[, cols_to_select_encomdds]
|
||||||
|
|
||||||
|
pivot_cols_encomdds = cols_to_select_encomdds[1: (length(static_cols_start) + 1)]; pivot_cols_encomdds
|
||||||
|
|
||||||
|
expected_rows_lf = nrow(wf_encomdds) * (length(wf_encomdds) - length(pivot_cols_encomdds))
|
||||||
|
expected_rows_lf
|
||||||
|
|
||||||
|
# LF data: encomddg
|
||||||
|
lf_encomdds = gather(wf_encomdds
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(encom_dds_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
|
if (nrow(lf_encomdds) == expected_rows_lf){
|
||||||
|
cat("\nPASS: long format data created for", encom_dds_dn)
|
||||||
|
}else{
|
||||||
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
#==============
|
||||||
|
# SDM: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_sdm = c(static_cols_start, c("ddg_sdm_outcome", sdm_dn), static_cols_end)
|
||||||
|
wf_sdm = comb_df_sl[, cols_to_select_sdm]
|
||||||
|
|
||||||
|
pivot_cols_sdm = cols_to_select_sdm[1: (length(static_cols_start) + 1)]; pivot_cols_sdm
|
||||||
|
|
||||||
|
expected_rows_lf = nrow(wf_sdm) * (length(wf_sdm) - length(pivot_cols_sdm))
|
||||||
|
expected_rows_lf
|
||||||
|
|
||||||
|
# LF data: encomddg
|
||||||
|
lf_sdm = gather(wf_sdm
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(sdm_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
|
if (nrow(lf_sdm) == expected_rows_lf){
|
||||||
|
cat("\nPASS: long format data created for", sdm_dn)
|
||||||
|
}else{
|
||||||
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
|
||||||
|
############################################################################
|
||||||
|
#==============
|
||||||
|
# mCSM: LF
|
||||||
|
#==============
|
||||||
|
cols_to_select_mcsm = c(static_cols_start, c("ddg_mcsm_outcome", mcsm_dn), static_cols_end)
|
||||||
|
wf_mcsm = comb_df_sl[, cols_to_select_mcsm]
|
||||||
|
|
||||||
|
pivot_cols_mcsm = cols_to_select_mcsm[1: (length(static_cols_start) + 1)]; pivot_cols_mcsm
|
||||||
|
|
||||||
|
expected_rows_lf = nrow(wf_mcsm) * (length(wf_mcsm) - length(pivot_cols_mcsm))
|
||||||
|
expected_rows_lf
|
||||||
|
|
||||||
|
# LF data: encomddg
|
||||||
|
lf_mcsm = gather(wf_mcsm
|
||||||
|
, key = param_type
|
||||||
|
, value = param_value
|
||||||
|
, all_of(mcsm_dn):tail(static_cols_end,1)
|
||||||
|
, factor_key = TRUE)
|
||||||
|
|
||||||
|
if (nrow(lf_mcsm) == expected_rows_lf){
|
||||||
|
cat("\nPASS: long format data created for", mcsm_dn)
|
||||||
|
}else{
|
||||||
|
cat("\nFAIL: long format data could not be created for duet")
|
||||||
|
quit()
|
||||||
|
}
|
||||||
|
############################################################################
|
||||||
|
# # clear excess variables
|
||||||
|
# rm(all_plot_dfs
|
||||||
|
# , cols_dynamut2_df
|
||||||
|
# , cols_mcsm_df
|
||||||
|
# , cols_mcsm_na_df
|
||||||
|
# , comb_df
|
||||||
|
# , corr_data_ps
|
||||||
|
# , corr_ps_df3
|
||||||
|
# , df_lf_ps
|
||||||
|
# , foo
|
||||||
|
# , foo_cnames
|
||||||
|
# , gene_metadata
|
||||||
|
# , logo_data
|
||||||
|
# , logo_data_or_mult
|
||||||
|
# , logo_data_plot
|
||||||
|
# , logo_data_plot_logor
|
||||||
|
# , logo_data_plot_or
|
||||||
|
# , my_data_snp
|
||||||
|
# , my_df
|
||||||
|
# , my_df_u
|
||||||
|
# , ols_mcsm_df
|
||||||
|
# , other_muts
|
||||||
|
# , pd_df
|
||||||
|
# , subcols_df_ps
|
||||||
|
# , tab_mt
|
||||||
|
# , wide_df_logor
|
||||||
|
# , wide_df_logor_m
|
||||||
|
# , wide_df_or
|
||||||
|
# , wide_df_or_mult
|
||||||
|
# , wt)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# rm(c3, c4, check1
|
||||||
|
# , cols_check
|
||||||
|
# , cols_to_select
|
||||||
|
# , cols_to_select_deepddg
|
||||||
|
# , cols_to_select_duet
|
||||||
|
# , cols_to_select_dynamut
|
||||||
|
# , cols_to_select_dynamut2
|
||||||
|
# , cols_to_select_encomddg
|
||||||
|
# , cols_to_select_encomdds
|
||||||
|
# , cols_to_select_mcsm
|
||||||
|
# , cols_to_select_mcsm_na
|
||||||
|
# , cols_to_select_sdm)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue