View source: R/jj_get_colours.R
| jj_get_colours | R Documentation |
get colours as named vector from file
jj_get_colours(
annotation_vector = NULL,
colour_csv,
plot_colours = FALSE,
comment_char = "/"
)
annotation_vector |
vector with the groups for which colours are needed |
colour_csv |
two column csv with annotation in first column and colour in second column (alternatively a data.frame with columns |
plot_colours |
visualize colours as ggplot heatmap, default = FALSE |
comment_char |
Lines in the colour file starting with this character are ignored, default = '/' |
#Save colour mapping in file (may contain comment lines starting with `/`)
colour_df = data.frame(group= c('g1','g2','g3'),colour= c('yellow', 'darkred','#D7B5D8'))
write.table(colour_df, file = 'colour_map.csv',
sep = ',', row.names = F, col.names=F)
# just show the colours in the file (also works passing the data.frame)
jj_get_colours(colour_csv='colour_map.csv', plot_colours=TRUE)
jj_get_colours(colour_csv=colour_df, plot_colours=TRUE)
# use the colours in ggplot (automatically selects the groups which are needed)
custom_cols = jj_get_colours(pbmc_small$groups, colour_csv='colour_map.csv')
Seurat::DimPlot(pbmc_small, group.by = 'groups') + scale_colour_manual(values=custom_cols)
#or using jj_plot_features
jj_plot_features(pbmc_small, reduction='tsne', meta_features='groups', custom_colors = custom_cols, pt.size = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.