default color for metadat
Closed this issue · 3 comments
Hi,
Is it possible to determine specific color, rather than having to specify them in the Colors tab?
For example, if I have a group "seurat_clusters" with 5 levels, can i specify what colors should be used for each level?
I'm not sure how the file color_setup.R
could be used.
Best,
Marc
Hi Marc,
While I haven't implemented that feature yet, the changes I made to the data storage in v1.3 should make it easier to implement it. At the moment, the color palette is built in color_setup.R
. You could change those colors, but that color scale will then be applied to all categorical meta data variables. In the utility_functions.R
file, there is a function called assignColorsToGroups()
, which is used to assign colors to the selected coloring variable (if categorical) for plotting. As a workaround until the feature is properly implemented, you could modify that function, e.g. by adding an if
statement that waits for the grouping variable you want to manually assign colors to, and then return a named vector (values are the colors in hex, names are the groups/clusters). For example:
if ( grouping_variable == 'seurat_clusters' ) {
colors <- setNames(
c('#2980b9','#2980b9','#2980b9','#2980b9','#2980b9'),
c('1','2','3','4','5')
)
return(colors)
} else if ( grouping_variable %in% names(reactive_colors()) ) {
...
That should do it, but it will only work for the modified installation of cerebroApp, so the colors are not stored in the .crb
file (which would be much more elegant because then other users would see the same colors as well).
Best,
Roman
Hi sorry I forgot to anwser you, but it is exactlly what I need, to configure Cerebro application on a Web Server.
Thank you again.
Marc
Hi Marc,
I'm not sure if changing the modifying assignColorsToGroups()
in the utility_functions.R
file has entirely solved your problem, but in my case modifying that script has resulted in changes in colors only in the UMAP/scatter plots. In order to assign specific colors to my groups of interest I had to modify color_setup.R
. E.g. to assign colors to variables within MUT_STATUS
group I had to add the following to the reactive_colors()
function within that script:
for ( group_name in getGroups() ) {
## if loop condition with new colours for "MUT_STATUS" group
if ( group_name == 'Bailey' ) {
colors[[ 'MUT_STATUS' ]] <- setNames(
c('#1874CD','#83CB83','#BEBEBE'),
c('mut','ref','no call'))
## if color selection from the "Color management" tab exist, assign those
## colors, otherwise assign colors from default colorset
} else if ( !is.null(input[[ paste0('color_', group_name, '_', getGroupLevels(group_name)[1]) ]]) ) {
...
That has changed colours in "Color management" tab as well as in all the other plots and tables in other tabs. I hope that helps.
Best
Jacek