| 209 | |
| 210 | === Optimize UMAP plots === |
| 211 | |
| 212 | Default UMAP plots have at least two shortcomings: (1) axes are labeled like 'UMAP_1' instead of the clearer-to-read 'UMAP 1', and (2) cluster numbering starts with 0, even though most people start counting at 1. These can both be corrected. |
| 213 | |
| 214 | {{{ |
| 215 | # Change the x-axis and y-axis labels from "UMAP_1/UMAP_2" to "UMAP 1/UMAP 2" |
| 216 | DimPlot(all_Filt, reduction = "umap") + xlab('UMAP 1') + ylab('UMAP 2') + ggtitle('UMAP with relabeled axes') + theme(plot.title = element_text(hjust = 0.5)) |
| 217 | # Rename the cluster numbers by adding 1 |
| 218 | all_Filt$new_labels <- as.numeric(as.character(all_Filt$seurat_clusters)) + 1 |
| 219 | # Plot the cells using these new labels |
| 220 | DimPlot(all_Filt, reduction = "umap", group.by = "new_labels") + xlab('UMAP 1') + ylab('UMAP 2') + ggtitle('UMAP with relabeled axes and new cluster numbers') + theme(plot.title = element_text(hjust = 0.5)) |
| 221 | # Add cluster labels (slightly transparent) on top of each cluster |
| 222 | DimPlot(all_Filt, reduction = "umap", group.by = "new_labels", label = T, label.size=10, label.color="#00000088") + xlab('UMAP 1') + ylab('UMAP 2') + ggtitle('Final UMAP') + theme(plot.title = element_text(hjust = 0.5)) |
| 223 | }}} |
| 224 | |