0

I'm trying to cycle through a list of Seurat objects and make violin plots of each object. My code is:

for (i in 1:length(gene.list)){
  VlnPlot(gene.list[[i]], features = c("nCount_RNA", "nFeature_RNA", "percent.mt"))
}

but no plots are being produced. To test my code I did a single line:

VlnPlot(gene.list[[2]], features = c("nCount_RNA", "nFeature_RNA", "percent.mt"))

And the desired plot was generated, so it must be something with my loop, right?

I tried doing:

  VlnPlot(gene.list[[as.integer(i)]], features = c("nCount_RNA", "nFeature_RNA", "percent.mt"))
}

But that didn't make a difference.

Any ideas?

Thanks,

  • Try adding a `print()` around your plotting function: `print(VlnPlot(...))`. It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick May 31 '22 at 14:41

0 Answers0