Monocle3 gene expression dot plot with a cell data set object (need help with reordering x-axis)
2
0
Entering edit mode
3 months ago

I have a cell data set object (cds1) which I ran preprocess, reduce_dimension and cluster_cells functions on in monocle3 (most recent version). However when I ran the function plot_genes_by_group, the dot plot looks good except that the clusters on the x-axis are not in numerical order (from 1 on the left to 24 on the right). How do I modify my code so that my x-axis is listed in numerical order (cds1 is my starting cell data set object)? I'll put a snippet of my code here.

markergenes <- top_markers(cds1, group_cells_by="cluster",  genes_to_test_per_group = 25, reference_cells=1000, cores=1)

top_specific_markers <- markergenes %>%
  filter(fraction_expressing >= 0.10) %>%
  group_by(cell_group) %>%
  top_n(2, pseudo_R2)

top_specific_marker_ids <- unique(top_specific_markers %>% pull(gene_id))

plot_genes_by_group(cds1,
                    top_specific_marker_ids,
                    group_cells_by="cluster",
                    ordering_type="maximal_on_diag",
                    max.size= 3)

Gene Expression dot plot of cell data set object (24 clusters)

scRNA-seq monocle3 celldataset • 595 views
ADD COMMENT
0
Entering edit mode

The monocle version that I am using is Monocle3-1.3.4

ADD REPLY
0
Entering edit mode
3 months ago
fracarb8 ★ 1.6k

You are setting ordering_type = maximal_on_diag which position each column so that the maximal color shown on each column on the diagonal, if the current maximal is used in earlier columns, the next largest one is position.

As monocle uses ggplot2 under the hood, you can order the value in the cluster column yourself (e.g. factor(...., levels = c(...))) and set ordering_type = none. You can also try to leave the default value (cluster_row_col) and see if it works.

ADD COMMENT
0
Entering edit mode
3 months ago

Hi, seattlescientist_01!

colnames(cds)$clusters <- factor(colnames(cds)$clusters, levels=c(your required order)) does not changes the order of clusters in plot_genes_by_group, no matter what ordering_type you choose.

As fracarb8 mentioned, it uses ggplot2, what worked for me is saving the plot in an object and changing cluster order in that object as follows:

p <- plot_genes_by_group(cds, c(your_genes),
                         group_cells_by="cluster",
                         ordering_type='none',
                         max.size=3)

p$data$Group <- factor(p$data$Group, levels = c(your required order))

p

Best
Ekta

ADD COMMENT

Login before adding your answer.

Traffic: 1621 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6