0

I ran a PCA and customized it via ggplot (on DESeq2 RNAseq data). Everything looks 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 is well colored in green and genotype 2 colored in red, both individualy shaped with a dark border line). I have tried many writings but I am stucked concerning the legend looking. Thanks for help.

The 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")
    )

The graph (see the 2 black circles in the genotype legend (instead of expected green and red + black line)):

Link

Below are some tests I have done according to comments.

Link

Thanks for your help.

Zampaï
  • 11
  • 6
  • Unrelated, but you should use `coord_equal` with an ordination. – Richard Telford Dec 13 '18 at 16:58
  • It'll be the `scale_color_manual` call (set to black) clashing with the `scale_fill_manual` call (set to colors). Can you remove one and see what happens – bob1 Dec 13 '18 at 17:04
  • I have edited my question by adding your suggered tests and their results. None of them solved the problem. Thanks. – Zampaï Dec 14 '18 at 14:24
  • @Richard Telford : Can you be a litle more explicit please (about ordination) ? – Zampaï Dec 14 '18 at 14:34
  • See this question: https://stackoverflow.com/questions/37140266/how-to-merge-color-line-style-and-shape-legends-in-ggplot – Joe Dec 14 '18 at 17:37

0 Answers0