# SCI Figure Hub — UMAP / t-SNE Cluster Embedding (CC0-1.0) library(ggplot2) set.seed(101) pal <- c("#E64B35", "#4DBBD5", "#00A087", "#3C5488", "#F39B7F", "#8491B4") ctrs <- data.frame(cx = c(-3.2, 0.5, 3.4, -2.4, 1.2, 4.0), cy = c(2.2, 3.1, 1.5, -2.5, -2.1, -2.2), cluster = c("T cell", "B cell", "Macrophage", "NK", "DC", "Epithelial")) df <- do.call(rbind, lapply(seq_len(nrow(ctrs)), function(i) { data.frame(u1 = rnorm(140, ctrs$cx[i], 0.75), u2 = rnorm(140, ctrs$cy[i], 0.7), cluster = ctrs$cluster[i]) })) p <- ggplot(df, aes(x = u1, y = u2, colour = cluster)) + geom_point(size = 0.8, alpha = 0.82) + geom_label(data = ctrs, aes(x = cx, y = cy, label = cluster), colour = "#121C26", fill = alpha("#FFFFFF", 0.78), label.size = 0, size = 2.4, fontface = "bold") + scale_colour_manual(values = pal) + labs(x = "UMAP 1", y = "UMAP 2") + theme_classic(base_size = 8) + theme(legend.position = "none", axis.ticks = element_blank(), axis.text = element_blank()) ggsave("umap_clusters.pdf", p, width = 89, height = 78, units = "mm")