The rscatter function has an argument showLegend to
create a legend if using colorBy with a categorical data
type. Below we plot the UMAP of
1.1M cells from the Tabula Sapiens
dataset and color the points by cell type.
library(rscatter)
input <- if (file.exists("tabula_sapiens.parquet")) {
"tabula_sapiens.parquet"
} else {
"https://davidpross.com/tabula_sapiens.parquet"
}
cells <- arrow::read_parquet(input)
labels <- readLines("cell_type_mapping.csv")
rscatter(
cells$umap1,
cells$umap2,
colorBy = factor(cells$cell_type, labels = labels),
showLegend = TRUE
)