bugfixes
This commit is contained in:
parent
a405cd8035
commit
1c616eeb71
7 changed files with 77 additions and 51 deletions
|
@ -47,7 +47,7 @@ bp_stability_hmap <- function(plot_df = merged_df3
|
|||
my_yaxts = 10, # y-axis text size
|
||||
my_pts = 10 # plot-title size
|
||||
, my_xlab = "Position"
|
||||
, my_ylab = "No. of SAVs"
|
||||
, my_ylab = ""
|
||||
|
||||
# Custom 2: x-axis: geom tiles ~ lig distance
|
||||
#, A_xvar_lig = T
|
||||
|
|
|
@ -13,7 +13,8 @@ position_annotation=function(plot_df,
|
|||
drug_colour='green',
|
||||
lig1_colour='slategrey',
|
||||
lig2_colour='navyblue',
|
||||
lig3_colour='purple'
|
||||
lig3_colour='purple',
|
||||
x_label=NULL
|
||||
)
|
||||
{
|
||||
x_ats = 12
|
||||
|
@ -107,9 +108,9 @@ position_annotation=function(plot_df,
|
|||
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"
|
||||
legend.position = "none", axis.title.x = element_text(size = 8)
|
||||
) +
|
||||
labs(x = NULL, y= NULL) +
|
||||
labs(x = x_label, 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)
|
||||
|
@ -146,9 +147,9 @@ position_annotation=function(plot_df,
|
|||
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"
|
||||
legend.position = "none", axis.title.x = element_text(size = 8)
|
||||
) +
|
||||
labs(x = NULL, y= NULL) +
|
||||
labs(x = x_label, 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)
|
||||
|
|
|
@ -166,7 +166,7 @@ print(paste0("Plotting LOW Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_low = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab="",
|
||||
y_lab="SAV Diversity",
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -195,7 +195,7 @@ logo_or_low = LogoPlotCustomH(
|
|||
lig3_colour = tile_map$tile_colour[4]
|
||||
)
|
||||
|
||||
stability_low = stab()+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
stability_low = stab()+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
|
||||
# MID
|
||||
|
@ -205,7 +205,7 @@ print(paste0("Plotting MID Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_centre = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab = "",
|
||||
y_lab = "SAV Diversity",
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -231,7 +231,7 @@ logo_or_centre = LogoPlotCustomH(
|
|||
lig3_colour = tile_map$tile_colour[4]
|
||||
)
|
||||
|
||||
stability_centre = stab(my_ylab="SAV Count")
|
||||
stability_centre = stab()
|
||||
|
||||
# HIGH
|
||||
small_df3 = merged_df3[merged_df3['position'] > centre,]
|
||||
|
@ -241,7 +241,7 @@ print(paste0("Plotting HIGH Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_high = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab="" ,
|
||||
y_lab="SAV Diversity" ,
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -251,7 +251,7 @@ logo_p_snps_high = LogoPlotSnps(
|
|||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
logo_or_high = LogoPlotCustomH(
|
||||
small_df3,
|
||||
|
@ -267,10 +267,10 @@ logo_or_high = LogoPlotCustomH(
|
|||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
|
||||
stability_high = stab()+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
stability_high = stab()+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
#### "sorted" stability plots ####
|
||||
|
||||
# do stability plots for later assembly
|
||||
|
@ -292,9 +292,10 @@ stability_high_reorder = bp_stability_hmap(
|
|||
drug_colour = tile_map$tile_colour[1],
|
||||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
lig3_colour = tile_map$tile_colour[4],
|
||||
x_label="Wild-Type Position"
|
||||
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)
|
||||
stability_centre_reorder = bp_stability_hmap(
|
||||
snpcount_low_high_df,
|
||||
reorder_position = T,
|
||||
|
|
|
@ -12,6 +12,7 @@ source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R")
|
|||
|
||||
#outdir="/home/pub/Work/LSHTM/Thesis_Plots/"
|
||||
outdir="~/git/Writing/thesis/tex/images-corrected/embb/"
|
||||
#outdir="~/tmp/embb/"
|
||||
|
||||
# add "pos_count" position count column
|
||||
merged_df3=merged_df3 %>% dplyr::add_count(position)
|
||||
|
@ -83,8 +84,9 @@ stability_low = bp_stability_hmap(snpcount_low_low_df,
|
|||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
aa_pos_lig2=aa_pos_lig2,
|
||||
aa_pos_lig3=aa_pos_lig3
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
aa_pos_lig3=aa_pos_lig3,
|
||||
x_label="Wild-Type Position"
|
||||
)
|
||||
|
||||
low=round(max(merged_df3$position)/3)
|
||||
centre=low*2
|
||||
|
@ -175,7 +177,7 @@ print(paste0("Plotting LOW Rows: ", nrow(small_df3)))
|
|||
|
||||
|
||||
logo_p_snps_low = LogoPlotSnps(mutable_df3,
|
||||
y_lab="",
|
||||
y_lab="SAV Diversity",
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -207,13 +209,13 @@ logo_p_snps_centre = LogoPlotSnps(
|
|||
aa_pos_lig1=aa_pos_lig1,
|
||||
aa_pos_lig2=aa_pos_lig2,
|
||||
aa_pos_lig3=aa_pos_lig3,
|
||||
y_lab = "SAV Count"
|
||||
y_lab = "SAV Diversity"
|
||||
)
|
||||
|
||||
logo_or_centre = LogoPlotCustomH(small_df3,
|
||||
y_axis_increment=2,
|
||||
y_lab = "Log(10) Odds Ratio",
|
||||
y_axis_log = TRUE,
|
||||
y_axis_increment=10,
|
||||
y_lab = "Odds Ratio",
|
||||
y_axis_log = FALSE,
|
||||
rm_empty_y=T,
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
|
@ -229,14 +231,14 @@ print(paste0("Plotting HIGH Rows: ", nrow(small_df3)))
|
|||
|
||||
|
||||
logo_p_snps_high = LogoPlotSnps(mutable_df3,
|
||||
y_lab="",
|
||||
y_lab="SAV Diversity",
|
||||
x_lab = "Position",
|
||||
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
|
||||
) + annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
) + annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
|
||||
logo_or_high = LogoPlotCustomH(small_df3,
|
||||
|
@ -248,7 +250,7 @@ logo_or_high = LogoPlotCustomH(small_df3,
|
|||
aa_pos_lig1=aa_pos_lig1,
|
||||
aa_pos_lig2=aa_pos_lig2,
|
||||
aa_pos_lig3=aa_pos_lig3
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
jpeg(paste0(outdir,"embb_average_stability.jpeg"), height = 8.25, width=11.5, unit="in",res=300)
|
||||
cowplot::plot_grid(
|
||||
|
|
|
@ -136,7 +136,7 @@ stab=function(...){bp_stability_hmap(
|
|||
yvar_colname = 'avg_stability_scaled',
|
||||
stability_colname = "avg_stability_scaled",
|
||||
stability_outcome_colname = "avg_stability_outcome",
|
||||
my_ylab = "",
|
||||
#my_ylab = "",
|
||||
my_xaxls = 6, # x-axis label size
|
||||
my_yaxls = 8, # y-axis label size
|
||||
drug_colour = tile_map$tile_colour[1],
|
||||
|
@ -163,7 +163,7 @@ print(paste0("Plotting LOW Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_low = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab="",
|
||||
y_lab="SAV Diversity",
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -203,7 +203,7 @@ mutable_df3 = cbind(small_df3)
|
|||
print(paste0("Plotting MID Rows: ", nrow(small_df3)))
|
||||
logo_p_snps_centre = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab = "",
|
||||
y_lab = "SAV Diversity",
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -229,7 +229,26 @@ logo_or_centre = LogoPlotCustomH(
|
|||
lig3_colour = tile_map$tile_colour[4]
|
||||
)
|
||||
|
||||
stability_centre = stab()
|
||||
stability_centre = bp_stability_hmap(
|
||||
small_df3,
|
||||
p_title = NULL,
|
||||
yvar_colname = 'avg_stability_scaled',
|
||||
stability_colname = "avg_stability_scaled",
|
||||
stability_outcome_colname = "avg_stability_outcome",
|
||||
my_ylab = "SAV Count",
|
||||
my_xaxls = 6, # x-axis label size
|
||||
my_yaxls = 8, # y-axis label size
|
||||
drug_colour = tile_map$tile_colour[1],
|
||||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4],
|
||||
y_max_override=max(merged_df3$pos_count),
|
||||
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
|
||||
)
|
||||
|
||||
# HIGH
|
||||
small_df3 = merged_df3[merged_df3['position'] > centre,]
|
||||
|
@ -239,7 +258,7 @@ print(paste0("Plotting HIGH Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_high = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab="" ,
|
||||
y_lab="SAV Diversity" ,
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -249,7 +268,7 @@ logo_p_snps_high = LogoPlotSnps(
|
|||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
logo_or_high = LogoPlotCustomH(
|
||||
small_df3,
|
||||
|
@ -265,10 +284,10 @@ logo_or_high = LogoPlotCustomH(
|
|||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
|
||||
stability_high = stab()+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
stability_high = stab(x_label="Wild-Type Position")
|
||||
#### "sorted" stability plots ####
|
||||
|
||||
# do stability plots for later assembly
|
||||
|
|
|
@ -165,7 +165,7 @@ print(paste0("Plotting LOW Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_low = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab="",
|
||||
y_lab="SAV Diversity",
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -195,7 +195,7 @@ logo_or_low = LogoPlotCustomH(
|
|||
lig3_colour = tile_map$tile_colour[4]
|
||||
)
|
||||
|
||||
stability_low = stab()+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
stability_low = stab(x_label="Wild-Type Position")
|
||||
|
||||
|
||||
# MID
|
||||
|
@ -205,7 +205,7 @@ print(paste0("Plotting MID Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_centre = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab = "",
|
||||
y_lab = "SAV Diversity",
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -244,7 +244,7 @@ print(paste0("Plotting HIGH Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_high = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab="" ,
|
||||
y_lab="SAV Diversity" ,
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -254,7 +254,7 @@ logo_p_snps_high = LogoPlotSnps(
|
|||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
logo_or_high = LogoPlotCustomH(
|
||||
small_df3,
|
||||
|
@ -271,7 +271,7 @@ logo_or_high = LogoPlotCustomH(
|
|||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
|
||||
stability_high = stab()
|
||||
|
@ -298,7 +298,7 @@ stability_high_reorder = bp_stability_hmap(
|
|||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
stability_centre_reorder = bp_stability_hmap(
|
||||
snpcount_low_high_df,
|
||||
reorder_position = T,
|
||||
|
@ -340,7 +340,8 @@ stability_low_reorder = bp_stability_hmap(
|
|||
drug_colour = tile_map$tile_colour[1],
|
||||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
lig3_colour = tile_map$tile_colour[4],
|
||||
x_label="Wild-Type Position"
|
||||
|
||||
)
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ print(paste0("Plotting LOW Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_low = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab="",
|
||||
y_lab="SAV Diversity",
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
aa_pos_lig1=aa_pos_lig1,
|
||||
|
@ -204,7 +204,7 @@ print(paste0("Plotting MID Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_centre = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab = "",
|
||||
y_lab = "SAV Diversity",
|
||||
x_ats = 4.5,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
|
@ -246,7 +246,7 @@ print(paste0("Plotting HIGH Rows: ", nrow(small_df3)))
|
|||
|
||||
logo_p_snps_high = LogoPlotSnps(
|
||||
mutable_df3,
|
||||
y_lab=" " ,
|
||||
y_lab="SAV Diversity" ,
|
||||
x_ats = 5,
|
||||
active_aa_pos=active_aa_pos,
|
||||
aa_pos_drug=aa_pos_drug,
|
||||
|
@ -257,7 +257,7 @@ logo_p_snps_high = LogoPlotSnps(
|
|||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
logo_or_high = LogoPlotCustomH(
|
||||
small_df3,
|
||||
|
@ -274,10 +274,11 @@ logo_or_high = LogoPlotCustomH(
|
|||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
|
||||
|
||||
stability_low = stab(my_xaxls = 4)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
stability_low = stab(my_xaxls = 4,
|
||||
x_label="Wild-Type Position")
|
||||
#### "sorted" stability plots ####
|
||||
|
||||
# do stability plots for later assembly
|
||||
|
@ -301,7 +302,7 @@ stability_high_reorder = bp_stability_hmap(
|
|||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
|
||||
)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
|
||||
)+ annotate(geom="text", label="Wild-Type Position",x=0.5,y=0.025, size=3)
|
||||
stability_centre_reorder = bp_stability_hmap(
|
||||
snpcount_low_high_df,
|
||||
reorder_position = T,
|
||||
|
@ -343,7 +344,8 @@ stability_low_reorder = bp_stability_hmap(
|
|||
drug_colour = tile_map$tile_colour[1],
|
||||
lig1_colour = tile_map$tile_colour[2],
|
||||
lig2_colour = tile_map$tile_colour[3],
|
||||
lig3_colour = tile_map$tile_colour[4]
|
||||
lig3_colour = tile_map$tile_colour[4],
|
||||
x_label="Wild-Type Position"
|
||||
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue