dadded v2 of barplot layput

This commit is contained in:
Tanushree Tunstall 2022-08-14 22:56:08 +01:00
parent da8f8d90d4
commit 7c40e13771
7 changed files with 800 additions and 79 deletions

View file

@ -39,12 +39,12 @@ class(merged_df3)
merged_df3 = as.data.frame(merged_df3)
class(df3)
head(df3$pos_count)
head(merged_df3$pos_count)
nc_pc_CHANGE = which(colnames(merged_df3)== "pos_count")
colnames(merged_df3)[nc_pc_CHANGE] = "df2_pos_count_all"
head(merged_df3$pos_count)
head(merged_df3$pos_count_all)
head(merged_df3$df2_pos_count_all)
# DROP pos_count column
# merged_df3$pos_count <-NULL
@ -247,11 +247,6 @@ snap2P = stability_count_bp(plotdf = df3
#
# dev.off()
###########################################################
#=========================
# Affinity outcome
@ -285,7 +280,7 @@ mLigP = stability_count_bp(plotdf = df3_lig
, bar_fill_values = c("#F8766D", "#00BFC4")
, sts = sts
, subtitle_colour= subtitle_colour
, bp_plot_title = paste(common_bp_title, "ligand")
#, bp_plot_title = paste(common_bp_title, "ligand")
)
#------------------------------
@ -304,7 +299,7 @@ mmLigP = stability_count_bp(plotdf = df3_lig
, bar_fill_values = c("#F8766D", "#00BFC4")
, sts = sts
, subtitle_colour= subtitle_colour
, bp_plot_title = paste(common_bp_title, "ligand")
#, bp_plot_title = paste(common_bp_title, "ligand")
)
#------------------------------
@ -485,46 +480,43 @@ dev.off()
#####################################################################
# test
setDT(df3)[, pos_count2 := .N, by = .(eval(parse(text = "position")))]
foo = df3[, c("mutationinformation", "position")]
df4 = foo[, c("mutationinformation", "position")]
var_pos = "position"
df4 =
df4 %>%
dplyr::add_count(eval(parse(text = var_pos)))
class(df4)
df4 = as.data.frame(df4)
class(df4)
nc_change = which(colnames(df4) == "n")
colnames(df4)[nc_change] <- "pos_count"
class(df4)
setDT(df4)[, pos_count2 := .N, by = .(eval(parse(text = "position")))]
class(df4)
all(df4$pos_count==df4$pos_count2)
# %>%
#group_by(pos_count = position)
#
# setDT(df3)[, pos_count2 := .N, by = .(eval(parse(text = "position")))]
# foo = df3[, c("mutationinformation", "position")]
# df4 = foo[, c("mutationinformation", "position")]
#
#
# var_pos = "position"
# df4 =
# df4 %>%
# dplyr::group_by(position) %>%
# count(position)
foo2 = df4[, c("mutationinformation", "position", "pos_count")]
# dplyr::add_count(eval(parse(text = var_pos)))
#
# class(df4)
# df4 = as.data.frame(df4)
# class(df4)
# nc_change = which(colnames(df4) == "n")
# colnames(df4)[nc_change] <- "pos_count"
# class(df4)
#
# setDT(df4)[, pos_count2 := .N, by = .(eval(parse(text = "position")))]
# class(df4)
#
# all(df4$pos_count==df4$pos_count2)
#
# # %>%
# #group_by(pos_count = position)
#
# # df4 =
# # df4 %>%
# # dplyr::group_by(position) %>%
# # count(position)
#foo2 = df4[, c("mutationinformation", "position", "pos_count")]
#####################################################################
# ------------------------------
# bp site site count: ALL
# <10 Ang ligand
# ------------------------------
posC_all = site_snp_count_bp(plotdf = df3
, df_colname = "position"
, xaxis_title = "Number of nsSNPs"
@ -541,9 +533,10 @@ posC_lig = site_snp_count_bp(plotdf = df3_lig
, df_colname = "position"
, xaxis_title = "Number of nsSNPs"
, yaxis_title = "Number of Sites"#+ annotate("text", x = 1.5, y = 2.2, label = "Text No. 1")
, subtitle_text = paste0(common_bp_title, " ligand")
, subtitle_size = 20
#, subtitle_text = paste0(common_bp_title, " ligand")
, subtitle_size = 8
, subtitle_colour = subtitle_colour)
posC_lig
# ------------------------------
# bp site site count: ppi2
# < 10 Ang interface
@ -556,7 +549,7 @@ posC_ppi2 = site_snp_count_bp(plotdf = df3_ppi2
, subtitle_text = paste0(common_bp_title, " interface")
, subtitle_size = 20
, subtitle_colour = subtitle_colour)
posC_ppi2
# ------------------------------
#FIXME: bp site site count: na
# < 10 Ang TBC
@ -571,23 +564,23 @@ posC_ppi2 = site_snp_count_bp(plotdf = df3_ppi2
# output: SITE SNP count:
# all + affinity
#==========================
my_label_size = 25
pos_count_combined_CLP = paste0(outdir_images
,tolower(gene)
,"_pos_count_PS_AFF.svg")
svg(pos_count_combined_CLP, width = 20, height = 5.5)
print(paste0("plot filename:", pos_count_combined_CLP))
cowplot::plot_grid(posC_all, posC_lig, posC_ppi2
#, posC_na
, nrow = 1
, ncol = 3
, labels = "AUTO"
, label_size = my_label_size)
dev.off()
# my_label_size = 25
# pos_count_combined_CLP = paste0(outdir_images
# ,tolower(gene)
# ,"_pos_count_PS_AFF.svg")
#
#
# svg(pos_count_combined_CLP, width = 20, height = 5.5)
# print(paste0("plot filename:", pos_count_combined_CLP))
#
# cowplot::plot_grid(posC_all, posC_lig, posC_ppi2
# #, posC_na
# , nrow = 1
# , ncol = 3
# , labels = "AUTO"
# , label_size = my_label_size)
#
# dev.off()
#===============================================================

View file

@ -0,0 +1,292 @@
#!/usr/bin/env Rscript
#########################################################
# TASK: Barplots for mCSM DUET, ligand affinity, and foldX
# basic barplots with count of mutations
# basic barplots with frequency of count of mutations
# , df_colname = ""
# , leg_title = ""
# , ats = 25 # axis text size
# , als = 22 # axis label size
# , lts = 20 # legend text size
# , ltis = 22 # label title size
# , geom_ls = 10 # geom_label size
# , yaxis_title = "Number of nsSNPs"
# , bp_plot_title = ""
# , label_categories = c("Destabilising", "Stabilising")
# , title_colour = "chocolate4"
# , subtitle_text = NULL
# , sts = 20
# , subtitle_colour = "pink"
# #, leg_position = c(0.73,0.8) # within plot area
# , leg_position = "top"
# , bar_fill_values = c("#F8766D", "#00BFC4")
#########################################################
#=============
# Data: Input
#==============
#source("~/git/LSHTM_analysis/config/alr.R")
source("~/git/LSHTM_analysis/config/embb.R")
#source("~/git/LSHTM_analysis/config/katg.R")
#source("~/git/LSHTM_analysis/config/gid.R")
#source("~/git/LSHTM_analysis/config/pnca.R")
#source("~/git/LSHTM_analysis/config/rpob.R")
source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R")
source("~/git/LSHTM_analysis/scripts/plotting/plotting_colnames.R")
class(merged_df3)
merged_df3 = as.data.frame(merged_df3)
class(df3)
head(merged_df3$pos_count)
nc_pc_CHANGE = which(colnames(merged_df3)== "pos_count"); nc_pc_CHANGE
colnames(merged_df3)[nc_pc_CHANGE] = "df2_pos_count_all"
head(merged_df3$pos_count)
head(merged_df3$df2_pos_count_all)
# DROP pos_count column
# merged_df3$pos_count <-NULL
merged_df3 = merged_df3[, !colnames(merged_df3)%in%c("pos_count")]
head(merged_df3$pos_count)
df3 = merged_df3[, colnames(merged_df3)%in%plotting_cols]
#=======
# output
#=======
outdir_images = paste0("~/git/Writing/thesis/images/results/", tolower(gene), "/")
cat("plots will output to:", outdir_images)
###########################################################
#------------------------------
# plot default sizes
#------------------------------
#=========================
# Affinity outcome
# check this var: outcome_cols_affinity
# get from preformatting or put in globals
#==========================
DistCutOff
LigDist_colname # = "ligand_distance" # from globals
ppi2Dist_colname
naDist_colname
###########################################################
# get plotting data within the distance
df3_lig = df3[df3[[LigDist_colname]]<DistCutOff,]
df3_ppi2 = df3[df3[[ppi2Dist_colname]]<DistCutOff,]
df3_na = df3[df3[[naDist_colname]]<DistCutOff,]
common_bp_title = paste0("Sites <", DistCutOff, angstroms_symbol)
#------------------------------
# barplot for ligand affinity:
# <10 Ang of ligand
#------------------------------
mLigP = stability_count_bp(plotdf = df3_lig
, df_colname = "ligand_outcome"
#, leg_title = "mCSM-lig"
#, bp_plot_title = paste(common_bp_title, "ligand")
, yaxis_title = "Number of nsSNPs"
, leg_position = "none"
, subtitle_text = "mCSM-lig"
, bar_fill_values = c("#F8766D", "#00BFC4")
, subtitle_colour= "black"
, sts = 10
, lts = 8
, ats = 12
, als = 11
, ltis = 11
, geom_ls = 2.5)
mLigP
#------------------------------
# barplot for ligand affinity:
# <10 Ang of ligand
# mmCSM-lig: will be the same no. of sites but the effect will be different
#------------------------------
mmLigP = stability_count_bp(plotdf = df3_lig
, df_colname = "mmcsm_lig_outcome"
#, leg_title = "mmCSM-lig"
#, label_categories = labels_mmlig
#, bp_plot_title = paste(common_bp_title, "ligand")
, yaxis_title = ""
, leg_position = "none"
, subtitle_text = "mmCSM-lig"
, bar_fill_values = c("#F8766D", "#00BFC4")
, subtitle_colour= "black"
, sts = 10
, lts = 8
, ats = 12
, als = 11
, ltis = 11
, geom_ls = 2.5
)
mmLigP
#------------------------------
# barplot for ppi2 affinity
# <10 Ang of interface
#------------------------------
ppi2P = stability_count_bp(plotdf = df3_ppi2
, df_colname = "mcsm_ppi2_outcome"
#, leg_title = "mCSM-ppi2"
#, label_categories = labels_ppi2
#, bp_plot_title = paste(common_bp_title, "PP-interface")
, yaxis_title = "Number of nsSNPs"
, leg_position = "none"
, subtitle_text = "mCSM-ppi2"
, bar_fill_values = c("#F8766D", "#00BFC4")
, subtitle_colour= "black"
, sts = 10
, lts = 8
, ats = 12
, als = 11
, ltis = 11
, geom_ls = 2.5
)
ppi2P
#####################################################################
# ------------------------------
# bp site site count: mCSM-lig
# < 10 Ang ligand
# ------------------------------
common_bp_title = paste0("Sites <", DistCutOff, angstroms_symbol)
posC_lig = site_snp_count_bp(plotdf = df3_lig
, df_colname = "position"
, xaxis_title = "Number of nsSNPs"
, yaxis_title = "Number of Sites"
, subtitle_colour = "chocolate4"
, subtitle_text = ""
, subtitle_size = 8
, geom_ls = 2.6
, leg_text_size = 10
, axis_text_size = 10
, axis_label_size = 10)
posC_lig
# ------------------------------
# bp site site count: ppi2
# < 10 Ang interface
# ------------------------------
posC_ppi2 = site_snp_count_bp(plotdf = df3_ppi2
, df_colname = "position"
, xaxis_title = "Number of nsSNPs"
, yaxis_title = "Number of Sites"
, subtitle_colour = "chocolate4"
, subtitle_text = ""
, subtitle_size = 8
, geom_ls = 2.6
, leg_text_size = 10
, axis_text_size = 10
, axis_label_size = 10)
posC_ppi2
#===============================================================
# 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 affinty"
, "+ve Lig affinity"
, "+ve PPI2 affinity"
, "-ve PPI2 affinity"
, "+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
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
# ------------------------------
# bp site site count: ALL
# <10 Ang ligand
# ------------------------------
posC_all = site_snp_count_bp(plotdf = df3
, df_colname = "position"
, xaxis_title = "Number of nsSNPs"
, yaxis_title = "Number of Sites"
, subtitle_colour = "chocolate4"
, subtitle_text = "All mutations sites"
, subtitle_size = 8
, geom_ls = 2.6
, leg_text_size = 10
, axis_text_size = 10
, axis_label_size = 10)
##################################################################
#------------------------------
# barplot for sensitivity:
#------------------------------
senP = stability_count_bp(plotdf = df3
, df_colname = "sensitivity"
#, leg_title = "mCSM-ppi2"
#, label_categories = labels_ppi2
#, bp_plot_title = paste(common_bp_title, "PP-interface")
, yaxis_title = "Number of nsSNPs"
, leg_position = "none"
, subtitle_text = "Sensitivity"
, bar_fill_values = c("red", "blue")
, subtitle_colour= "black"
, sts = 10
, lts = 8
, ats = 12
, als = 11
, ltis = 11
, geom_ls = 2.5
)
consurfP = stability_count_bp(plotdf = df3
, df_colname = "consurf_outcome"
#, leg_title = "ConSurf"
#, label_categories = labels_consurf
, yaxis_title = "Number of nsSNPs"
, leg_position = "top"
, subtitle_text = "ConSurf"
, bar_fill_values = consurf_colours # from globals
, subtitle_colour= "black"
, sts = 10
, lts = 8
, ats = 12
, als = 11
, ltis = 11
, geom_ls = 2.5)
consurfP

View file

@ -0,0 +1,237 @@
mLigP
mmLigP
posC_lig
ppi2P
posC_ppi2
peP
pe_allCL
theme_georgia <- function(...) {
theme_gray(base_family = "sans", ...) +
theme(plot.title = element_text(face = "bold"))
}
title_theme <- calc_element("plot.title", theme_georgia())
###############################################################
common_bp_title = paste0("Sites <", DistCutOff, angstroms_symbol)
# extract common legend
common_legend_outcome = get_legend(mLigP +
guides(color = guide_legend(nrow = 1)) +
theme(legend.position = "top"))
###############################################################
#================================
# Lig Affinity: outcome + site
#================================
ligT = paste0(common_bp_title, " ligand")
lig_affT = ggdraw() +
draw_label(
ligT,
fontfamily = title_theme$family,
fontface = title_theme$face,
#size = title_theme$size
size = 8
)
#-------------
# Outplot
#-------------
ligaffP = paste0(outdir_images
,tolower(gene)
,"_lig_oc.png")
#svg(affP, width = 20, height = 5.5)
print(paste0("plot filename:", ligaffP))
png(ligaffP, units = "in", width = 6, height = 4, res = 300 )
cowplot::plot_grid(cowplot::plot_grid(lig_affT,common_legend_outcome,
nrow = 2,
rel_heights = c(1,1)
),
cowplot::plot_grid(mLigP, mmLigP, posC_lig
, nrow = 1
#, labels = c("A", "B", "C","D")
, rel_widths = c(1,1,1.8)
, align = "h"),
nrow = 2,
labels = c("A", ""),
label_size = 12,
rel_heights = c(1,8))
dev.off()
#############################################################
#================================
# PPI2 Affinity: outcome + site
#================================
ppi2T = paste0(common_bp_title, " PP-interface")
ppi2_affT = ggdraw() +
draw_label(
ppi2T,
fontfamily = title_theme$family,
fontface = title_theme$face,
#size = title_theme$size
size = 8
)
#-------------
# Outplot: PPI2
#-------------
ppiaffP = paste0(outdir_images
,tolower(gene)
,"_ppi2_oc.png")
#svg(affP, width = 20, height = 5.5)
print(paste0("plot filename:", ppiaffP))
png(ppiaffP, units = "in", width = 6, height = 4, res = 300 )
cowplot::plot_grid(cowplot::plot_grid(ppi2_affT, common_legend_outcome,
nrow = 2,
rel_heights = c(1,1)),
cowplot::plot_grid(ppi2P, posC_ppi2
, nrow = 1
, rel_widths = c(1.2,1.8)
, align = "h"
, label_size = my_label_size),
nrow = 2,
labels = c("B", ""),
label_size = 12,
rel_heights = c(1,8)
)
dev.off()
#############################################################
peP # pe counts
#================================
# PE + All position count
#================================
peT_allT = ggdraw() +
draw_label(
paste0("All mutation sites"),
fontfamily = title_theme$family,
fontface = title_theme$face,
#size = title_theme$size
size = 8
)
#-------------
# Outplot: PPI2
#-------------
pe_allCL = paste0(outdir_images
,tolower(gene)
,"_pe_oc.png")
#svg(affP, width = 20, height = 5.5)
print(paste0("plot filename:", pe_allCL))
png(pe_allCL, units = "in", width = 6, height = 4, res = 300 )
cowplot::plot_grid(peT_allT,
cowplot::plot_grid(peP, posC_all
, nrow = 1
, rel_widths = c(1, 2)
, align = "h"),
nrow = 2,
labels = c("C", "", ""),
label_size = 12,
rel_heights = c(1,8))
dev.off()
#===========================================
# COMBINE ALL three
#==========================================
p1 = cowplot::plot_grid(cowplot::plot_grid(lig_affT,common_legend_outcome, nrow=2),
cowplot::plot_grid(mLigP, mmLigP, posC_lig
, nrow = 1
, rel_widths = c(1,1,1.8)
, align = "h"),
nrow = 2,
rel_heights = c(1,8)
)
p2 = cowplot::plot_grid(cowplot::plot_grid(ppi2_affT, common_legend_outcome, nrow=2),
cowplot::plot_grid(ppi2P, posC_ppi2
, nrow = 1
, rel_widths = c(1.2,1.8)
, align = "h"),
nrow = 2,
rel_heights = c(1,8)
)
p3 = cowplot::plot_grid(cowplot::plot_grid(peT_allT, nrow = 2
, rel_widths = c(1,3),axis = "lr"),
cowplot::plot_grid(
peP2, posC_all,
nrow = 2,
rel_widths = c(1,1),
align = "v",
axis = "lr",
rel_heights = c(1,8)
),
rel_heights = c(1,10),
nrow = 2,axis = "lr")
#===============
# Final combine
#===============
w = 11.75
h = 3.7
mut_impact_CLP = paste0(outdir_images
,tolower(gene)
,"_mut_impactCLP.png")
#svg(affP, width = 20, height = 5.5)
print(paste0("plot filename:", mut_impact_CLP))
png(mut_impact_CLP, units = "in", width = w, height = h, res = 300 )
cowplot::plot_grid(p1, p2, p3
, nrow = 1
, labels = "AUTO"
, label_size = 12
, rel_widths = c(3,2,2)
#, rel_heights = c(1)
)
dev.off()
##################################################
sensP
consurfP
#=================
# Combine sensitivity + ConSurf
# or ConSurf
#=================
w = 3
h = 3
# sens_conP = paste0(outdir_images
# ,tolower(gene)
# ,"_sens_cons_CLP.png")
#
# print(paste0("plot filename:", sens_conP))
# png(sens_conP, units = "in", width = w, height = h, res = 300 )
#
# cowplot::plot_grid(sensP, consurfP,
# nrow = 2,
# rel_heights = c(1, 1.5)
# )
#
# dev.off()
conCLP = paste0(outdir_images
,tolower(gene)
,"_consurf_BP.png")
print(paste0("plot filename:", sens_conP))
png(sens_conP, units = "in", width = w, height = h, res = 300 )
consurfP
dev.off()

View 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..")
####################################################

View file

@ -153,13 +153,20 @@ for (i in unique(str_df$position) ){
# ends with suffix 2 if dups
str_df$effect_type = sub("\\.[0-9]+", "", str_df$effect_type) # cull duplicate effect types that happen when there are exact duplicate values
colnames(str_df)
#================
# for Plots
#================
str_df_short = str_df[, c("mutationinformation","position","sensitivity"
, "effect_type"
, "effect_sign")]
# check
str_df_check = str_df[str_df$position%in%c(24, 32,160, 303, 334 ),]
str_df_check = str_df[str_df$position%in%c(24, 32,160, 303, 334),]
table(str_df$effect_type)
#-------------------------------------
# get df with uniqye position
# get df with unique position
#--------------------------------------
#data[!duplicated(data$x), ]
str_df_plot = str_df[!duplicated(str_df$position),]
@ -234,7 +241,7 @@ table(str_df_plot_cols$colour_map)
#-------------------
# Ligand Affinity
#-------------------
foo = str_df_plot_cols[str_df_plot_cols$colours=="light_salmon",]
foo = str_df_plot_cols[str_df_plot_cols$colours=="yellow",]
all(foo2$effect_sign == 1)
foo1 = str_df_plot_cols[str_df_plot_cols$colours=="bright_salmon",]