added hbond residues in config for all genes
This commit is contained in:
parent
7a14655ecb
commit
6ffb084546
9 changed files with 686 additions and 110 deletions
|
@ -193,6 +193,29 @@ map(paste0(func_path, source_files), source) # source all your R scripts!
|
|||
# set plot script dir
|
||||
plot_script_path = "~/git/LSHTM_analysis/scripts/plotting/"
|
||||
|
||||
####################################################
|
||||
consurf_palette1 = c("0" = "yellow2"
|
||||
, "1" = "cyan1"
|
||||
, "2" = "steelblue2"
|
||||
, "3" = "cadetblue2"
|
||||
, "4" = "paleturquoise2"
|
||||
, "5" = "thistle3"
|
||||
, "6" = "thistle2"
|
||||
, "7" = "plum2"
|
||||
, "8" = "maroon"
|
||||
, "9" = "violetred2")
|
||||
|
||||
consurf_palette2 = c("0" = "yellow2"
|
||||
, "1" = "forestgreen"
|
||||
, "2" = "seagreen3"
|
||||
, "3" = "palegreen1"
|
||||
, "4" = "darkseagreen2"
|
||||
, "5" = "thistle3"
|
||||
, "6" = "lightpink1"
|
||||
, "7" = "orchid3"
|
||||
, "8" = "orchid4"
|
||||
, "9" = "darkorchid4")
|
||||
|
||||
##################################################
|
||||
|
||||
# Function name clashes with plyr and dplyr
|
||||
|
|
|
@ -213,7 +213,7 @@ g = ggplot(df, aes(factor(position, ordered = T)))
|
|||
# This is the key to generating the geom_tiles OUTside the plotting area on the x-axis!
|
||||
OutPlot_aa_PS = g +
|
||||
coord_cartesian(xlim = c(1, my_xlim)
|
||||
#, ylim = c(0, 6)
|
||||
#, ylim = c(0, 6)0.85
|
||||
, ylim = c(0, max(snp_count))
|
||||
, clip = "off") +
|
||||
geom_bar(aes(fill = group), colour = "grey") +
|
||||
|
|
|
@ -1,30 +1,3 @@
|
|||
consurf_palette1 = c("0" = "yellow2"
|
||||
, "1" = "cyan1"
|
||||
, "2" = "steelblue2"
|
||||
, "3" = "cadetblue2"
|
||||
, "4" = "paleturquoise2"
|
||||
, "5" = "thistle3"
|
||||
, "6" = "thistle2"
|
||||
, "7" = "plum2"
|
||||
, "8" = "maroon"
|
||||
, "9" = "violetred2")
|
||||
|
||||
consurf_palette2 = c("0" = "yellow2"
|
||||
, "1" = "forestgreen"
|
||||
, "2" = "seagreen3"
|
||||
, "3" = "palegreen1"
|
||||
, "4" = "darkseagreen2"
|
||||
, "5" = "thistle3"
|
||||
, "6" = "lightpink1"
|
||||
, "7" = "orchid3"
|
||||
, "8" = "orchid4"
|
||||
, "9" = "darkorchid4")
|
||||
|
||||
|
||||
#myCOL <- colorRampPalette(c("yellow2", "palegreen1", "darkorchid4"))(10)
|
||||
#plot(1:100, col = myCOL, pch = 19, cex = 2)
|
||||
#myColors <- scale_color_brewer(palette = "Cyan-Magenta")
|
||||
|
||||
consurf_cols = consurf_palette1
|
||||
consurf_cols = consurf_palette2
|
||||
#consurf_cols = myCOL
|
||||
|
@ -42,17 +15,20 @@ length(unique(merged_df3[[aa_position_colname]]))
|
|||
|
||||
positionF <- levels(as.factor(merged_df3[[aa_position_colname]]))
|
||||
length(positionF)
|
||||
aa_pos_colours = ifelse(positionF%in%rna_bind_aa_pos, "purple"
|
||||
, ifelse(positionF%in%binding_aa_pos, "orange", "black" ))
|
||||
aa_pos_colours = ifelse(positionF%in%aa_pos_sry, "purple"
|
||||
, ifelse(positionF%in%aa_pos_rna, "orange", "black" ))
|
||||
bar = merged_df3
|
||||
bar[['lab_bg']] = ifelse(bar[[aa_position_colname]]%in%rna_bind_aa_pos
|
||||
aa_colour_colname = "lab_bg"
|
||||
|
||||
bar[[aa_colour_colname]] = ifelse(bar[[aa_position_colname]]%in%aa_pos_sry
|
||||
, "purple"
|
||||
, ifelse(bar[[aa_position_colname]]%in%binding_aa_pos
|
||||
, ifelse(bar[[aa_position_colname]]%in%aa_pos_rna
|
||||
, "orange", "white" ))
|
||||
head(bar[[aa_position_colname]])
|
||||
head(bar[['lab_bg']])
|
||||
head(bar[[aa_colour_colname]])
|
||||
|
||||
my_xlim = length(unique(bar$position)); my_xlim
|
||||
######################################################################
|
||||
my_xlim = length(unique(bar[[aa_position_colname]])); my_xlim
|
||||
|
||||
ymin = min(bar$consurf_score)
|
||||
ymax = max(bar$consurf_score)
|
||||
|
@ -70,15 +46,38 @@ g = ggplot(bar, aes(x = factor(position)
|
|||
) +
|
||||
geom_errorbar(aes(ymin = consurf_ci_lower, ymax = consurf_ci_upper))
|
||||
|
||||
g0 = g + geom_tile(aes(,-2, width = 0.95, height = -0.2)
|
||||
, fill = bar$lab_bg
|
||||
, colour = "white")
|
||||
g0
|
||||
|
||||
g1 = g0 + theme( axis.text.x = element_text(size = 10
|
||||
# g0 = g + geom_tile(aes(,-2, width = 0.95, height = -0.2)
|
||||
# #, fill = bar$lab_bg
|
||||
# , fill = bar[[aa_colour_colname]]
|
||||
# , colour = "white")
|
||||
|
||||
g0 = g +
|
||||
geom_tile(aes(,-1.7, width = 0.95, height = 0.3)
|
||||
, fill = bar$ligD_colours
|
||||
, colour = "black")
|
||||
|
||||
# g0 = g +
|
||||
# geom_tile(aes(,-1.9, width = 0.95, height = 0.2)
|
||||
# , fill = bar[[aa_colour_colname4]]
|
||||
# , colour = "white") +
|
||||
# geom_tile(aes(,-2, width = 0.95, height = 0.3)
|
||||
# , fill = bar[[aa_colour_colname3]]
|
||||
# , colour = "white"
|
||||
# )+
|
||||
# geom_tile(aes(,-2.1, width = 0.95, height = 0.35)
|
||||
# , fill = bar[[aa_colour_colname2]]
|
||||
# , colour = "white"
|
||||
# )+
|
||||
# geom_tile(aes(,-2.2, width = 0.95, height = 0.45)
|
||||
# , fill = bar[[aa_colour_colname1]]
|
||||
# , colour = "white"
|
||||
# )
|
||||
|
||||
g1 = g + theme( axis.text.x = element_text(size = 10
|
||||
, angle = 90
|
||||
, hjust = 1
|
||||
, vjust = 0.4
|
||||
, face = "bold"
|
||||
#, colour = aa_pos_colours
|
||||
)
|
||||
, axis.text.y = element_text(size = 12
|
||||
|
@ -92,12 +91,128 @@ g1 = g0 + theme( axis.text.x = element_text(size = 10
|
|||
, panel.grid.minor = element_line(color = "black")) +
|
||||
guides(colour = guide_legend(title = "Consurf"
|
||||
, position = "top"
|
||||
#, direction = "horizontal"
|
||||
#, direction = "horizontal"
|
||||
)) +
|
||||
labs(title = ""
|
||||
, x = "Wild-type position"
|
||||
#, x = "Wild-type position"
|
||||
, x = ""
|
||||
, y = "Consurf score")
|
||||
|
||||
g1
|
||||
|
||||
##########################################
|
||||
# add tile afterwards
|
||||
g2 = g1 + geom_tile(aes(,-1.7, width = 0.95, height = 0.3)
|
||||
, fill = bar$ligD_colours
|
||||
, colour = "black")
|
||||
g2
|
||||
|
||||
g3 = g2 +
|
||||
geom_tile(aes(,-1.9, width = 0.95, height = 0.3)
|
||||
, fill = bar[[aa_colour_colname4]]
|
||||
, colour = "white") +
|
||||
geom_tile(aes(,-2, width = 0.95, height = 0.3)
|
||||
, fill = bar[[aa_colour_colname3]]
|
||||
, colour = "white"
|
||||
)+
|
||||
geom_tile(aes(,-2.1, width = 0.95, height = 0.35)
|
||||
, fill = bar[[aa_colour_colname2]]
|
||||
, colour = "white"
|
||||
)+
|
||||
geom_tile(aes(,-2.2, width = 0.95, height = 0.35)
|
||||
, fill = bar[[aa_colour_colname1]]
|
||||
, colour = "white"
|
||||
)
|
||||
|
||||
g3
|
||||
|
||||
#==============================================
|
||||
#Multiple legends in a plot with geom_tile
|
||||
#==============================================
|
||||
|
||||
# https://stackoverflow.com/questions/24822621/multiple-legends-in-a-plot-with-geom-tile
|
||||
g_legend<-function(a.gplot){
|
||||
tmp <- ggplot_gtable(ggplot_build(a.gplot))
|
||||
leg <- which(sapply(tmp$grobs, function(x) x$name) == "guide-box")
|
||||
legend <- tmp$grobs[[leg]]
|
||||
legend
|
||||
}
|
||||
|
||||
legend1 = g_legend(g1)
|
||||
|
||||
g2 = g1 + geom_tile(aes(,-1.7, width = 0.95, height = 0.3)
|
||||
, fill = bar$ligD_colours
|
||||
, colour = "black")
|
||||
|
||||
g2
|
||||
|
||||
legend2 = g_legend(g2)
|
||||
|
||||
grid.arrange(g1+theme(legend.position = 'none')
|
||||
#, legend1
|
||||
, legend2
|
||||
, ncol = 2
|
||||
, widths=c(4/6, 1/6))
|
||||
###############################################################
|
||||
###############################################################
|
||||
|
||||
lig_min = min(round(bar[[LigDist_colname]])); lig_min
|
||||
lig_max = max(round(bar[[LigDist_colname]])); lig_max
|
||||
lig_mean = round(mean(bar[[LigDist_colname]])); lig_mean
|
||||
labels = seq(lig_min, lig_max, len = 5); labels
|
||||
labelsD = round(labels, digits = 0); labelsD
|
||||
|
||||
g = ggplot(bar, aes( x = factor(.data[[aa_position_colname]])
|
||||
, y = .data[[LigDist_colname]]))
|
||||
g
|
||||
# yayy
|
||||
g1 = g + geom_tile(aes(fill = .data[[LigDist_colname]])
|
||||
, colour = "white") +
|
||||
#scale_fill_gradient(low = "green", high = "red")
|
||||
scale_fill_gradient2(midpoint = lig_mean
|
||||
, low = "green"
|
||||
, mid = "yellow"
|
||||
, high = "red"
|
||||
, breaks = labels
|
||||
#, n.breaks = 11
|
||||
#, minor_breaks = c(2, 4, 6, 8, 10)
|
||||
, limits = c(lig_min, lig_max)
|
||||
, labels = labelsD
|
||||
, name = "Ligand Distance")
|
||||
g1
|
||||
|
||||
|
||||
main_leg = g_legend(g2)
|
||||
main_leg
|
||||
|
||||
ligD_leg = g_legend(g1)
|
||||
grid.arrange(ligD_leg
|
||||
, ncol = 2
|
||||
, widths=c(4/6, 1/6))
|
||||
|
||||
grid.arrange(g2+theme(legend.position = 'none')
|
||||
, main_leg
|
||||
, ligD_leg
|
||||
, ncol = 3
|
||||
, widths=c(9/10, 0.5/10, 0.5/10))
|
||||
|
||||
|
||||
##########################
|
||||
g3 = g2 + theme(legend.position = 'none')
|
||||
g3
|
||||
g4 = g3 + geom_tile(aes(fill = .data[['consurf_score']])
|
||||
, colour = "white")
|
||||
|
||||
g4 + geom_tile(scale_fill_gradient(consurf_palette2)
|
||||
|
||||
|
||||
midpoint = lig_mean
|
||||
, low = "green"
|
||||
, mid = "yellow"
|
||||
, high = "red"
|
||||
, breaks = labels
|
||||
#, n.breaks = 11
|
||||
#, minor_breaks = c(2, 4, 6, 8, 10)
|
||||
, limits = c(lig_min, lig_max)
|
||||
, labels = labelsD
|
||||
, name = "Ligand Distance")
|
||||
g1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue