Add black outline for different geom_point shapes on DESeq2 PCA

1.1k Views Asked by At

I am running a PCA with the DESeq2 package and would like to obtain a black outline on the shapes which are already based on an observation.The round ones work, but the other shapes do not.

Examples such as Make stat_ellipse {ggplot2} outline geom_point fill color or Place a border around points have data plotted as one only shape.

It is hard to give a reproducible example as it has previously performed a PCA on a big dataset, but this is what I have run the following:

ggplot(pcaData, aes(x = PC1, y = PC2, color = dFe, shape = location))+   
geom_point(size=5)+  
geom_point(aes(PC1, PC2, color = dFe, shape = location), shape= 21, colour="black", size= 5)

I believe the key is on the coding of that new layer of geom_point

enter image description here

Running scale_fill_manual I get the following

ggplot(pcaData, aes(x = PC1, y = PC2, color = dFe, shape = location))+   
geom_point(size=5)+  scale_shape_manual(values=c(21,22,23))

enter image description here

2

There are 2 best solutions below

0
On BEST ANSWER

As mentioned in my comment, use scale_shape_manual, and provide a fill aesthetic:

ggplot(pcaData, aes(x = PC1, y = PC2, fill = dFe, shape = location)) +
    geom_point(color = 'black', size = 5) +
    scale_shape_manual(values = c(21L, 22L, 23L))

enter image description here

2
On

Try This:

ggplot(pcaData, aes(x = PC1, y = PC2, shape = location))+   
  geom_point(size=7) + 
  geom_point(aes(x = PC1, y = PC2, color = dFe, shape = location), size=5)

enter image description here