LSHTM_analysis/scripts/plotting/plotting_thesis/pe_sens_site_count.R

78 lines
2.8 KiB
R

##############################################################
# PE count
##############################################################
rects <- data.frame(x = 1:6,
colors = c("#ffd700" #gold
, "#f0e68c" #khaki
, "#da70d6"# orchid
, "#ff1493"# deeppink
, "#00BFC4" #, "#007d85" #blue
, "#F8766D" )# red,
)
rects
rects$text = c("-ve Lig"
, "+ve Lig"
, "+ve PPI2"
, "-ve PPI2"
, "+ve stability"
, "-ve stability")
# FOR EMBB ONLY
rects$numbers = c(38, 0, 22, 9, 108, 681)
rects$num_labels = paste0("n=", rects$numbers)
rects
#https://stackoverflow.com/questions/47986055/create-a-rectangle-filled-with-text
peP = ggplot(rects, aes(x, y = 0, fill = colors, label = paste0(text,"\n", num_labels))) +
geom_tile(width = 1, height = 1) + # make square tiles
geom_text(color = "black", size = 1.7) + # add white text in the middle
scale_fill_identity(guide = "none") + # color the tiles with the colors in the data frame
coord_fixed() + # make sure tiles are square
coord_flip()+ scale_x_reverse() +
# theme_void() # remove any axis markings
theme_nothing() # remove any axis markings
peP
peP2 = ggplot(rects, aes(x, y = 0, fill = colors, label = paste0(text,"\n", num_labels))) +
geom_tile() + # make square tiles
geom_text(color = "black", size = 1.6) + # add white text in the middle
scale_fill_identity(guide = "none") + # color the tiles with the colors in the data frame
coord_fixed() + # make sure tiles are square
theme_nothing() # remove any axis markings
peP2
########################################################
# MANUAL process
#===============================
# Sensitivity count: Site
#==============================
table(df3$sensitivity)
#--------
# embb
#--------
#rsc = 54
#ccc = 46
#ssc = 470
rect_rs_siteC =data.frame(mutation_class=c("A_Resistant sites"
, "B_Common sites"
, "C_Sensitive sites"),
tile_colour =c("red",
"purple",
"blue"),
numbers = c(rsc, ccc, ssc),
order = c(1, 2, 3))
rect_rs_siteC$labels = paste0(rect_rs_siteC$mutation_class, "\nn=", rect_rs_siteC$ numbers)
sens_siteP = ggplot(rect_rs_siteC, aes(mutation_class, y = 0,
fill = tile_colour,
label = paste0("n=", numbers))) +
geom_tile(width = 1, height = 1) +
geom_label(color = "black", size = 1.7,fill = "white", alpha=0.7) +
theme_nothing()
sens_siteP