thibautjombart / adegenet

adegenet: a R package for the multivariate analysis of genetic markers
169 stars 64 forks source link

sPCA colorplot with more than 3 significant PCs #293

Open Katrinhoh opened 4 years ago

Katrinhoh commented 4 years ago

Hi Thibaut and community,

I'm running sPCA's and it appears that my first four PCs are significant. I can produce nice plots with black and white squares but would love to also use a colorplot. However, I can't figure out how I can plot more than 3 PCs at a time. Is there a way I can plot the first 4?

Cheers, Katrin

zkamvar commented 4 years ago

Hello,

Since the colorplot is based on RGB space, it's limited to three axes. That being said, you have a couple of options:

  1. you could scale your fourth PC from 0 to 1 and use it as the alpha parameter (with transp = TRUE)
  2. the colorplot function returns the colors for the three PCs, so you could use those to color a custom plot where size is scaled by absolute value of the 4th PC and shape is based on whether or not those values are negative or positive.