various heat-bar/position tile faff
This commit is contained in:
parent
94454d6fba
commit
5cbaef3d36
4 changed files with 140 additions and 48 deletions
|
@ -2,7 +2,7 @@
|
|||
# 1b: Define function: coloured barplot by subgroup
|
||||
# LINK: https://stackoverflow.com/questions/49818271/stacked-barplot-with-colour-gradients-for-each-bar
|
||||
#########################################################
|
||||
source("~/git/LSHTM_analysis/scripts/functions/generate_distance_colour_map.R")
|
||||
#source("~/git/LSHTM_analysis/scripts/functions/generate_distance_colour_map.R")
|
||||
|
||||
ColourPalleteMulti = function(df, group, subgroup){
|
||||
|
||||
|
@ -121,16 +121,16 @@ bp_stability_hmap <- function(plotdf = merged_df3
|
|||
, axis.title.y = element_text(size = my_yaxts )
|
||||
, plot.title = element_text(size = my_pts
|
||||
, hjust = 0.5)) +
|
||||
|
||||
labs(title = p_title
|
||||
, x = my_xlab
|
||||
, y = my_ylab),
|
||||
geom_tile(aes(, tpos0 # heat-mapped distance tiles along the bot
|
||||
, width = tW0
|
||||
, height = tH0)
|
||||
, fill = plotdf$ligD_colours
|
||||
, colour = plotdf$ligD_colours
|
||||
, linetype = "blank") +
|
||||
|
||||
labs(title = p_title
|
||||
, x = my_xlab
|
||||
, y = my_ylab),
|
||||
, linetype = "blank"), #end of distance-heat-bar
|
||||
generate_distance_legend(plotdf),
|
||||
ncol = 2,
|
||||
#align = "hv",
|
||||
|
|
|
@ -69,17 +69,17 @@ LogoPlotCustomH <- function(plot_df
|
|||
# Data processing for logo plot
|
||||
#################################
|
||||
plot_df = generate_distance_colour_map(plot_df, debug=TRUE)
|
||||
|
||||
|
||||
unique_colour_map = unique(plot_df[,c("position","ligD_colours")])
|
||||
unique_colour_map = unique_colour_map[order(unique_colour_map$position), ]
|
||||
rownames(unique_colour_map) = unique_colour_map$position
|
||||
|
||||
|
||||
unique_colour_map2 = unique_colour_map
|
||||
unique_colour_map2$position=as.factor(unique_colour_map2$position)
|
||||
unique_colour_map2$ligD_colours = as.factor(unique_colour_map2$ligD_colours)
|
||||
|
||||
|
||||
|
||||
|
||||
if (rm_empty_y){
|
||||
plot_df = plot_df[!is.na(plot_df[y_axis_colname]),]
|
||||
cat("\nRemoving empty positions...\n")
|
||||
|
@ -171,20 +171,18 @@ LogoPlotCustomH <- function(plot_df
|
|||
, seq_type = "aa") +
|
||||
#ylab("my custom height") +
|
||||
theme( axis.ticks.x = element_blank()
|
||||
, axis.ticks.length = unit(0, "pt")
|
||||
, axis.title.x = element_blank()
|
||||
, axis.text.x = element_blank() # turn this off and the below on if you want to visually
|
||||
# , axis.text.x = element_blank() # turn this off and the below on if you want to visually
|
||||
# verify positions.
|
||||
# , axis.text.x = element_text(size = x_ats
|
||||
# , angle = x_tangle
|
||||
# , hjust = 1
|
||||
# , vjust = 0.4
|
||||
# , colour = xfont_bgc
|
||||
# , margin = margin(b=0)
|
||||
# )
|
||||
, axis.text.x = element_text(size = x_ats
|
||||
, angle = x_tangle
|
||||
, colour = xfont_bgc
|
||||
, vjust = 0.4
|
||||
, margin = margin(t=-8,r=0,b=0,l=0, unit="mm")
|
||||
)
|
||||
, axis.text.y = element_text(size = y_ats
|
||||
, angle = y_tangle
|
||||
, hjust = 1
|
||||
, vjust = 0
|
||||
, colour = yfont_bgc)
|
||||
, axis.title.y = element_text(size = y_tts
|
||||
, colour = ytt_col)
|
||||
|
@ -195,10 +193,11 @@ LogoPlotCustomH <- function(plot_df
|
|||
|
||||
, legend.position = leg_pos
|
||||
, legend.direction = leg_dir
|
||||
, plot.background = element_rect(fill = theme_bgc)
|
||||
#, plot.background = element_blank()
|
||||
, plot.margin = margin(b=0)
|
||||
, panel.grid=element_blank()
|
||||
, panel.background = element_rect(fill = theme_bgc)
|
||||
, plot.background = element_rect(fill = theme_bgc, colour=NA)
|
||||
, panel.background = element_rect(fill = "transparent", colour=NA)
|
||||
|
||||
)+
|
||||
|
||||
|
@ -217,36 +216,43 @@ LogoPlotCustomH <- function(plot_df
|
|||
, fill = position
|
||||
, colour = position
|
||||
, linetype = "blank"
|
||||
)
|
||||
)
|
||||
) +
|
||||
geom_tile() +
|
||||
theme(axis.text.x = element_text(size = x_ats
|
||||
, angle = x_tangle
|
||||
, hjust = 1
|
||||
, vjust = 0.4
|
||||
, colour = xfont_bgc)
|
||||
, axis.text.y = element_blank()
|
||||
, axis.ticks.y = element_blank()
|
||||
, axis.title.x = element_text(size = x_tts
|
||||
, colour = xtt_col)
|
||||
, axis.title.y = element_text(size = y_tts
|
||||
, colour = ytt_col)
|
||||
, legend.title = element_text(size = leg_tts
|
||||
, colour = ytt_col)
|
||||
, legend.text = element_text(size = leg_ts)
|
||||
|
||||
, legend.position = leg_pos
|
||||
, legend.direction = leg_dir
|
||||
, plot.background = element_rect(fill = theme_bgc)
|
||||
, plot.margin = margin(t=0)
|
||||
, panel.grid=element_blank()
|
||||
, panel.background = element_rect(fill = theme_bgc)
|
||||
theme(
|
||||
axis.text.x = element_blank()
|
||||
# axis.text.x = element_text(size = x_ats
|
||||
# , angle = x_tangle
|
||||
# , hjust = 1
|
||||
# , vjust = 0.4
|
||||
# , colour = xfont_bgc)
|
||||
, axis.text.y = element_blank()
|
||||
, axis.ticks.y = element_blank()
|
||||
, axis.ticks.x = element_blank()
|
||||
, axis.title.x = element_blank()
|
||||
, axis.title.y = element_text(size = y_tts
|
||||
, colour = ytt_col)
|
||||
, legend.title = element_text(size = leg_tts
|
||||
, colour = ytt_col)
|
||||
, legend.text = element_text(size = leg_ts)
|
||||
|
||||
, legend.position = leg_pos
|
||||
, legend.direction = leg_dir
|
||||
#, plot.background = element_blank()
|
||||
, plot.margin = margin(t=0,b=0)
|
||||
, panel.grid=element_blank()
|
||||
, plot.background = element_rect(fill = theme_bgc, colour=NA)
|
||||
, panel.background = element_rect(fill = "transparent", colour=NA)
|
||||
#, panel.background = element_rect(fill = theme_bgc)
|
||||
#, panel.background = element_blank()
|
||||
) +
|
||||
scale_x_discrete(x_lab, labels=factor(unique_colour_map$position)) +
|
||||
#scale_x_discrete(x_lab, labels=factor(unique_colour_map$position)) +
|
||||
scale_color_manual(values=unique_colour_map$ligD_colours) +
|
||||
scale_fill_manual(values=unique_colour_map$ligD_colours) +
|
||||
labs(y = NULL),
|
||||
ncol=1, align='v', rel_heights = c(8/10,1/10)
|
||||
labs(y = NULL), NULL,
|
||||
position_annotation(plot_df, bg=theme_bgc),
|
||||
|
||||
ncol=1, align='v', rel_heights = c(16,1,-0.1, 1)
|
||||
)
|
||||
}
|
||||
#LogoPlotCustomH(merged_df3)
|
||||
}
|
||||
#LogoPlotCustomH(small_df3)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue