Question: (Closed) Small problem of legend color in PCA, is it a bug or a my script miswriting ?
0
gravatar for David ROUX
3 months ago by
David ROUX10
France (Avignon University)
David ROUX10 wrote:

Hello,

I am following the DESeq2 pipeline. My design has 2 genotypes and 2 treatments. I ran the PCA to make a nice exploration of my RNAseq data. Everything look well excepted the legend that appears all black for the 2 genotypes (see the Genotype legend on right of the picture) while the PCA itself looks great (genotype 1 colored in green and genotype 2 colored in red, both individualy shaped with a dark border line). I have tried many writing but I am stucked concerning the legend looking. Thanks for help.

Here is my script :

############# PCA
names<-colnames(rld)

pcaData <- plotPCA(rld, intgroup=c("Genotype", "Treatment"), returnData=TRUE)

percentVar <- round(100 * attr(pcaData, "percentVar"))


ggplot(pcaData, aes(PC1, PC2, color=Genotype, shape=Treatment, fill=Genotype, label=names)) +
  geom_point(size=3) +
  ggtitle("PCA | Prunus") +
  theme(legend.position = "right") +
  xlab(paste0("PC1: ",percentVar[1],"% variance")) +
  ylab(paste0("PC2: ",percentVar[2],"% variance")) + 
  coord_cartesian()+
  scale_shape_manual(values=c(21,23))+
  scale_color_manual(values = c("#000000", "#000000")) +
  scale_fill_manual(values = c("#78D212", "#C12D0D")) +
  stat_ellipse(type = "norm", geom="polygon", level=0.8,alpha=0.2)+
  theme(
    axis.line = element_line(colour = "black", size = 1, linetype = "solid"),
    panel.background = element_rect(fill = "white", colour = "black", size = 2, linetype = "solid"),
    panel.grid.major = element_line(colour ="grey", size = , linetype = "dashed"),
    panel.grid.minor = element_line(colour ="black", size = , linetype = "dashed")
    )

 

pca color legend geom • 68 views
ADD COMMENTlink modified 3 months ago • written 3 months ago by David ROUX10

Hello David ROUX!

We believe that this post does not fit the main topic of this site.

Questions about ggplot2 should be asked either in R-help or on the tidyverse help (if there is such a thing).

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

ADD REPLYlink written 3 months ago by James W. MacDonald49k

I agree, I am sorry for that. Accordingly I made a copy of my question on the Sta... Over... forum. Thanks.

ADD REPLYlink written 3 months ago by David ROUX10
Please log in to add an answer.
The thread is closed. No new answers may be added.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 177 users visited in the last hour