diff --git a/scripts/plotting/consurf_plot.R b/scripts/plotting/consurf_plot.R new file mode 100644 index 0000000..0d77bd2 --- /dev/null +++ b/scripts/plotting/consurf_plot.R @@ -0,0 +1,103 @@ +myColors1 = c("0" = "yellow2" + , "1" = "cyan1" + , "2" = "steelblue2" + , "3" = "cadetblue2" + , "4" = "paleturquoise2" + , "5" = "thistle3" + , "6" = "thistle2" + , "7" = "plum2" + , "8" = "maroon" + , "9" = "violetred2") + + +myColors2 = c("0" = "yellow2" + , "1" = "forestgreen" + , "2" = "seagreen3" + , "3" = "palegreen1" + , "4" = "darkseagreen2" + , "5" = "thistle3" + , "6" = "lightpink1" + , "7" = "orchid3" + , "8" = "orchid4" + , "9" = "darkorchid4") + + +#myColors <- colorRampPalette(c("cyan", "violetred4"))(9) +#myColors <- scale_color_brewer(palette = "Cyan-Magenta") +breaks <- levels(as.factor(mtcars$cyl)) +colours <- ifelse(breaks == 4, "red", "blue") + +aa_position_colname = "position" +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" )) +bar = merged_df3 +bar[['lab_bg']] = ifelse(bar[[aa_position_colname]]%in%rna_bind_aa_pos + , "purple" + , ifelse(bar[[aa_position_colname]]%in%binding_aa_pos + , "orange", "white" )) +head(bar[[aa_position_colname]]) +head(bar[['lab_bg']]) + +#bar2 = as.data.frame(cbind(bar[[aa_position]], bar[['lab_bg']]) ) + + + + +#geom_tile(aes(,-0.8, width = 0.95, height = 0.85) +# , fill = df$lab_bg) + +#geom_tile(aes(,-1.2, width = 0.95, height = -0.2) +# , fill = df$lab_bg2) + +my_xlim = length(unique(bar$position)); my_xlim + +ymin = min(bar$consurf_score) +ymax = max(bar$consurf_score) + +g = ggplot(bar, aes(x = factor(position) + , y = consurf_score + , colour = factor(consurf_colour_rev))) + + + coord_cartesian(xlim = c(1, my_xlim) + , ylim = c(ymin, ymax) + , clip = "off") + + geom_point() + + #scale_colour_manual( values = myColors1) + + scale_colour_manual( values = myColors2) + + 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 + , angle = 90 + , hjust = 1 + , vjust = 0.4 + #, colour = aa_pos_colours + ) + , axis.text.y = element_text(size = 12 + , angle = 0 + , hjust = 1 + , vjust = 0) + , axis.title.x = element_text(size = 12) + , axis.title.y = element_text(size =12 ) + , panel.background = element_rect(fill = "black", color = "black") + , panel.grid.major = element_line(color = "black") + , panel.grid.minor = element_line(color = "black")) + + guides(colour = guide_legend(title = "Consurf" + , position = "top" + #, direction = "horizontal" + )) + + labs(title = "" + , x = "Position" + , y = "Consurf_score") + +g1 + + + +##########################################