<p>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 <code>p</code> in your case is <code>NULL</code>. You need to set <code>do.return</code> to <code>TRUE</code> in the FeaturePlot call.</p>

<p>You should instead do:</p>

<pre><code>library(Seurat)

p &lt;- FeaturePlot(pbmc_small, head(pbmc_small@var.genes), do.return = TRUE)

for(i in 1:length(p)) {
  p[[i]] &lt;- p[[i]] + theme(plot.title = element_text(face = 'italic'))
}

cowplot::plot_grid(plotlist = p)
</code></pre>

<p><a href="https://i.sstatic.net/h9me4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/h9me4.png" alt="featureplot"></a></p>

CC BY-SA 4.0
2019-01-10T18:42:59.803Z
2019-01-10T18:42:59.803Z
TimStuart
<p>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." <a href="https://i.sstatic.net/emCgW.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/emCgW.jpg" alt="enter image description here"></a></p>

CC BY-SA 4.0
2019-01-10T18:14:44.737Z
Please replace the image with the actual text.
Devon Ryan
CC BY-SA 4.0
2019-01-10T18:20:04.303Z
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.
Devon Ryan
CC BY-SA 4.0
2019-01-10T19:51:38.253Z
Seriously. It's even *easier* to paste the text!
Daniel Standage
CC BY-SA 4.0
2019-01-10T20:31:02.780Z
I'm voting to close this question as off-topic because formatting text as italics is not a bioinformatics problem
Bioathlete
<rna-seq><single-cell>
how to write italic script in Rstudio
# how to write italic script in Rstudio

(Asked by: username_0 on 2019-01-10)

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](https://i.sstatic.net/emCgW.jpg)](https://i.sstatic.net/emCgW.jpg)

**Tags:** rna-seq, single-cell
> **Comments:**
> **username_1**: Please replace the image with the actual text.  
> **username_1**: 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.  
> **username_2**: Seriously. It's even *easier* to paste the text!  
> **username_3**: I'm voting to close this question as off-topic because formatting text as italics is not a bioinformatics problem  

---

## 1 answers

### Answer by username_4 on 2019-01-10. Score: 4 | Accepted 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)


---

