1 year ago
#379531
Annaliese
Forcing ggplot to display graphs with no data?
I am working on displaying some UMAPs from Seurat object HVvU01temp using the following:
Idents(HVvU01temp) <- HVvU01temp@meta.data$integrated_snn_res.0.9
temptemp <- HVvU01temp[,HVvU01temp@meta.data$integrated_snn_res.0.9=="0"]
temp <- RunUMAP(temptemp, reduction = "pca", dims = 1:100)
my_levels <- c("PBMC_HV","PBMC_UD1","PBMC_UD2","PBMC_UD3","PBMC_UD4","PBMC_UD5","PBMC_UD6","PBMC_UD7","CSF_HV","CSF_UD1","CSF_UD2","CSF_UD3","CSF_UD4","CSF_UD5")
temp@meta.data$compartment.class2 <- factor(x=temp@meta.data$compartment.class2, levels=my_levels)
DimPlot(temp,group.by="compartment.class2",split.by="compartment.class2",ncol=8,cols=c("red","blue","orchid","tomato","springgreen","steelblue","violet","darkred","orange","purple","navy","sienna","lightgoldenrod","hotpink4"))
I am selecting all cells from the original cluster 0, re-running UMAP on all selected cells, then generating a DimPlot for the data in which the data is split by compartment.class2 label. I should have 13 UMAPs organized in 2 rows of 8 columns (8 UMAPs on top, 5 on the bottom), such that PBMC_HV is directly above CSF_HV, PBMC_UD1 is above CSF_UD1, and so on.
However, some of the compartment.class2 labels were not present in cluster 0, so they are omitted from the split UMAP and cause my matched PBMC and CSF data to no longer be aligned (for example, PBMC_UD2 and CSF_UD1 did not have cells available to be plotted).
Is there a way for me to force the plot to leave an empty space where these UMAPs would have been so my matched PBMC and CSF plots are aligned properly?
r
ggplot2
seurat
0 Answers
Your Answer