PCoA Plot axis values.

I want to make a PCoA plot such that i do not want any negative values on either of the axis.
Generally this is how the plot is produced:

data(Envs)

Compute PCoA

Env.bray <- vegdist(Envs)
Env.pcoa <- cmdscale(Env.bray, eig=TRUE)
ggpcoa(Env.pcoa, ordata = Envs, group = grl)

When I use the function cmdscale(), it has the following result:

Env.pcoa
$points
[,1] [,2]
1 -0.415229098 -0.0754838595
2 -0.410918177 -0.0573311265
3 -0.385787218 -0.0542847295
4 -0.347370761 -0.0294118010
5 -0.327794656 -0.0428844122
6 -0.340168572 -0.0327971295
7 -0.311982124 -0.0358090905
8 -0.250194928 -0.0172983343
9 -0.176680298 0.0452886314
10 -0.067741212 0.0767277779
11 -0.062013687 0.0864887469
12 -0.030271744 0.0782744826
13 -0.011689192 0.0772438102
14 0.005814605 0.0877431895
15 0.046198591 0.0843960342
16 0.083336392 0.0744518941
17 0.102459391 0.0704002594
18 0.127003906 0.0650481510
19 0.160287767 0.0489585494
20 0.196350700 0.0212241405
21 0.208418751 0.0103047609
22 0.227059867 0.0003217102
23 0.236254788 -0.0077832554
24 0.254567430 -0.0290411283
25 0.272128515 -0.0488242801
26 0.279593092 -0.0613387478
27 0.296626145 -0.0787165652
28 0.314128078 -0.1171867863
29 0.327613647 -0.1386808920

$eig
[1] 1.796388e+00 1.235223e-01 1.473045e-02 1.002841e-02 3.935535e-03 2.769832e-03
[7] 1.660992e-03 1.259043e-03 1.034339e-03 5.914731e-04 4.719036e-04 4.279308e-04
[13] 3.828201e-04 2.406857e-04 6.904454e-05 1.701151e-16 -3.252792e-08 -5.078936e-05
[19] -1.061517e-04 -2.003526e-04 -2.752026e-04 -3.294674e-04 -4.019700e-04 -5.080407e-04
[25] -8.019487e-04 -1.207039e-03 -2.163082e-03 -4.758212e-03 -5.015671e-03

$x
NULL

$ac
[1] 0

$GOF
[1] 0.9729288 0.9807907

Then I tried this:

positions <- Env.pcoa$points
positions <- positions^2
colnames(positions) <- c("pcoa1", "pcoa2")
print(positions)
pcoa1 pcoa2
1 1.724152e-01 5.697813e-03
2 1.688537e-01 3.286858e-03
3 1.488318e-01 2.946832e-03
4 1.206664e-01 8.650540e-04
5 1.074493e-01 1.839073e-03
6 1.157147e-01 1.075652e-03
7 9.733285e-02 1.282291e-03
8 6.259750e-02 2.992324e-04
9 3.121593e-02 2.051060e-03
10 4.588872e-03 5.887152e-03
11 3.845697e-03 7.480303e-03
12 9.163785e-04 6.126895e-03
13 1.366372e-04 5.966606e-03
14 3.380963e-05 7.698867e-03
15 2.134310e-03 7.122691e-03
16 6.944954e-03 5.543085e-03
17 1.049793e-02 4.956197e-03
18 1.612999e-02 4.231262e-03
19 2.569217e-02 2.396940e-03
20 3.855360e-02 4.504641e-04
21 4.343838e-02 1.061881e-04
22 5.155618e-02 1.034975e-07
23 5.581632e-02 6.057907e-05
24 6.480458e-02 8.433871e-04
25 7.405393e-02 2.383810e-03
26 7.817230e-02 3.762442e-03
27 8.798707e-02 6.196298e-03
28 9.867645e-02 1.373274e-02
29 1.073307e-01 1.923239e-02

Now All the values in "positions" to be plotted are positive, So i won't have any negative values on either of my axes. But when I use ggpcoa() function, I get the following error:

ggpcoa(positions, ordata = Envs)
Error in ord$points : $ operator is invalid for atomic vectors

I just want the result of cmdscale() to have positive values for positions as I want to plot using ggpcoa() specifically.

How can solve this?

Regards
Hira

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.