I have got the problem on how to write the italic script in RStudio. I used the script in the screenshot and got the error "Error in grobs[[i]]: subscript out of bounds."
1 Answer
The title is misleading as this error doesn't have anything to do with making the font italic. In Seurat v2, FeaturePlot does not return a ggplot2 object by default, so p
in your case is NULL
. You need to set do.return
to TRUE
in the FeaturePlot call.
You should instead do:
library(Seurat)
p <- FeaturePlot(pbmc_small, head(pbmc_small@var.genes), do.return = TRUE)
for(i in 1:length(p)) {
p[[i]] <- p[[i]] + theme(plot.title = element_text(face = 'italic'))
}
cowplot::plot_grid(plotlist = p)
p
are grobs (things plottable by ggplot)? The error suggests that that's not that case, so try just iterating over1:4
instead. $\endgroup$