2. Add gene SYMBOL to your plots

Did you just plot a bunch of genes using the ENSEMBL ID and now you can’t tell which gene SYMBOL belongs to each plot? :face_with_raised_eyebrow:
Solution: Add the gene SYMBOL directly to the plot!

Here is how to do it:

gene_name <- "Sox17"
gene_id <- rowData(sce)[which(rowData(sce)[,2] %in% gene_name),1]
plotReducedDim(object = sce, dimred="umap", colour_by=gene_id) + labs(title = gene_name)
plotExpression(object = sce, features = gene_id, x = "celltype") + labs(title = gene_name)

Here is why it works!

  1. assign your gene of interest (here Sox17) to the object gene_name
gene_name <- "Sox17"
  1. convert the gene name to the ENSEMBL gene id for plotting and call it gene_id
gene_id <- rowData(sce)[which(rowData(sce)[,2] %in% gene_name),1]
  1. add the gene_id to the plotting function (plotReducedDim) instead of the ENSEMBL ID
  2. Add the gene_name directly to the plot using + labs(title = gene_name)
plotReducedDim(object = sce, dimred="umap", colour_by=gene_id) + labs(title = gene_name)

This is really convenient because all you have to do is change the "Sox17" to see a different gene without having to change any of the other codes! Whew… :saluting_face:

1 Like