PCoA biplot (with any package)

Does anyone have a good exemple of a code to generate a PCoA biplot?

Hi, and welcome!

# from the documentation
library(ape)
library(vegan)
#> Loading required package: permute
#> Loading required package: lattice
#> This is vegan 2.5-6

data(mite)  # Community composition data, 70 peat cores, 35 species

# Select rows 1:30. Species 35 is absent from these rows. Transform to log
mite.log <- log(mite[1:30,-35]+1)  # Equivalent: log1p(mite[1:30,-35])

# Principal coordinate analysis and simple ordination plot
mite.D <- vegdist(mite.log, "bray")
res <- pcoa(mite.D)
res$values
#>      Eigenvalues  Relative_eig Rel_corr_eig Broken_stick Cum_corr_eig
#> 1   0.5604323559  0.2736140557 0.1963607644  0.140256109    0.1963608
#> 2   0.4066256394  0.1985226035 0.1455282106  0.104541823    0.3418890
#> 3   0.2261439730  0.1104079181 0.0858796839  0.086684680    0.4277687
#> 4   0.1620738100  0.0791276093 0.0647047307  0.074779918    0.4924734
#> 5   0.1450117270  0.0707975661 0.0590657751  0.065851347    0.5515392
#> 6   0.1381465685  0.0674458612 0.0567968655  0.058708489    0.6083360
#> 7   0.1022992571  0.0499445015 0.0449494609  0.052756109    0.6532855
#> 8   0.0949832947  0.0463727053 0.0425315623  0.047654068    0.6958171
#> 9   0.0813151150  0.0396996322 0.0380142792  0.043189782    0.7338313
#> 10  0.0654021307  0.0319306015 0.0327550964  0.039221528    0.7665864
#> 11  0.0551697303  0.0269349432 0.0293733257  0.035650099    0.7959598
#> 12  0.0379453868  0.0185256812 0.0236807436  0.032403346    0.8196405
#> 13  0.0358536611  0.0175044598 0.0229894360  0.029427156    0.8426299
#> 14  0.0319968076  0.0156214683 0.0217147601  0.026679903    0.8643447
#> 15  0.0255893519  0.0124932229 0.0195971195  0.024128883    0.8839418
#> 16  0.0202713788  0.0098968843 0.0178395490  0.021747930    0.9017814
#> 17  0.0134441498  0.0065636973 0.0155831749  0.019515787    0.9173645
#> 18  0.0086568437  0.0042264407 0.0140009878  0.017414947    0.9313655
#> 19  0.0062043038  0.0030290626 0.0131904324  0.015430820    0.9445560
#> 20  0.0008276446  0.0004040723 0.0114134664  0.013551121    0.9559694
#> 21  0.0000000000  0.0000000000 0.0101992521  0.011765406    0.9661687
#> 22 -0.0028462670 -0.0013896033 0.0084730317  0.010064726    0.9746417
#> 23 -0.0080693824 -0.0039396306 0.0074159140  0.008441350    0.9820576
#> 24 -0.0112679585 -0.0055012381 0.0056778626  0.006888555    0.9877355
#> 25 -0.0165268717 -0.0080687425 0.0046670453  0.005400459    0.9924025
#> 26 -0.0195853544 -0.0095619537 0.0044130774  0.003971888    0.9968156
#> 27 -0.0203537983 -0.0099371231 0.0026751190  0.002598262    0.9994907
#> 28 -0.0256124299 -0.0125044900 0.0005092734  0.001275510    1.0000000
#> 29 -0.0321657421 -0.0157039455 0.0000000000  0.000000000    1.0000000
#> 30 -0.0337066774 -0.0164562603 0.0000000000  0.000000000    1.0000000
#>    Cumul_br_stick
#> 1       0.1402561
#> 2       0.2447979
#> 3       0.3314826
#> 4       0.4062625
#> 5       0.4721139
#> 6       0.5308224
#> 7       0.5835785
#> 8       0.6312325
#> 9       0.6744223
#> 10      0.7136439
#> 11      0.7492940
#> 12      0.7816973
#> 13      0.8111245
#> 14      0.8378044
#> 15      0.8619332
#> 16      0.8836812
#> 17      0.9031970
#> 18      0.9206119
#> 19      0.9360427
#> 20      0.9495938
#> 21      0.9613593
#> 22      0.9714240
#> 23      0.9798653
#> 24      0.9867539
#> 25      0.9921543
#> 26      0.9961262
#> 27      0.9987245
#> 28      1.0000000
#> 29      1.0000000
#> 30      1.0000000
biplot(res)

Created on 2020-02-19 by the reprex package (v0.3.0)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.