cole-trapnell-lab / monocle-release

280 stars 116 forks source link

adding custom color code to cluster #182

Open abmmki opened 6 years ago

abmmki commented 6 years ago

Hi,

I have 6 different types of cells (marker in pData) to plot in trajectory. Calling the function "plot_cell_trajectory" with color_by=marker provides automatic colors to those 6 cell markers (cell1, cell2, cell3............). However, I want to provide these hex color codes for each cell cluster (marker):

cell1 - #6db200 cell2 - #00c0af cell3- #f8766d cell4 -#b984ff cell5 - #a3a500 cell5 - #00ba38

plot_cell_trajectory(HSMM, color_by = "marker")

how can I do that?

thanks

Xiaojieqiu commented 6 years ago

hi @abmmki please notice that the plot_cell_trajectory function returns a ggplot object, you can change the color map for each cell cluster by doing adding + scale_color_manual(values = cluster_cols, name = "cluster") to the plot_cell_trajectory call. cluster_cols is a vector of the six colors with the name of each color the corresponding cell type. Please do read the monocle 2 (3) website (http://cole-trapnell-lab.github.io/monocle-release/monocle3/ for example, section Visualize the clustering results) and the github repo for monocle 2 paper (https://github.com/cole-trapnell-lab/monocle2-rge-paper/blob/master/Olsson_dataset_analysis_final.ipynb, section Show the complicate tree structure for WT and full dataset) to get real examples. Thanks

initialqy commented 4 years ago

Hi, I'm sorry I have a question. I try to color the Module score in the "plot_cell_trajectory", here is the codes: data <- AddModuleScore( object =data, features = angio_Features, ctrl = 5, name = 'angio_score', seed = 1 ) #add angio score on each sample

Then I create the monocle object "monocle_data", Now I use plot_cell_trajectory to check the angio score through pseudotime, the color bar is dark blue to light blue. I want to change the colour.

coul <- colorRampPalette(brewer.pal(8, "RdYlBu"))(25)

plot_cell_trajectory( monocle_data, color_by = "angio_score1") + scale_color_manual(breaks = waiver(),values=coul) Here is the error Error: Continuous value supplied to discrete scale

How can I do this? Thank you.