This simple for loop I want it to run the function FindMarkers, which will take as an argument a data identifier (1,2,3 etc..) that it will use to pull data from. I then want it to store the result of the function in immunes.i, where I want I to be the same integer (1,2,3)
So I want an output of 15 files names immunes.0, immunes.1, immunes.2 etc...
I've ran the code before, and it runs, but doesn't make the individual files. It just makes 1 file at the end called, not surprisingly immunes.i
Right now Im getting a different error though; here is the code:
for (i in 0:14){
Idents(AllCells.combined) <- AllCells.combined$seurat_clusters
DefaultAssay(AllCells.combined) <- "RNA"
immunes.i <- FindMarkers(AllCells.combined, ident.1 = "VEH", ident.2 = "IMQ", verbose = TRUE, group.by="stim", subset.ident = "i")
}
The error i get is
Error in WhichCells.Seurat(object = x, cells = cells, idents = idents, :
Cannot find the following identities in the object: i
If I run the last line by itself it works perfectly, namely:
immunes.0 <- FindMarkers(AllCells.combined, ident.1 = "VEH", ident.2 = "IMQ", verbose = TRUE, group.by="stim", subset.ident = "0")
any advice? thanks!