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

@ -60,17 +60,9 @@ bp_stability_hmap <- function(plot_df = merged_df3
)
{
################################################
# Custom 2: x-axis geom tiles ~ lig distance
################################################
#=========================
# Build data with colours
# ~ ligand distance
#=========================
# plot_df = generate_distance_colour_map(plot_df, debug=TRUE)
# order the df by position and ensure it is a factor
# order the df by position and ensure it is a factor
plot_df = plot_df[order(plot_df[[xvar_colname]]), ]
plot_df[[xvar_colname]] = factor(plot_df[[xvar_colname]])
@ -79,26 +71,30 @@ bp_stability_hmap <- function(plot_df = merged_df3
# stability values isolated to help with generating column called: 'group'
my_grp = plot_df[[stability_colname]]
cat( "\nLength of nsSNPs:", length(my_grp)
, "\nLength of unique values for nsSNPs:", length(unique(my_grp)) )
# cat( "\nLength of nsSNPs:", length(my_grp)
# , "\nLength of unique values for nsSNPs:", length(unique(my_grp)) )
#
# Add col: 'group'
plot_df$group = paste0(plot_df[[stability_outcome_colname]], "_", my_grp, sep = "")
# check unique values in normalised data
cat("\nNo. of unique values in", stability_colname, "no rounding:"
, length(unique(plot_df[[stability_colname]])))
# cat("\nNo. of unique values in", stability_colname, "no rounding:"
# , length(unique(plot_df[[stability_colname]])))
# Call the function to create the palette based on the group defined above
#subcols_ps
subcols_bp_hmap = ColourPalleteMulti(plot_df, stability_outcome_colname, stability_colname)
cat("\nNo. of sub colours generated:", length(subcols_bp_hmap))
anno_bar=position_annotation(plot_df,
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
)
#-------------------------------
# Generate the subcols barplot
#-------------------------------
cowplot::plot_grid(
ggplot(plot_df, aes_string(x = xvar_colname
# , ordered = T)
@ -111,7 +107,8 @@ bp_stability_hmap <- function(plot_df = merged_df3
# scale_x_discrete("Position", labels=factor(plot_df$position)) +
theme(
axis.text.x = element_text(size = my_xaxls
panel.grid = element_line(color="lightgrey", size=0.125)
, axis.text.x = element_text(size = my_xaxls
, angle = 90
, hjust = 1
, vjust = 0.4)
@ -128,25 +125,17 @@ bp_stability_hmap <- function(plot_df = merged_df3
# , panel.grid = element_blank()
, panel.background = element_rect(fill = "transparent", colour=NA)
) +
labs(title = p_title
, x = my_xlab
, y = my_ylab),
NULL,
position_annotation(plot_df,
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,
#generate_distance_legend(plot_df),
ncol = 1,
align = "v",
rel_heights = c(10,-0.1,1)
rel_heights = c(6,-0.1,1)
#rel_widths = c(9/10, 0.4/10)
)
}
#bp_stability_hmap(merged_df3)
# bp_stability_hmap(small_df3)