tweaks to thesis figs

This commit is contained in:
Tanushree Tunstall 2023-02-24 22:38:37 +00:00
parent e9d841d989
commit 9bc18169cf
7 changed files with 361 additions and 358 deletions

View file

@ -272,11 +272,15 @@ LogoPlotSnps <- function(plot_df
, limits = factor(1:length(x_axis_colname))) + , limits = factor(1:length(x_axis_colname))) +
theme(text = element_text(family="FreeSans") theme(text = element_text(family="FreeSans")
, legend.position = "none" , legend.position = "none"
, axis.text.x = element_blank() #, axis.text.x = element_blank()
, axis.text.y = element_blank() #, axis.text.y = element_blank()
#, axis.text.y = element_text() #, axis.text.y = element_text()
, axis.title.x = element_blank() , axis.title.x = element_blank()
, axis.title.y = element_blank() #, axis.title.y = element_blank()
, axis.title.y = element_text(size = y_tts
, angle = 90
, colour = ytt_col
, margin = margin(t = 0, r = 0, b = 20, l = 0))
, plot.background = element_rect(fill = theme_bgc, colour=NA) , plot.background = element_rect(fill = theme_bgc, colour=NA)
) + ) +
labs(x=NULL, y="WT") labs(x=NULL, y="WT")

View file

@ -73,20 +73,17 @@ tile_colour_map = c("DCS" = "#00ff00"
,"PLP" = "#000080") ,"PLP" = "#000080")
tile_legend=get_legend( tile_legend=get_legend(
ggplot(tile_map, aes(factor(tile),y=0 ggplot(tile_map, aes(factor(tile),y=0
, colour=tile_colour , colour=tile_colour
, fill=tile_colour))+ , fill=tile_colour))+
geom_tile() + geom_tile() +
theme(legend.title = element_blank(), theme(
legend.direction="horizontal", legend.direction="horizontal",
legend.text = element_text(size=10), legend.text = element_text(size=10),
legend.key.size = unit(10, "pt")) + legend.key.size = unit(10, "pt")) +
scale_colour_manual(name=NULL scale_colour_manual(name="Active Site"
#, values = tile_map$tile_colour
, values=tile_colour_map) + , values=tile_colour_map) +
scale_fill_manual(name=NULL scale_fill_manual(name="Active Site"
#,values=tile_map$tile_colour
, values = tile_colour_map) , values = tile_colour_map)
) )
@ -198,7 +195,7 @@ logo_or_low = LogoPlotCustomH(
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )
stability_low = stab() stability_low = stab()+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
# MID # MID
@ -254,7 +251,7 @@ logo_p_snps_high = LogoPlotSnps(
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
logo_or_high = LogoPlotCustomH( logo_or_high = LogoPlotCustomH(
small_df3, small_df3,
@ -270,10 +267,10 @@ logo_or_high = LogoPlotCustomH(
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
stability_high = stab() stability_high = stab()+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
#### "sorted" stability plots #### #### "sorted" stability plots ####
# do stability plots for later assembly # do stability plots for later assembly
@ -297,7 +294,7 @@ stability_high_reorder = bp_stability_hmap(
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
stability_centre_reorder = bp_stability_hmap( stability_centre_reorder = bp_stability_hmap(
snpcount_low_high_df, snpcount_low_high_df,
reorder_position = T, reorder_position = T,

View file

@ -7,8 +7,9 @@
# mutable_df3 = cbind(small_df3) # mutable_df3 = cbind(small_df3)
# plot_df = cbind(small_df3) # plot_df = cbind(small_df3)
source("~/git/LSHTM_analysis/config/embb.R") #source("~/git/LSHTM_analysis/config/embb.R")
source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R") #source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R")
#outdir="/home/pub/Work/LSHTM/Thesis_Plots/" #outdir="/home/pub/Work/LSHTM/Thesis_Plots/"
outdir="~/git/Writing/thesis/tex/images-corrected/embb/" outdir="~/git/Writing/thesis/tex/images-corrected/embb/"
@ -36,12 +37,11 @@ low_half_snpcount = round(nrow(snpcount_low_df)/2)
snpcount_low_low_df = snpcount_low_df[1:low_half_snpcount,] snpcount_low_low_df = snpcount_low_df[1:low_half_snpcount,]
snpcount_low_high_df = snpcount_low_df[low_half_snpcount:nrow(snpcount_low_df),] snpcount_low_high_df = snpcount_low_df[low_half_snpcount:nrow(snpcount_low_df),]
# do stability plots for later assembly # do stability plots for later assembly
stability_high = bp_stability_hmap(snpcount_high_df, stability_high = bp_stability_hmap(snpcount_high_df,
reorder_position = T, reorder_position = T,
p_title = NULL, p_title = NULL,
my_ylab = NULL, my_ylab = "",
yvar_colname = 'avg_stability_scaled', yvar_colname = 'avg_stability_scaled',
stability_colname = "avg_stability_scaled", stability_colname = "avg_stability_scaled",
stability_outcome_colname = "avg_stability_outcome", stability_outcome_colname = "avg_stability_outcome",
@ -75,7 +75,7 @@ stability_low = bp_stability_hmap(snpcount_low_low_df,
yvar_colname = 'avg_stability_scaled', yvar_colname = 'avg_stability_scaled',
stability_colname = "avg_stability_scaled", stability_colname = "avg_stability_scaled",
stability_outcome_colname = "avg_stability_outcome", stability_outcome_colname = "avg_stability_outcome",
my_ylab = NULL, my_ylab = "",
y_max_override = max(snpcount_high_df$pos_count), y_max_override = max(snpcount_high_df$pos_count),
my_xaxls = 6, # x-axis label size my_xaxls = 6, # x-axis label size
my_yaxls = 8, # y-axis label size my_yaxls = 8, # y-axis label size
@ -84,7 +84,7 @@ stability_low = bp_stability_hmap(snpcount_low_low_df,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3 aa_pos_lig3=aa_pos_lig3
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
low=round(max(merged_df3$position)/3) low=round(max(merged_df3$position)/3)
centre=low*2 centre=low*2
@ -93,18 +93,18 @@ centre=low*2
heatbar_df = generate_distance_colour_map(merged_df3) heatbar_df = generate_distance_colour_map(merged_df3)
heat_bar_legend = get_legend( heat_bar_legend = get_legend(
ggplot(merged_df3, aes(factor(ligand_distance), y=0)) + ggplot(merged_df3, aes(factor(ligand_distance), y=0)) +
theme(legend.direction="horizontal", theme(legend.direction="horizontal",
legend.title = element_text(size=10), legend.title = element_text(size=10),
#legend.text = element_text(size=10), #legend.text = element_text(size=10),
#legend.key.size = unit(10, "pt") #legend.key.size = unit(10, "pt")
)+ )+
geom_point(aes( geom_point(aes(
colour = ligand_distance, colour = ligand_distance,
) )
) + ) +
scale_colour_gradientn(name="Ligand\nDistance (Å)", colours = magma(5, direction = -1)) scale_colour_gradientn(name="Ligand\nDistance (Å)", colours = magma(5, direction = -1))
) )
# Position Tile Legend # Position Tile Legend
@ -114,21 +114,18 @@ tile_colour_map = c("EMB" = "green"
, "Ca" = "purple") , "Ca" = "purple")
tile_legend=get_legend( tile_legend=get_legend(
ggplot(tile_map, aes(factor(tile),y=0
ggplot(tile_map, aes(factor(tile),y=0 , colour=tile_colour
, colour=tile_colour , fill=tile_colour))+
, fill=tile_colour))+ geom_tile() +
geom_tile() + theme(
theme(legend.title = element_blank(), legend.direction="horizontal",
legend.direction="horizontal", legend.text = element_text(size=10),
legend.text = element_text(size=10), legend.key.size = unit(10, "pt")) +
legend.key.size = unit(10, "pt")) + scale_colour_manual(name="Active Site"
scale_colour_manual(name=NULL , values=tile_colour_map) +
#, values = tile_map$tile_colour scale_fill_manual(name="Active Site"
, values=tile_colour_map) + , values = tile_colour_map)
scale_fill_manual(name=NULL
#,values=tile_map$tile_colour
, values = tile_colour_map)
) )
# SAV Tile Red/Blue Legend # SAV Tile Red/Blue Legend
@ -136,38 +133,39 @@ tile_legend=get_legend(
temp_snp_df=merged_df3%>%dplyr::add_count(position) temp_snp_df=merged_df3%>%dplyr::add_count(position)
snp_tile_legend = get_legend( snp_tile_legend = get_legend(
ggplot(temp_snp_df, aes(factor(avg_stability_scaled), y=0)) + ggplot(temp_snp_df, aes(factor(avg_stability_scaled), y=0)) +
theme(#legend.title = element_blank(), theme(#legend.title = element_blank(),
legend.direction="horizontal", legend.direction="horizontal",
legend.title = element_text(size=10), legend.title = element_text(size=10),
#legend.text = element_text(size=10), #legend.text = element_text(size=10),
#legend.key.size = unit(10, "pt") #legend.key.size = unit(10, "pt")
)+ )+
geom_point(aes( geom_point(aes(
colour = avg_stability_scaled, colour = avg_stability_scaled,
) )
) + ) +
scale_colour_gradientn(name="Protein Stability\n(ΔΔG Kcal/mol)", colours = rev(c("#007ba4", # rev() because FUCK scale_colour_gradientn(name="Protein Stability\n(ΔΔG Kcal/mol)", colours = rev(c("#007ba4", # rev() because FUCK
"#00bfc4", "#00bfc4",
"#ffffff", "#ffffff",
"#ffd9d0", "#ffd9d0",
"#f8766d", "#f8766d",
"#ae3121"))) "#ae3121")))
) )
# Logop Chemistry Colours # Logop Chemistry Colours
temp_logo_p_snp=cbind(merged_df3) temp_logo_p_snp=cbind(merged_df3)
tab_mt = table(temp_logo_p_snp[["mutant_type"]], temp_logo_p_snp[["position"]]) tab_mt = table(temp_logo_p_snp[["mutant_type"]], temp_logo_p_snp[["position"]])
tab_mt = unclass(tab_mt) tab_mt = unclass(tab_mt)
logoplot_chemistry_legend=get_legend( logoplot_chemistry_legend=get_legend(
ggplot() + ggplot() +
geom_logo(tab_mt geom_logo(tab_mt
, method = 'custom' , method = 'custom'
, col_scheme = "chemistry" , col_scheme = "chemistry"
, seq_type = 'aa') + theme(legend.title = element_blank(), , seq_type = 'aa') + theme(
legend.direction="horizontal", legend.title = element_blank(),
legend.text = element_text(size=10), legend.direction="horizontal",
legend.key.size = unit(10, "pt")) legend.text = element_text(size=10),
legend.key.size = unit(10, "pt"))
) )
# LOW # LOW
@ -187,7 +185,7 @@ logo_p_snps_low = LogoPlotSnps(mutable_df3,
# needs to be: active_aa_pos AND odds ratio >10 # needs to be: active_aa_pos AND odds ratio >10
logo_or_low = LogoPlotCustomH(small_df3, logo_or_low = LogoPlotCustomH(small_df3,
y_axis_increment=10, y_axis_increment=10,
y_lab="", y_lab="Odds Ratio",
rm_empty_y=T, rm_empty_y=T,
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
@ -201,10 +199,21 @@ logo_or_low = LogoPlotCustomH(small_df3,
small_df3 = merged_df3[merged_df3['position'] <= centre & merged_df3['position'] >= low,] small_df3 = merged_df3[merged_df3['position'] <= centre & merged_df3['position'] >= low,]
mutable_df3 = cbind(small_df3) mutable_df3 = cbind(small_df3)
print(paste0("Plotting MID Rows: ", nrow(small_df3))) print(paste0("Plotting MID Rows: ", nrow(small_df3)))
logo_p_snps_centre = LogoPlotSnps(mutable_df3, y_lab = "SAV Count")
logo_p_snps_centre = LogoPlotSnps(
mutable_df3,
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,
y_lab = "SAV Count"
)
logo_or_centre = LogoPlotCustomH(small_df3, logo_or_centre = LogoPlotCustomH(small_df3,
y_axis_increment=10, y_axis_increment=2,
y_lab = "Log(10) Odds Ratio",
y_axis_log = TRUE,
rm_empty_y=T, rm_empty_y=T,
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
@ -221,47 +230,49 @@ print(paste0("Plotting HIGH Rows: ", nrow(small_df3)))
logo_p_snps_high = LogoPlotSnps(mutable_df3, logo_p_snps_high = LogoPlotSnps(mutable_df3,
y_lab="", y_lab="",
x_lab = "Position",
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3 aa_pos_lig3=aa_pos_lig3
) ) + annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
logo_or_high = LogoPlotCustomH(small_df3, logo_or_high = LogoPlotCustomH(small_df3,
y_axis_increment=10, y_axis_increment=10,
y_lab="", y_lab="Odds Ratio",
rm_empty_y=T, rm_empty_y=T,
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3 aa_pos_lig3=aa_pos_lig3
) )+ annotate(geom="text", label="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) jpeg(paste0(outdir,"embb_average_stability.jpeg"), height = 8.25, width=11.5, unit="in",res=300)
cowplot::plot_grid( cowplot::plot_grid(
cowplot::plot_grid(heat_bar_legend, tile_legend, snp_tile_legend, nrow=1), cowplot::plot_grid(heat_bar_legend, tile_legend, snp_tile_legend, nrow=1),
cowplot::plot_grid(stability_high, stability_centre, stability_low,ncol=1), cowplot::plot_grid(stability_high, stability_centre, stability_low,ncol=1),
ncol=1, ncol=1,
rel_heights = c(1,12) rel_heights = c(1,12)
) )
dev.off() dev.off()
jpeg(paste0(outdir,"embb_snp.jpeg"), height = 8.25, width=11.5, unit="in",res=300) jpeg(paste0(outdir,"embb_snp.jpeg"), height = 8.25, width=11.5, unit="in",res=300)
cowplot::plot_grid( cowplot::plot_grid(
cowplot::plot_grid(heat_bar_legend, tile_legend, logoplot_chemistry_legend, nrow=1), cowplot::plot_grid(heat_bar_legend, tile_legend, logoplot_chemistry_legend, nrow=1),
cowplot::plot_grid(logo_p_snps_low, logo_p_snps_centre, logo_p_snps_high, ncol=1, align='hv'), cowplot::plot_grid(logo_p_snps_low, logo_p_snps_centre, logo_p_snps_high, ncol=1, align='hv'),
ncol=1, ncol=1,
rel_heights = c(1,12) rel_heights = c(1,12)
) )
dev.off() dev.off()
jpeg(paste0(outdir,"embb_or.jpeg"), height = 8.25, width=11.5, unit="in",res=300) jpeg(paste0(outdir,"embb_or.jpeg"), height = 8.25, width=11.5, unit="in",res=300)
cowplot::plot_grid( cowplot::plot_grid(
cowplot::plot_grid(heat_bar_legend, tile_legend, logoplot_chemistry_legend, nrow=1), cowplot::plot_grid(heat_bar_legend, tile_legend, logoplot_chemistry_legend, nrow=1),
cowplot::plot_grid(logo_or_low, logo_or_centre, logo_or_high, ncol=1, align='hv'), cowplot::plot_grid(logo_or_low, logo_or_centre, logo_or_high, ncol=1, align='hv'),
ncol=1, ncol=1,
rel_heights = c(1,12) rel_heights = c(1,12)
) )
dev.off() dev.off()

View file

@ -70,21 +70,18 @@ tile_colour_map = c("STR" = "green",
,"AMP" = "#000080") ,"AMP" = "#000080")
tile_legend=get_legend( tile_legend=get_legend(
ggplot(tile_map, aes(factor(tile),y=0
ggplot(tile_map, aes(factor(tile),y=0 , colour=tile_colour
, colour=tile_colour , fill=tile_colour))+
, fill=tile_colour))+ geom_tile() +
geom_tile() + theme(
theme(legend.title = element_blank(), legend.direction="horizontal",
legend.direction="horizontal", legend.text = element_text(size=10),
legend.text = element_text(size=10), legend.key.size = unit(10, "pt")) +
legend.key.size = unit(10, "pt")) + scale_colour_manual(name="Active Site"
scale_colour_manual(name=NULL , values=tile_colour_map) +
#, values = tile_map$tile_colour scale_fill_manual(name="Active Site"
, values=tile_colour_map) + , values = tile_colour_map)
scale_fill_manual(name=NULL
#,values=tile_map$tile_colour
, values = tile_colour_map)
) )
# SAV Tile Red/Blue Legend # SAV Tile Red/Blue Legend
@ -271,7 +268,7 @@ logo_or_high = LogoPlotCustomH(
) )
stability_high = stab() stability_high = stab()+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
#### "sorted" stability plots #### #### "sorted" stability plots ####
# do stability plots for later assembly # do stability plots for later assembly

View file

@ -51,20 +51,20 @@ centre=low*2
heatbar_df = generate_distance_colour_map(merged_df3) heatbar_df = generate_distance_colour_map(merged_df3)
heat_bar_legend = get_legend( heat_bar_legend = get_legend(
ggplot(merged_df3, aes(factor(ligand_distance), y=0)) + ggplot(merged_df3, aes(factor(ligand_distance), y=0)) +
theme(legend.direction="horizontal", theme(legend.direction="horizontal",
legend.title = element_text(size=10), legend.title = element_text(size=10),
#legend.text = element_text(size=10), #legend.text = element_text(size=10),
#legend.key.size = unit(10, "pt") #legend.key.size = unit(10, "pt")
)+ )+
geom_point(aes( geom_point(aes(
colour = ligand_distance, colour = ligand_distance,
) )
) + ) +
scale_colour_gradientn( scale_colour_gradientn(
name="Ligand\nDistance (Å)", name="Ligand\nDistance (Å)",
colours = magma(5, direction = -1)) colours = magma(5, direction = -1))
) )
# Position Tile Legend # Position Tile Legend
# STR #00ff00 # STR #00ff00
@ -72,21 +72,18 @@ tile_colour_map = c("INH" = "#00ff00"
,"HEME" = "darkslategrey") ,"HEME" = "darkslategrey")
tile_legend=get_legend( tile_legend=get_legend(
ggplot(tile_map, aes(factor(tile),y=0
ggplot(tile_map, aes(factor(tile),y=0 , colour=tile_colour
, colour=tile_colour , fill=tile_colour))+
, fill=tile_colour))+ geom_tile() +
geom_tile() + theme(
theme(legend.title = element_blank(), legend.direction="horizontal",
legend.direction="horizontal", legend.text = element_text(size=10),
legend.text = element_text(size=10), legend.key.size = unit(10, "pt")) +
legend.key.size = unit(10, "pt")) + scale_colour_manual(name="Active Site"
scale_colour_manual(name=NULL , values=tile_colour_map) +
#, values = tile_map$tile_colour scale_fill_manual(name="Active Site"
, values=tile_colour_map) + , values = tile_colour_map)
scale_fill_manual(name=NULL
#,values=tile_map$tile_colour
, values = tile_colour_map)
) )
# SAV Tile Red/Blue Legend # SAV Tile Red/Blue Legend
@ -94,67 +91,67 @@ tile_legend=get_legend(
temp_snp_df=merged_df3%>%dplyr::add_count(position) temp_snp_df=merged_df3%>%dplyr::add_count(position)
snp_tile_legend = get_legend( snp_tile_legend = get_legend(
ggplot(temp_snp_df, aes(factor(avg_stability_scaled), y=0)) + ggplot(temp_snp_df, aes(factor(avg_stability_scaled), y=0)) +
theme(#legend.title = element_blank(), theme(#legend.title = element_blank(),
legend.direction="horizontal", legend.direction="horizontal",
legend.title = element_text(size=10), legend.title = element_text(size=10),
#legend.text = element_text(size=10), #legend.text = element_text(size=10),
#legend.key.size = unit(10, "pt") #legend.key.size = unit(10, "pt")
)+ )+
geom_point(aes( geom_point(aes(
colour = avg_stability_scaled, colour = avg_stability_scaled,
) )
) + ) +
scale_colour_gradientn( scale_colour_gradientn(
name="Protein Stability\n(ΔΔG Kcal/mol)", colours = rev( name="Protein Stability\n(ΔΔG Kcal/mol)", colours = rev(
c("#007ba4", # rev() because FUCK c("#007ba4", # rev() because FUCK
"#00bfc4", "#00bfc4",
"#ffffff", "#ffffff",
"#ffd9d0", "#ffd9d0",
"#f8766d", "#f8766d",
"#ae3121") "#ae3121")
) )
) )
) )
# Logop Chemistry Colours # Logop Chemistry Colours
temp_logo_p_snp=cbind(merged_df3) temp_logo_p_snp=cbind(merged_df3)
tab_mt = table(temp_logo_p_snp[["mutant_type"]], temp_logo_p_snp[["position"]]) tab_mt = table(temp_logo_p_snp[["mutant_type"]], temp_logo_p_snp[["position"]])
tab_mt = unclass(tab_mt) tab_mt = unclass(tab_mt)
logoplot_chemistry_legend=get_legend( logoplot_chemistry_legend=get_legend(
ggplot() + ggplot() +
geom_logo( geom_logo(
tab_mt tab_mt
, method = 'custom' , method = 'custom'
, col_scheme = "chemistry" , col_scheme = "chemistry"
, seq_type = 'aa') + theme( , seq_type = 'aa') + theme(
legend.title = element_blank(), legend.title = element_blank(),
legend.direction="horizontal", legend.direction="horizontal",
legend.text = element_text(size=10), legend.text = element_text(size=10),
legend.key.size = unit(10, "pt") legend.key.size = unit(10, "pt")
) )
) )
stab=function(...){bp_stability_hmap( stab=function(...){bp_stability_hmap(
small_df3, small_df3,
p_title = NULL, p_title = NULL,
yvar_colname = 'avg_stability_scaled', yvar_colname = 'avg_stability_scaled',
stability_colname = "avg_stability_scaled", stability_colname = "avg_stability_scaled",
stability_outcome_colname = "avg_stability_outcome", stability_outcome_colname = "avg_stability_outcome",
my_ylab = "", my_ylab = "",
my_xaxls = 6, # x-axis label size my_xaxls = 6, # x-axis label size
my_yaxls = 8, # y-axis label size my_yaxls = 8, # y-axis label size
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4], lig3_colour = tile_map$tile_colour[4],
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
y_max_override=max(merged_df3$pos_count), y_max_override=max(merged_df3$pos_count),
... ...
) )
} }
@ -167,38 +164,38 @@ print(paste0("Plotting LOW Rows: ", nrow(small_df3)))
logo_p_snps_low = LogoPlotSnps( logo_p_snps_low = LogoPlotSnps(
mutable_df3, mutable_df3,
y_lab="", y_lab="",
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )
# needs to be: active_aa_pos AND odds ratio >10 # needs to be: active_aa_pos AND odds ratio >10
logo_or_low = LogoPlotCustomH( logo_or_low = LogoPlotCustomH(
small_df3, small_df3,
y_lab = "Odds Ratio", y_lab = "Odds Ratio",
# y_axis_increment=1, # y_axis_increment=1,
# y_axis_log = TRUE, # y_axis_log = TRUE,
rm_empty_y=TRUE, rm_empty_y=TRUE,
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )
stability_low = stab() stability_low = stab()+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
# MID # MID
@ -207,34 +204,34 @@ mutable_df3 = cbind(small_df3)
print(paste0("Plotting MID Rows: ", nrow(small_df3))) print(paste0("Plotting MID Rows: ", nrow(small_df3)))
logo_p_snps_centre = LogoPlotSnps( logo_p_snps_centre = LogoPlotSnps(
mutable_df3, mutable_df3,
y_lab = "", y_lab = "",
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )
logo_or_centre = LogoPlotCustomH( logo_or_centre = LogoPlotCustomH(
small_df3, small_df3,
y_axis_increment=2, y_axis_increment=2,
rm_empty_y=TRUE, rm_empty_y=TRUE,
y_lab = "Log(10) Odds Ratio", y_lab = "Log(10) Odds Ratio",
y_axis_log = TRUE, y_axis_log = TRUE,
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )
stability_centre = stab() stability_centre = stab()
@ -246,35 +243,35 @@ print(paste0("Plotting HIGH Rows: ", nrow(small_df3)))
logo_p_snps_high = LogoPlotSnps( logo_p_snps_high = LogoPlotSnps(
mutable_df3, mutable_df3,
y_lab="" , y_lab="" ,
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
logo_or_high = LogoPlotCustomH( logo_or_high = LogoPlotCustomH(
small_df3, small_df3,
y_axis_increment=10, y_axis_increment=10,
rm_empty_y=TRUE, rm_empty_y=TRUE,
# y_axis_log = TRUE, # y_axis_log = TRUE,
y_lab = "Odds Ratio", y_lab = "Odds Ratio",
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
stability_high = stab() stability_high = stab()
@ -282,103 +279,103 @@ stability_high = stab()
# do stability plots for later assembly # do stability plots for later assembly
stability_high_reorder = bp_stability_hmap( stability_high_reorder = bp_stability_hmap(
snpcount_high_df, snpcount_high_df,
reorder_position = T, reorder_position = T,
p_title = NULL, p_title = NULL,
my_ylab = NULL, my_ylab = NULL,
yvar_colname = 'avg_stability_scaled', yvar_colname = 'avg_stability_scaled',
stability_colname = "avg_stability_scaled", stability_colname = "avg_stability_scaled",
stability_outcome_colname = "avg_stability_outcome", stability_outcome_colname = "avg_stability_outcome",
my_xaxls = 4, # x-axis label size my_xaxls = 4, # x-axis label size
my_yaxls = 8, # y-axis label size my_yaxls = 8, # y-axis label size
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
stability_centre_reorder = bp_stability_hmap( stability_centre_reorder = bp_stability_hmap(
snpcount_low_high_df, snpcount_low_high_df,
reorder_position = T, reorder_position = T,
p_title = NULL, p_title = NULL,
yvar_colname = 'avg_stability_scaled', yvar_colname = 'avg_stability_scaled',
stability_colname = "avg_stability_scaled", stability_colname = "avg_stability_scaled",
stability_outcome_colname = "avg_stability_outcome", stability_outcome_colname = "avg_stability_outcome",
my_ylab = "", my_ylab = "",
y_max_override = max(snpcount_high_df$pos_count), y_max_override = max(snpcount_high_df$pos_count),
my_xaxls = 6, # x-axis label size my_xaxls = 6, # x-axis label size
my_yaxls = 8, # y-axis label size my_yaxls = 8, # y-axis label size
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )
stability_low_reorder = bp_stability_hmap( stability_low_reorder = bp_stability_hmap(
snpcount_low_low_df, snpcount_low_low_df,
reorder_position = T, reorder_position = T,
p_title = NULL, p_title = NULL,
yvar_colname = 'avg_stability_scaled', yvar_colname = 'avg_stability_scaled',
stability_colname = "avg_stability_scaled", stability_colname = "avg_stability_scaled",
stability_outcome_colname = "avg_stability_outcome", stability_outcome_colname = "avg_stability_outcome",
my_ylab = NULL, my_ylab = NULL,
y_max_override = max(snpcount_high_df$pos_count), y_max_override = max(snpcount_high_df$pos_count),
my_xaxls = 6, # x-axis label size my_xaxls = 6, # x-axis label size
my_yaxls = 8, # y-axis label size my_yaxls = 8, # y-axis label size
aa_pos_drug=aa_pos_drug, aa_pos_drug=aa_pos_drug,
active_aa_pos=active_aa_pos, active_aa_pos=active_aa_pos,
aa_pos_lig1=aa_pos_lig1, aa_pos_lig1=aa_pos_lig1,
aa_pos_lig2=aa_pos_lig2, aa_pos_lig2=aa_pos_lig2,
aa_pos_lig3=aa_pos_lig3, aa_pos_lig3=aa_pos_lig3,
drug_colour = tile_map$tile_colour[1], drug_colour = tile_map$tile_colour[1],
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )
jpeg(paste0(outdir,"katg_average_stability-sorted.jpeg"), height = 6, width=11.5, unit="in",res=300) jpeg(paste0(outdir,"katg_average_stability-sorted.jpeg"), height = 6, width=11.5, unit="in",res=300)
cowplot::plot_grid( cowplot::plot_grid(
cowplot::plot_grid(heat_bar_legend, tile_legend, snp_tile_legend, nrow=1), cowplot::plot_grid(heat_bar_legend, tile_legend, snp_tile_legend, nrow=1),
cowplot::plot_grid(stability_high_reorder, stability_centre_reorder, stability_low_reorder,ncol=1), cowplot::plot_grid(stability_high_reorder, stability_centre_reorder, stability_low_reorder,ncol=1),
ncol=1, ncol=1,
rel_heights = c(1,12) rel_heights = c(1,12)
) )
dev.off() dev.off()
jpeg(paste0(outdir,"katg_average_stability-unsorted.jpeg"), height = 6, width=11.5, unit="in",res=300) jpeg(paste0(outdir,"katg_average_stability-unsorted.jpeg"), height = 6, width=11.5, unit="in",res=300)
cowplot::plot_grid( cowplot::plot_grid(
cowplot::plot_grid(heat_bar_legend, tile_legend, snp_tile_legend, nrow=1), cowplot::plot_grid(heat_bar_legend, tile_legend, snp_tile_legend, nrow=1),
cowplot::plot_grid(stability_high, stability_centre, stability_low,ncol=1), cowplot::plot_grid(stability_high, stability_centre, stability_low,ncol=1),
ncol=1, ncol=1,
rel_heights = c(1,12) rel_heights = c(1,12)
) )
dev.off() dev.off()
jpeg(paste0(outdir,"katg_snp.jpeg"), height = 6, width=11.5, unit="in",res=300) jpeg(paste0(outdir,"katg_snp.jpeg"), height = 6, width=11.5, unit="in",res=300)
cowplot::plot_grid( cowplot::plot_grid(
cowplot::plot_grid(heat_bar_legend, tile_legend, logoplot_chemistry_legend, nrow=1), cowplot::plot_grid(heat_bar_legend, tile_legend, logoplot_chemistry_legend, nrow=1),
cowplot::plot_grid(logo_p_snps_low, logo_p_snps_centre, logo_p_snps_high, ncol=1, align='hv'), cowplot::plot_grid(logo_p_snps_low, logo_p_snps_centre, logo_p_snps_high, ncol=1, align='hv'),
ncol=1, ncol=1,
rel_heights = c(1,12) rel_heights = c(1,12)
) )
dev.off() dev.off()
jpeg(paste0(outdir,"katg_or.jpeg"), height = 6, width=11.5, unit="in",res=300) jpeg(paste0(outdir,"katg_or.jpeg"), height = 6, width=11.5, unit="in",res=300)
cowplot::plot_grid( cowplot::plot_grid(
cowplot::plot_grid(heat_bar_legend, tile_legend, logoplot_chemistry_legend, nrow=1), cowplot::plot_grid(heat_bar_legend, tile_legend, logoplot_chemistry_legend, nrow=1),
cowplot::plot_grid(logo_or_low, logo_or_centre, logo_or_high, ncol=1, align='hv'), cowplot::plot_grid(logo_or_low, logo_or_centre, logo_or_high, ncol=1, align='hv'),
ncol=1, ncol=1,
rel_heights = c(1,12) rel_heights = c(1,12)
) )
dev.off() dev.off()

View file

@ -71,20 +71,17 @@ heat_bar_legend = get_legend(
tile_colour_map = c("RFP" = "#00ff00") tile_colour_map = c("RFP" = "#00ff00")
tile_legend=get_legend( tile_legend=get_legend(
ggplot(tile_map, aes(factor(tile),y=0 ggplot(tile_map, aes(factor(tile),y=0
, colour=tile_colour , colour=tile_colour
, fill=tile_colour))+ , fill=tile_colour))+
geom_tile() + geom_tile() +
theme(legend.title = element_blank(), theme(
legend.direction="horizontal", legend.direction="horizontal",
legend.text = element_text(size=10), legend.text = element_text(size=10),
legend.key.size = unit(10, "pt")) + legend.key.size = unit(10, "pt")) +
scale_colour_manual(name=NULL scale_colour_manual(name="Active Site"
#, values = tile_map$tile_colour
, values=tile_colour_map) + , values=tile_colour_map) +
scale_fill_manual(name=NULL scale_fill_manual(name="Active Site"
#,values=tile_map$tile_colour
, values = tile_colour_map) , values = tile_colour_map)
) )
@ -260,7 +257,7 @@ logo_p_snps_high = LogoPlotSnps(
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
logo_or_high = LogoPlotCustomH( logo_or_high = LogoPlotCustomH(
small_df3, small_df3,
@ -277,10 +274,10 @@ logo_or_high = LogoPlotCustomH(
lig1_colour = tile_map$tile_colour[2], lig1_colour = tile_map$tile_colour[2],
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
stability_low = stab(my_xaxls = 4) stability_low = stab(my_xaxls = 4)+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
#### "sorted" stability plots #### #### "sorted" stability plots ####
# do stability plots for later assembly # do stability plots for later assembly
@ -304,7 +301,7 @@ stability_high_reorder = bp_stability_hmap(
lig2_colour = tile_map$tile_colour[3], lig2_colour = tile_map$tile_colour[3],
lig3_colour = tile_map$tile_colour[4] lig3_colour = tile_map$tile_colour[4]
) )+ annotate(geom="text", label="Position",x=0.5,y=0.025, size=3)
stability_centre_reorder = bp_stability_hmap( stability_centre_reorder = bp_stability_hmap(
snpcount_low_high_df, snpcount_low_high_df,
reorder_position = T, reorder_position = T,

View file

@ -187,7 +187,7 @@ loaded_files$gid_baselineC_cd_sl[loaded_files$gid_baselineC_cd_sl$source_data=="
for (x in gene) { for (x in gene) {
out_tex=paste0(latex_outdir,"ml_table-", x, ".tex") out_tex=paste0(latex_outdir,"ml_table-", x, ".tex")
df_name=paste0(x,"_baselineC_cd_sl") df_name=paste0(x,"_baselineC_cd_sl")
processed_df = loaded_files[[df_name]] %>% pivot_wider(names_from=source_data, values_from=c( processed_df = loaded_files[[df_name]] %>% pivotf_wider(names_from=source_data, values_from=c(
'MCC', 'MCC',
'F1', 'F1',
'Accuracy', 'Accuracy',