dadded v2 of barplot layput
This commit is contained in:
parent
da8f8d90d4
commit
7c40e13771
7 changed files with 800 additions and 79 deletions
182
scripts/plotting/plotting_thesis/bp_PE.R
Normal file
182
scripts/plotting/plotting_thesis/bp_PE.R
Normal file
|
@ -0,0 +1,182 @@
|
|||
colnames(str_df_short)
|
||||
table(str_df_short$effect_type)
|
||||
table(str_df_short$effect_sign)
|
||||
|
||||
str(str_df_short)
|
||||
|
||||
str_df_short$pe_outcome = ifelse(str_df_short$effect_sign<0, "DD", "SS")
|
||||
table(str_df_short$pe_outcome )
|
||||
table(str_df_short$effect_sign)
|
||||
|
||||
affcols = c("affinity_scaled", "mmcsm_lig_scaled")
|
||||
ppi2_cols = c("mcsm_ppi2_scaled")
|
||||
|
||||
#lig
|
||||
table(str_df_short$effect_type)
|
||||
|
||||
str_df_short$effect_grouped = ifelse(str_df_short$effect_type%in%affcols
|
||||
, "affinity"
|
||||
, str_df_short$effect_type)
|
||||
table(str_df_short$effect_grouped)
|
||||
|
||||
#ppi2
|
||||
str_df_short$effect_grouped = ifelse(str_df_short$effect_grouped%in%ppi2_cols
|
||||
, "ppi2"
|
||||
, str_df_short$effect_grouped)
|
||||
table(str_df_short$effect_grouped)
|
||||
|
||||
#stability
|
||||
str_df_short$effect_grouped = ifelse(!str_df_short$effect_grouped%in%c("affinity", "ppi2")
|
||||
, "stability"
|
||||
, str_df_short$effect_grouped)
|
||||
|
||||
table(str_df_short$effect_grouped)
|
||||
|
||||
|
||||
# create a sign as well
|
||||
str_df_short$effect_outcome = paste0(str_df_short$pe_outcome
|
||||
, str_df_short$effect_grouped)
|
||||
|
||||
table(str_df_short$effect_outcome)
|
||||
|
||||
pe_colour_map2 = c( "DDaffinity" = "#ffd700" # gold
|
||||
, "SSaffinity" = "#f0e68c" # khaki
|
||||
, "DDppi2" = "#ff1493" # deeppink
|
||||
, "SSppi2" = "#da70d6" # orchid
|
||||
, "DDstability " = "#ae301e"
|
||||
, "SSstability" = "#007d85"
|
||||
)
|
||||
|
||||
|
||||
str_df_short$effect_colours = str_df_short$effect_outcome
|
||||
|
||||
str_df_short = dplyr::mutate(str_df_short
|
||||
, effect_colours = case_when(effect_colours == "DDaffinity" ~ "#ffd700"
|
||||
, effect_colours == "DDppi2" ~ '#ff1493'
|
||||
, effect_colours == "SSppi2" ~ '#da70d6'
|
||||
, effect_colours == "DDstability" ~ '#ae301e'
|
||||
, effect_colours =="SSstability" ~ '#007d85'
|
||||
, TRUE ~ 'ns'))
|
||||
|
||||
"#F8766D" #red
|
||||
"#00BFC4" #blue
|
||||
table(str_df_short$effect_colours)
|
||||
|
||||
|
||||
###########################################
|
||||
|
||||
ggplot(str_df_short
|
||||
, aes( x=effect_grouped
|
||||
, fill = effect_colours)) +
|
||||
geom_bar() +
|
||||
scale_fill_manual(values = str_df_short$effect_colours)
|
||||
|
||||
|
||||
|
||||
first_col = c(38, 0)
|
||||
second_col = c(9, 22)
|
||||
third_col = c(681, 108)
|
||||
thing_df = data.frame(first_row, second_row, third_row)
|
||||
rownames(thing_df) = c("Destabilising","Stabilising")
|
||||
thing_df
|
||||
|
||||
|
||||
###############################################
|
||||
rect_colour_map = c("EMB" = "green"
|
||||
,"DSL" = "slategrey"
|
||||
, "CDL" = "navyblue"
|
||||
, "Ca" = "purple")
|
||||
|
||||
|
||||
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 affinty"
|
||||
, "+ve Lig affinity"
|
||||
, "+ve PPI2 affinity"
|
||||
, "-ve PPI2 affinity"
|
||||
, "+ve stability"
|
||||
, "-ve stability")
|
||||
|
||||
|
||||
rects$numbers = c(38, 0, 22, 9, 108, 681)
|
||||
rects$num_labels = paste0("n=", rects$numbers)
|
||||
|
||||
rects
|
||||
|
||||
outdir_images = paste0("~/git/Writing/thesis/images/results/", tolower(gene), "/")
|
||||
|
||||
#https://stackoverflow.com/questions/47986055/create-a-rectangle-filled-with-text
|
||||
png(paste0(outdir_images, "test.png")
|
||||
, width = 0.5
|
||||
, height = 2.5
|
||||
, units = "in", res = 300)
|
||||
|
||||
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.5) + # 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
|
||||
|
||||
|
||||
dev.off()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##########################################################
|
||||
tile_map=data.frame(tile=c("EMB","DSL","CDL","Ca")
|
||||
,tile_colour =c("green","darkslategrey","navyblue","purple"))
|
||||
|
||||
|
||||
# great
|
||||
tile_colour_map = c("EMB" = "green"
|
||||
,"DSL" = "darkslategrey"
|
||||
, "CDL" = "navyblue"
|
||||
, "Ca" = "purple")
|
||||
|
||||
tile_legend=get_legend(
|
||||
|
||||
ggplot(tile_map, aes(factor(tile),y=0
|
||||
, colour=tile_colour
|
||||
, fill=tile_colour))+
|
||||
geom_tile() +
|
||||
theme(legend.direction="horizontal") +
|
||||
scale_colour_manual(name=NULL
|
||||
#, values = tile_map$tile_colour
|
||||
, values=tile_colour_map) +
|
||||
scale_fill_manual(name=NULL
|
||||
#,values=tile_map$tile_colour
|
||||
, values = tile_colour_map)
|
||||
)
|
||||
#############################################################
|
||||
|
||||
|
||||
###############################################
|
||||
library(ggplot2)
|
||||
library(viridis)
|
||||
library(hrbrthemes)
|
||||
|
||||
ggplot(str_df_short, aes(fill=effect_colours,x=effect_type)) +
|
||||
geom_bar() +
|
||||
|
||||
scale_fill_viridis(discrete = T) +
|
||||
ggtitle("Studying 4 species..")
|
||||
####################################################
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue