Nothing
#' Assign Default GRIN Colors
#'
#' @description
#' Assigns a default set of colors to lesion types for use in GRIN plots.
#'
#' @usage
#' default.grin.colors(
#' lsn.types
#' )
#'
#' @param lsn.types A character vector of lesion types, typically obtained from
#' the \code{"lsn.type"} column of lesion data. Duplicate lesion types are
#' automatically removed and the remaining lesion types are sorted before
#' colors are assigned.
#'
#' @details
#' This function assigns colors from a predefined palette of up to 10 colors.
#' Colors are assigned to unique lesion types in alphabetical order. If more
#' than 10 unique lesion types are provided, custom colors must be specified
#' manually in the plotting function.
#'
#' @return
#' A named character vector in which names correspond to the unique lesion types
#' and values correspond to their assigned colors.
#'
#' @importFrom stats setNames
#'
#' @export
#'
#' @author
#' Abdelrahman Elsayed \email{abdelrahman.elsayed@stjude.org},
#' Stanley Pounds \email{stanley.pounds@stjude.org}
#'
#' @examples
#' data(lesion_data)
#'
#' # Extract unique lesion types
#' lsn.types <- unique(lesion_data$lsn.type)
#'
#' # Assign default colors to lesion types
#' default.grin.colors(lsn.types)
default.grin.colors=function(lsn.types) # Unique lesion types as specified in the lesion data file
{
message("Computationally assigning lesion type colors for GRIN plots.")
uniq.types=sort(unique(lsn.types))
n.types=length(uniq.types)
default.colors=c("black", "red","blue",
"olivedrab", "purple",
"cyan", "brown", "gold",
"orange","steelblue")
if (n.types==0)
return(setNames(character(0),character(0)))
if (n.types>length(default.colors))
stop(paste0("Too many lesion types for default GRIN colors; please assign colors manually."))
res=default.colors[1:n.types]
names(res)=uniq.types
return(res)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.