Thank you! Sorry j was typo in the code it should have been i. Instead of x[i], I used x[[i]] and it works perfectly.
I was able to print Seurat object name in ggtitle using following code.
x <- list( "seuratobject1"=seuratobject1, "seuratobject2"=seuratobject2)
pdf("plots.pdf", onefile = TRUE)
for (i in names(x)){
b02 <- RunPCA(x[[i]], assay = "SCT", verbose = FALSE)
b02 <- FindNeighbors(b02, reduction = "pca", dims = 1:30)
b02 <- FindClusters(b02, verbose = FALSE)
b02 <- RunUMAP(b02, reduction = "pca", dims = 1:30)
print(DimPlot(b02, reduction = "umap", label = TRUE)+ggtitle(i)+ SpatialDimPlot(b02, label = TRUE, label.size = 3))
}
dev.off()
• 0 views
•
link