From 3b77b4b611bf2a31f5cf32f078a16d1ffc2b77d6 Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Wed, 24 Aug 2022 16:52:11 +0100 Subject: [PATCH] stuff --- scripts/functions/lf_bp.R | 4 +- scripts/functions/wideP_consurf3.R | 60 +++++++++++++----------------- 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/scripts/functions/lf_bp.R b/scripts/functions/lf_bp.R index 48b2162..4dcf365 100644 --- a/scripts/functions/lf_bp.R +++ b/scripts/functions/lf_bp.R @@ -73,7 +73,7 @@ lf_bp <- function(lf_df = lf_duet ) ) ) - ) + ggplot2::scale_color_manual(values = consurf_bp_colours) + ) + ggplot2::scale_color_manual(values = consurf_colours) } else { #Legend=factor(eval(parse(text = colour_categ))) @@ -99,7 +99,7 @@ lf_bp <- function(lf_df = lf_duet ) #, aes(colour = Legend) ) + - ggplot2::scale_color_manual(values = consurf_bp_colours) + ggplot2::scale_color_manual(values = consurf_colours) } diff --git a/scripts/functions/wideP_consurf3.R b/scripts/functions/wideP_consurf3.R index 4053591..99eda2a 100644 --- a/scripts/functions/wideP_consurf3.R +++ b/scripts/functions/wideP_consurf3.R @@ -28,8 +28,8 @@ wideP_consurf3 <- function(plot_df , "1": "Variable" , "2", "3", "4", "5", "6", "7", "8" , "9": "Conserved") - , panel_col = "grey" - , panel_col_fill = "grey" + , panel_col = "white" + , panel_col_fill = "white" # axes title and label sizes , x_axls = 12 # x-axis label size @@ -70,6 +70,15 @@ wideP_consurf3 <- function(plot_df , build_plot_df=FALSE , debug=FALSE ){ + anno_bar = 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 + ) if(missing(point_colours)){ temp_cols = colorRampPalette(c("seagreen", "sienna3"))(30) @@ -171,7 +180,7 @@ wideP_consurf3 <- function(plot_df , y = yvar_colname , colour = sprintf("factor(%s)", yvar_colourN_colname) )) - + #"if SPECIAL do SPECIAL THING, otherwise do NORMAL THING" if (plot_type == "bar"){ @@ -230,9 +239,9 @@ wideP_consurf3 <- function(plot_df , unit = unit_margin))+ #guides(colour = guide_legend(title = "ConsurfXXXX")) + labs(x = NULL, y = NULL) - # labs(title = ptitle - # , x = xlab - # , y = ylab) + # labs(title = ptitle + # , x = xlab + # , y = ylab) #------------------ #Extract legend1 @@ -242,7 +251,7 @@ wideP_consurf3 <- function(plot_df , aes_string( x = sprintf("factor(%s)" , xvar_colname)) - ) + ) g1_leg = g1_leg + geom_bar(); g1_leg g1_leg = g1_leg + geom_bar(aes_string(fill = sprintf("factor(%s)" , yvar_colourN_colname))) @@ -254,41 +263,24 @@ wideP_consurf3 <- function(plot_df out = g1 + - # x-axis: geom_tiles ~ active sites and others + # x-axis: geom_tiles ~ active sites and others if(annotate_active_sites){ - aligned = align_plots(out,position_annotation(plot_df)) - + #aligned = align_plots(out,position_annotation(plot_df)) out=cowplot::plot_grid( out, NULL, - ggplot(plot_df, - aes(x=factor(position), # THIS STUPID FUCKING FACTOR THING - ) - ) + - geom_tile(aes(y=0), - fill=plot_df$ligD_colours) + - scale_x_discrete("Position", labels=factor(plot_df$position)) + - theme_nothing() + - theme(plot.background = element_rect(fill = panel_col, colour=NA), - 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, - 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 - ), + anno_bar, ncol=1, align='v', - axis='lr', - rel_heights = c(10,0,1,-0.1,1) + #axis='lr', + rel_heights = c(10,-0.1,1) ) -} + } + #### add the legends to the output #### + # ...which legends depend on whether the heat bar and position tiles are included if (annotate_ligand_distance){ cat('\nOutput: Plot + distance heat-bar + other stuff') legs = cowplot::plot_grid(legend1 @@ -314,4 +306,4 @@ wideP_consurf3 <- function(plot_df return(out2) } -#wideP_consurf3(small_df3, point_colours = consurf_bp_colours) +#wideP_consurf3(small_df3, point_colours = consurf_colours)