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?
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!
- assign your gene of interest (here Sox17) to the object
gene_name
gene_name <- "Sox17"
- 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]
- add the
gene_id
to the plotting function (plotReducedDim
) instead of the ENSEMBL ID - 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…