config: add tile stuff for all targets. Other functions: many rewrites!

This commit is contained in:
Tanushree Tunstall 2022-08-15 16:29:38 +01:00
parent a3e5283a9b
commit 0cc7a8fcae
11 changed files with 163 additions and 200 deletions

View file

@ -49,77 +49,78 @@ position_annotation=function(plot_df,
plot_df = generate_distance_colour_map(plot_df, debug=TRUE)
cowplot::plot_grid(
ggplot(plot_df,
aes(x=factor(position), # THIS STUPID FUCKING FACTOR THING
)
heat_bar = 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(#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=0),
fill=plot_df$ligD_colours) +
#scale_x_discrete("Position", labels=factor(plot_df$position)) +
#theme_nothing() +
theme(plot.background = element_rect(fill = "transparent", colour=NA),
plot.margin = margin(t=0,b=0),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.text.y = element_blank(),
panel.grid = element_blank(),
panel.background = element_rect(fill = "transparent", colour=NA),
) +
labs(x = NULL, y = NULL), #end of distance-heat-bar
#NULL,
ggplot(plot_df,
aes(x=factor(position), # THIS STUPID FUCKING FACTOR THING
#reorder(ligand_distance)
)
geom_tile(aes(y = 2, fill = col_bg1, colour = col_bg1)
) +
# 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)
) +
#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)
) +
#scale_x_continuous(expand=c(0,0)) +
#scale_y_continuous(expand=c(0,0)) +
theme_nothing() +
theme(plot.background = element_rect(fill = bg, colour=NA),
plot.margin = margin(t=0,b=0)) +
labs(x = NULL, y = NULL),
geom_tile(aes(y = 3, fill = col_bg2, colour = col_bg2)
) +
geom_tile(aes(y = 4, fill = col_bg3, colour = col_bg3)
) +
#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)
out_plot=cowplot::plot_grid(
heat_bar,
NULL,
pos_tiles,
ncol=1,
align='v',
rel_heights = c(1,
#-0.1,
1)
-0.1,
2)
)
return(out_plot)
}
# position_annotation(merged_df3,
# position_annotation(small_df3,
# aa_pos_drug=aa_pos_drug,
# active_aa_pos=active_aa_pos,
# aa_pos_lig1=aa_pos_lig1,