save_colors.Rd
This function stores custom color settings within a Seurat object, allowing these settings to be reused across various visualization functions within the Seurat environment.
save_colors(seu, col_list)
A Seurat object to which the color settings will be saved.
A list of color settings where names correspond to variable names and values are the colors to be associated with each variable.
The modified Seurat object with updated color settings in the `misc` slot.
`save_colors` enhances workflow efficiency by centralizing color management within the Seurat object. This enables consistent and coherent visualizations across multiple plots, reducing the need for repeated color specifications and ensuring that plots are both aesthetically pleasing and informative.
library(SeuratExtend)
# Define custom colors for different clusters and genes
custom_colors <- list(
"cluster" = "pro_blue",
"CD14" = "D",
"CD3D" = c("#EEEEEE", "black")
)
# Save these colors to the Seurat object
pbmc <- save_colors(pbmc, custom_colors)
# Use the colors in DimPlot2
DimPlot2(pbmc, features = c("cluster", "CD14", "CD3D"))