Adding sample label to PCA plot
1
0
Entering edit mode
bjen731 ▴ 10
@2586ad17
Last seen 2.7 years 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 • 8.4k views
ADD COMMENT
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.

ADD REPLY
2
Entering edit mode
@james-w-macdonald-5106
Last seen 1 day 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)
## add some random column 
> 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))
ADD COMMENT
1
Entering edit mode

This worked, thank you so much!

ADD REPLY

Login before adding your answer.

Traffic: 521 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6