I am using autolplot function from the ggfortify library in R. Autoplot serves cluster analysis too. I wanted to know what is the algorithm used by the autoplot for finding the 1st two principal components?
The PCA function that it uses is `prcomp()`, which is the same as what my own package (<a href="https://github.com/kevinblighe/PCAtools">PCAtools</a>) and DESeq2 use.

Yes, it is performing partitioning around medoids (PAM) and identifying X number of clusters (user pre-selects desired number as second parameter to `pam()`). `autoplot()` then performs PCA on the dataset and shades the points based on the PAM cluster assignments. Here is the proof:

    g1 <- autoplot(prcomp(iris[-5]), frame = TRUE, frame.type = 'norm')
    g2 <- autoplot(pam(iris[-5], 2), frame = TRUE, frame.type = 'norm')
    require(grid)
    require(gridExtra)
    grid.arrange(g1,g2, ncol = 2)

<a href="https://ibb.co/whLvCm3"><img src="https://i.ibb.co/TMTCR3p/Captura-de-tela-de-2019-04-24-08-43-19.png" alt="Captura-de-tela-de-2019-04-24-08-43-19" border="0"></a>

They are the same points, but higlighted differently.

As is typical with many CRAN (and other) packages, the documentation is poor and the program functionality does not make it readily obvious what the function is doing.
