0
$\begingroup$

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." enter image description here

$\endgroup$
4
  • 2
    $\begingroup$ Please replace the image with the actual text. $\endgroup$
    – Devon Ryan
    Jan 10, 2019 at 18:14
  • $\begingroup$ Have you ensured that all of the elements of p are grobs (things plottable by ggplot)? The error suggests that that's not that case, so try just iterating over 1:4 instead. $\endgroup$
    – Devon Ryan
    Jan 10, 2019 at 18:20
  • 1
    $\begingroup$ Seriously. It's even easier to paste the text! $\endgroup$ Jan 10, 2019 at 19:51
  • 5
    $\begingroup$ I'm voting to close this question as off-topic because formatting text as italics is not a bioinformatics problem $\endgroup$
    – Bioathlete
    Jan 10, 2019 at 20:31

1 Answer 1

4
$\begingroup$

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)

featureplot

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.