AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

This commit is contained in:
Tanushree Tunstall 2022-08-17 18:42:15 +01:00
parent cd9b1ad245
commit c9d7ea9fad
10 changed files with 208 additions and 128 deletions

View file

@ -3,6 +3,7 @@
# This plots position tiles for the (up to) three ligands as well as drug
position_annotation=function(plot_df,
bg="transparent",
reorder_position = FALSE, # enable to reorder according to plot_df$pos_count
aa_pos_drug=1:100,
active_aa_pos=1:100,
aa_pos_lig1=1:100,
@ -47,65 +48,112 @@ position_annotation=function(plot_df,
plot_df$col_bg3 = ifelse(plot_df[["position"]]%in%aa_pos_lig3
, "purple", plot_df$col_bg3)
# the call to generate_distance_colour_map should probably be
# wherever the outer DF is built, and not here.
plot_df = generate_distance_colour_map(plot_df, debug=TRUE)
heat_bar = ggplot(plot_df,
aes(x=factor(position)) # THIS STUPID FUCKING FACTOR THING
) +
geom_tile(aes(y=0),
fill=plot_df$ligD_colours) +
heat_bar = ggplot(plot_df) + # THIS STUPID FUCKING FACTOR THING
# scale_x_discrete("Position", labels=factor(plot_df$position)) +
theme_nothing() +
theme(#axis.text.x = element_text(angle = 90, size = 6),
title = element_blank()
) + # enable for alignment debug
labs(x = NULL, y = NULL) #end of distance-heat-bar
#NULL,
pos_tiles = ggplot(plot_df,
aes(x=factor(position), # THIS STUPID FUCKING FACTOR THING
)
) +
# geom_tile(aes(y = 0, fill = col_aa, colour = col_aa)
# ) +
geom_tile(aes(y = 1, fill = bg_all, colour = bg_all)
) +
geom_tile(aes(y = 2, fill = col_bg1, colour = col_bg1)
) +
geom_tile(aes(y = 3, fill = col_bg2, colour = col_bg2)
) +
geom_tile(aes(y = 4, fill = col_bg3, colour = col_bg3)
) +
) + # enable for alignment debug
labs(x = NULL, y = NULL) +
#scale_x_discrete("Position", labels=factor(plot_df$position)) +
scale_color_manual(values = c(
"brown"="brown",
"green"="#00ff00",
"transparent"="transparent",
"slategrey"="#2f4f4f",
"navyblue"="#000080",
"purple"="#a020f0"
),
#expand=c(0,0)
) +
scale_fill_manual(values = c(
"brown"="brown",
"green"="#00ff00",
"transparent"="transparent",
"slategrey"="#2f4f4f",
"navyblue"="#000080",
"purple"="#a020f0"
),
#expand=c(0,0)
) +
theme_nothing() +
theme(plot.background = element_rect(fill = bg, colour=NA),
#plot.margin = margin(t=0,b=0),
panel.background = element_rect(fill = bg, colour=NA),
legend.position = "none"
) +
labs(x = NULL, y= NULL)
heat_legend=get_legend(heat_bar)
# if reorder_position is turned on then we need to reorder 'x'
# according to the pos_count column (creating this column is
# left as a fun exercise to whoever reads this next)
if(reorder_position) {
geom_tile(aes(y=0, x=reorder(position,-pos_count)),
fill=plot_df$ligD_colours)
} else {
geom_tile(aes(y=0, x=factor(position)),
fill=plot_df$ligD_colours)
}
#end of distance-heat-bar
#NULL,
if(reorder_position) {
pos_tiles = ggplot(plot_df) +
#scale_x_discrete("Position", labels=factor(plot_df$position)) +
scale_color_manual(values = c(
"brown"="brown",
"green"="#00ff00",
"transparent"="transparent",
"slategrey"="#2f4f4f",
"navyblue"="#000080",
"purple"="#a020f0"
),
#expand=c(0,0)
) +
scale_fill_manual(values = c(
"brown"="brown",
"green"="#00ff00",
"transparent"="transparent",
"slategrey"="#2f4f4f",
"navyblue"="#000080",
"purple"="#a020f0"
),
#expand=c(0,0)
) +
theme_nothing() +
theme(plot.background = element_rect(fill = bg, colour=NA),
#plot.margin = margin(t=0,b=0),
panel.background = element_rect(fill = bg, colour=NA),
legend.position = "none"
) +
labs(x = NULL, y= NULL) +
geom_tile(aes(y = 1,x=reorder(position,-pos_count), fill = bg_all, colour = bg_all)
) +
geom_tile(aes(y = 2, x=reorder(position,-pos_count), fill = col_bg1, colour = col_bg1)
) +
geom_tile(aes(y = 3, x=reorder(position,-pos_count), fill = col_bg2, colour = col_bg2)
) +
geom_tile(aes(y = 4, x=reorder(position,-pos_count), fill = col_bg3, colour = col_bg3)
)
} else {
pos_tiles = ggplot(plot_df) +
#scale_x_discrete("Position", labels=factor(plot_df$position)) +
scale_color_manual(values = c(
"brown"="brown",
"green"="#00ff00",
"transparent"="transparent",
"slategrey"="#2f4f4f",
"navyblue"="#000080",
"purple"="#a020f0"
),
#expand=c(0,0)
) +
scale_fill_manual(values = c(
"brown"="brown",
"green"="#00ff00",
"transparent"="transparent",
"slategrey"="#2f4f4f",
"navyblue"="#000080",
"purple"="#a020f0"
),
#expand=c(0,0)
) +
theme_nothing() +
theme(plot.background = element_rect(fill = bg, colour=NA),
#plot.margin = margin(t=0,b=0),
panel.background = element_rect(fill = bg, colour=NA),
legend.position = "none"
) +
labs(x = NULL, y= NULL) +
geom_tile(aes(y = 1, x=factor(position), fill = bg_all, colour = bg_all)
) +
geom_tile(aes(y = 2, x=factor(position), fill = col_bg1, colour = col_bg1)
) +
geom_tile(aes(y = 3, x=factor(position), fill = col_bg2, colour = col_bg2)
) +
geom_tile(aes(y = 4, x=factor(position), fill = col_bg3, colour = col_bg3)
)
}
# tile thingies end
heat_legend=get_legend(heat_bar)
out_plot=cowplot::plot_grid(
heat_bar,
NULL,