This commit is contained in:
Tanushree Tunstall 2022-08-14 12:17:36 +01:00
parent c09d7530c9
commit 6f354ab390
10 changed files with 833 additions and 285 deletions

View file

@ -13,12 +13,6 @@
# input args
#==========================================================
wideP_consurf3 <- function(plot_df
, aa_pos_drug = NULL
, aa_pos_lig1 = NULL
, aa_pos_lig2 = NULL
, aa_pos_lig3 = NULL
, active_aa_pos = NULL
, xvar_colname = "position"
, yvar_colname = "consurf_score"
, yvar_colourN_colname = "consurf_colour_rev" # num from 0-1
@ -65,26 +59,13 @@ wideP_consurf3 <- function(plot_df
, annotate_ligand_distance = T
, leg_title2 = "Ligand Distance"
, lig_dist_colname = LigDist_colname # from globals
, lig_dist_colours = c("green", "yellow", "orange", "red")
, lig_dist_colours = c("tan", "black")
, tpos0 = 0 # 0 is a magic number that does my sensible default
, tW0 = 1
, tH0 = 0.3
# Custom 3: x-axis: geom tiles ~ active sites and ligand
, annotate_active_sites = T
, drug_aa_colour = "purple"
, active_aa_colour = "brown"
, aa_colour_lig1 = "blue"
, tpos1 = 0
, aa_colour_lig2 = "cyan"
, tpos2 = 0
, aa_colour_lig3 = "cornflowerblue"
, tpos3 = 0
, default_gt_clr = "white"
, build_plot_df=FALSE
, debug=FALSE
@ -174,68 +155,6 @@ wideP_consurf3 <- function(plot_df
, ligD_cols = plot_df$ligD_colours))
}
###############################################
# Custom 3: x-axis geom tiles ~ active sites
################################################
#==========================
# Build Data with colours
# ~ on active sites
#==========================
aa_colour_colname = "bg_all"
aa_colour_colname1 = "col_bg1"
aa_colour_colname2 = "col_bg2"
aa_colour_colname3 = "col_bg3"
if (build_plot_df) {
if(annotate_active_sites) {
cat("\nAnnotation for xvar requested. Building colours for annotation...")
#--------------------------------------------------
# column colour 0: Active site + drug binding sites
#--------------------------------------------------
plot_df[[aa_colour_colname]] = ifelse(plot_df[[xvar_colname]]%in%aa_pos_drug
, drug_aa_colour
, ifelse(plot_df[[xvar_colname]]%in%active_aa_pos
, active_aa_colour, default_gt_clr ))
plot_df[[aa_colour_colname]]
cat("\nColumn created 'bg_all':", length(plot_df[[aa_colour_colname]]))
#------------------------------------------------
# column colour 1: Ligand 1 + drug binding sites
#------------------------------------------------
cat("\nAssigning colours to drug binding and ligand-1 binding residues")
plot_df[[aa_colour_colname1]] = plot_df[[aa_colour_colname]]
plot_df[[aa_colour_colname1]] = ifelse(plot_df[[xvar_colname]]%in%aa_pos_lig1
, aa_colour_lig1, plot_df[[aa_colour_colname]])
#------------------------------------------------
# column colour 2: Ligand 2
#------------------------------------------------
plot_df[[aa_colour_colname2]] = plot_df[[aa_colour_colname1]]
plot_df[[aa_colour_colname2]] = ifelse(plot_df[[xvar_colname]]%in%aa_pos_lig2
, aa_colour_lig2, plot_df[[aa_colour_colname1]])
#------------------------------------------------
# column colour 3: Ligand 3
#------------------------------------------------
plot_df[[aa_colour_colname3]] = plot_df[[aa_colour_colname2]]
plot_df[[aa_colour_colname3]] = ifelse(plot_df[[xvar_colname]]%in%aa_pos_lig3
, aa_colour_lig3, plot_df[[aa_colour_colname2]])
}
} else {
# set these to the string "DUMMY" so that the build-up-the-tiles bit works
aa_pos_drug = "DUMMY"
aa_pos_lig1 = "DUMMY"
active_aa_pos = "DUMMY"
if (aa_colour_colname2 %in% colnames(merged_df3)) {
aa_pos_lig2 = "DUMMY"
if (aa_colour_colname3 %in% colnames(merged_df3)) {
aa_pos_lig2 = "DUMMY"
}
}
}
###################
# start plot
###################
@ -355,7 +274,14 @@ wideP_consurf3 <- function(plot_df
plot.margin = margin(t=0,b=0)) +
labs(x = NULL, y = NULL), #end of distance-heat-bar
NULL,
position_annotation(plot_df, bg = panel_col),
position_annotation(plot_df,
bg = panel_col,
aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3
),
ncol=1,
align='v',
axis='lr',