saving other_plots.R
This commit is contained in:
parent
c9040cad21
commit
14182df12f
5 changed files with 227 additions and 241 deletions
|
@ -33,7 +33,7 @@ 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) #335, 15
|
||||
#sanity check
|
||||
# sanity check
|
||||
my_min = min(df_ps$foldx_scaled); my_min
|
||||
my_max = max(df_ps$foldx_scaled); my_max
|
||||
|
||||
|
@ -50,7 +50,6 @@ if ( all(c1 == c2) ){
|
|||
exit()
|
||||
}
|
||||
|
||||
|
||||
# name tidying
|
||||
df_ps$mutation_info = as.factor(df_ps$mutation_info)
|
||||
df_ps$duet_outcome = as.factor(df_ps$duet_outcome)
|
||||
|
@ -60,6 +59,21 @@ df_ps$ligand_outcome = as.factor(df_ps$ligand_outcome)
|
|||
# check
|
||||
table(df_ps$mutation_info)
|
||||
|
||||
# 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_names = unique(dr_muts$mutation)
|
||||
|
||||
other_muts = df_ps[df_ps$mutation_info == other_muts_col,]
|
||||
other_muts_names = unique(other_muts$mutation)
|
||||
|
||||
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) ){
|
||||
cat("PASS: dr and other muts are indeed unique")
|
||||
}else{
|
||||
cat("FAIL: dr adn others muts are NOT unique!")
|
||||
quit()
|
||||
}
|
||||
|
||||
#%%%%%%%%%%%%%%%%%%%
|
||||
# REASSIGNMENT: LIG
|
||||
#%%%%%%%%%%%%%%%%%%%%
|
||||
|
@ -133,78 +147,25 @@ levels(df_lf_ps$mutation_info)[levels(df_lf_ps$mutation_info)==other_muts_col] <
|
|||
levels(df_lf_ps$mutation_info); table(df_lf_ps$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:kd_values, 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()
|
||||
}
|
||||
|
||||
# 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"] <- "Foldx"
|
||||
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)
|
||||
|
||||
############################################################################
|
||||
#===========
|
||||
# LF data: LIG
|
||||
#===========
|
||||
# keep similar dtypes cols together
|
||||
cols_to_select_lig = c("mutationinformation", "mutation", "position", "mutation_info"
|
||||
, "ligand_outcome"
|
||||
|
||||
, "affinity_scaled"
|
||||
, "ligand_distance"
|
||||
, "asa"
|
||||
, "rsa"
|
||||
, "rd_values"
|
||||
, "kd_values")
|
||||
, "ligand_outcome"
|
||||
|
||||
, "affinity_scaled"
|
||||
, "ligand_distance"
|
||||
, "asa"
|
||||
, "rsa"
|
||||
, "rd_values"
|
||||
, "kd_values")
|
||||
|
||||
df_wf_lig = df_lig[, cols_to_select_lig]
|
||||
|
||||
pivot_cols_lig = cols_to_select_lig[1:5]; pivot_cols_lig
|
||||
|
||||
|
||||
expected_rows_lf_lig = nrow(df_wf_lig) * (length(df_wf_lig) - length(pivot_cols_lig))
|
||||
expected_rows_lf_lig
|
||||
|
||||
|
@ -239,7 +200,61 @@ levels(df_lf_lig$mutation_info)[levels(df_lf_lig$mutation_info)==other_muts_col]
|
|||
# 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()
|
||||
}
|
||||
|
||||
# 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"] <- "Foldx"
|
||||
#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)
|
||||
|
||||
############################################################################
|
||||
|
||||
# clear excess variables
|
||||
rm(cols_to_select_ps, cols_to_select_foldx, cols_to_select_lig
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue