ggplot2 of PCA
2
0
Entering edit mode
yueli7 ▴ 20
@yueli7-8401
Last seen 2.9 years ago
China

Hello, I only can draw six points. It should be 40 points. Thanks in advance for great help! Best, Yue

library(ggplot2)
rld <- rlog(dds)
data <- plotPCA(rld, intgroup=c("condition", "name"), returnData=TRUE)
percentVar <- round(100 * attr(data, "percentVar"))
p<- ggplot(data, aes(PC1, PC2, color=condition, shape=name)) +
  geom_point(size=3) +
  xlab(paste0("PC1: ",percentVar[1],"% variance")) +
  ylab(paste0("PC2: ",percentVar[2],"% variance"))
p

Screenshot-from-2020-06-19-22-23-46

software error ggplot2 • 3.9k views
ADD COMMENT
0
Entering edit mode
Kevin Blighe ★ 3.9k
@kevin
Last seen 5 hours ago
Republic of Ireland

I do not think that it's practical to plot that many groups in the same plot space. Try to condense your data into less groups and re-try. If you must, take a look at this answer: https://stackoverflow.com/questions/46803260/assigning-40-shapes-or-more-in-scale-shape-manual/46814238

If you want more advanced functionality, then try PCAtools, also on Bioconductor.

Kevin

ADD COMMENT
0
Entering edit mode

Hello Kein Blighe, Thank you so much for your great help and really appreciated! Best, Yue

ADD REPLY
0
Entering edit mode
leahfa • 0
@leahfa-23736
Last seen 3.8 years ago

I think its a ggplot issue You are assigning "name" to shape, but ggplot provides just 6 shapes by default and you have far more names. You can probably force it to add shapes but it doesnt really make any sense. First try plotting it without setting "shape" aesthetic at all - you should see all the points. If you deeply care about identifying points by name , you can add name as a label ( dont forgot to add geom_text() . and I would shorten the names first). If you want to see how replicates cluster, add another variable to your original dataframe and use that. Best

ADD COMMENT

Login before adding your answer.

Traffic: 738 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