Adding sample label to PCA plot
1
0
Entering edit mode
bjen731 • 0
Last seen 6 days ago
United Kingdom

Hi, I have created a PCA plot for my data using deseq2. But now I would like to add the sample labels to my PCA plot. Can anyone please show me how?
I have added my code below that I used to create the PCA plot

library(ggplot2)
plotPCA(rld, intgroup = c("Sample", "Celltype", "Subset", "Treatment"))


Thank you very much!

plotpca DESeq2 • 141 views
0
Entering edit mode

I don't think you can with PlotPCA. You might want to make your own plot with ggplot2 or plot.ly.

1
Entering edit mode
@james-w-macdonald-5106
Last seen 6 minutes ago
United States

The plotPCA function uses ggplot2 to generate the PCA plot, so you can hypothetically do what you want directly. As an example


> library(DESeq2)
## after running example("plotPCA")
> z <- plotPCA(rld)
> z + geom_label(aes(label = name))
## That will only be able to use what's in the
## or for arbitrary extra things
> zz <- plotPCA(rld, returnData = TRUE)
> zz\$whatever <- c("FOO","BAR")[sample(1:2, 12, TRUE)]
> z +  geom_label(data = zz, aes(label = whatever))

## or if you want to be cool
> library(ggrepel)
> z + geom_label_repel(data = zz, aes(label = whatever))

0
Entering edit mode

This worked, thank you so much!