moved barplot_colour_function.R to functions

This commit is contained in:
Tanushree Tunstall 2021-06-29 13:58:22 +01:00
parent 3d4ccc51d7
commit ac09cfc4e0
2 changed files with 23 additions and 0 deletions

View file

@ -1,27 +0,0 @@
#########################################################
# 1b: Define function: coloured barplot by subgroup
# LINK: https://stackoverflow.com/questions/49818271/stacked-barplot-with-colour-gradients-for-each-bar
#########################################################
ColourPalleteMulti <- function(df, group, subgroup){
# Find how many colour categories to create and the number of colours in each
categories <- aggregate(as.formula(paste(subgroup, group, sep="~" ))
, df
, function(x) length(unique(x)))
# return(categories) }
category.start <- (scales::hue_pal(l = 100)(nrow(categories))) # Set the top of the colour pallete
category.end <- (scales::hue_pal(l = 40)(nrow(categories))) # set the bottom
#return(category.start); return(category.end)}
# Build Colour pallette
colours <- unlist(lapply(1:nrow(categories),
function(i){
colorRampPalette(colors = c(category.start[i]
, category.end[i]))(categories[i,2])}))
return(colours)
}
#########################################################

View file

@ -89,6 +89,29 @@ note:
- fb flag has default if not supplied
- Short df being used in this i.e derivations from _df3
#========================
# barplots_subcolours.R
#=========================
#-----------------------------------------------------------------------
./barplots_subcolours.R -d streptomycin -g gid
#-----------------------------------------------------------------------
It replaces
## barplots_subcolours_PS.R
These have been moved to redundant/
sources:
## get_plotting_dfs.R
## functions/barplot_colour_function.R
outputs: 2 svgs in the plotdir
## barplot_coloured_PS.svg
## barplot_coloured_LIG.svg
note:
- fa flag has default if not supplied
- fb flag has default if not supplied
########################################################################
# TODO
Delete: dirs.R