This commit is contained in:
Tanushree Tunstall 2022-08-24 16:52:11 +01:00
parent e4e8bd7278
commit 3b77b4b611
2 changed files with 28 additions and 36 deletions

View file

@ -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)
}

View file

@ -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)
@ -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)))
@ -255,40 +264,23 @@ wideP_consurf3 <- function(plot_df
out = g1
# x-axis: geom_tiles ~ active sites and others
if(annotate_active_sites){
aligned = align_plots(out,position_annotation(plot_df))
# x-axis: geom_tiles ~ active sites and others
if(annotate_active_sites){
#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)