H
ello R-experts,
I want to do ordination plots using vegan metaMDS.
I have a where many cells have zero values.
Data structure:
X[1:10,1:14]
Height.1 Height.2 Height.3 Height.4 Height.5 Height.6 Height.7
Height.8 Height.9 Height.10 Height.11 Height.12 Height.13
D30I1A 46 0 0 0 0 0 0
0 0 0 39 0 98
D30I1B 46 0 0 0 0 0 0
0 0 0 39 0 98
D30I1C 70 0 0 0 0 0 0
0 0 0 0 85 0
D30I2A 47 0 0 0 0 0 0
0 0 0 49 0 105
D30I2B 68 0 0 0 0 0 0
0 0 0 83 0 214
D30I2C 0 75 0 0 0 0 0
0 0 0 0 83 0
D30I3A 48 0 0 0 0 0 0
0 0 0 42 0 107
D30I3B 64 0 0 0 0 0 0
0 0 0 72 0 177
D30I3C 72 0 0 0 0 0 0
0 0 0 0 96 0
D30M1A 60 0 0 0 0 0 0
0 0 0 74 0 169
When I tried to perform metaMDS, it was not working, with the
error> ord1 <- metaMDS(
X
="bray")
Square root transformation
Wisconsin double standardization
Error in if (any(dist < -sqrt(.Machine$double.eps))) warning("some
dissimilarities are negative -- is this intentional?") :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In distfun(comm, method = distance, ...) :
you have empty rows: their dissimilarities may be meaningless in method
“bray”
2: In distfun(comm, method = distance, ...) : missing values in results
I realised some of the values are either zero or similar.
I tried to check it with
distance
X
.dist <- metaMDSdist(
X
, method="bray")
got the error:
Square root transformation
Wisconsin double standardization
Error in distfun(comm, method = distance, ...) :
formal argument "method" matched by multiple actual arguments
When I checked the distance I see some of the distances are NaN as for
example some rows of dist matrix:
D3M1A NaN 1.000000000 1.000000000 1.000000000 1.000000000
1.000000000 NaN 1.000000000 1.000000000 NaN
::::
D3R1A NaN 1.000000000 1.000000000 1.000000000 1.000000000
1.000000000 NaN 1.000000000 1.000000000 NaN
I searched all the details of metaMDS where it is suggested to avail the
argument 'zerodist'
So I tried both
X.dist1 <- metaMDSdist(X, method="bray",zerodist =
"ignore")
X.dist2 <- metaMDSdist(X, method="bray",zerodist = "add")
But for both the cases I still have those NaN values in some distances.
I have read, one of the discussion says modify zero dissimilarities as:
If there is a good reason, and you want to include all samples, then you'll
need to come up with a means for handling them. metaMDSdist allow you to
add a small value to the zero dissimilarities. The details are in the code,
but effectively all zero distances are replaced by half the smallest non
zero distance. You could do a similar replacement yourself if you feel this
is warranted and/or justified.
minDij <- min(Dij[Dij > 0) / 2
Dij[Dij <= 0] <- minDij
But still I don't understand how can I modify the NaN values. In my data I
don't have any NA values. All the cells are either +ve or zero.
Please help me with this. Should I just replace all the NaN values with
zero? Please advice.
Thanks a lot,
Mitra
[[alternative HTML version deleted]]
Suparna Mitra
2013-Jun-23 08:03 UTC
[R] Fwd: metaMDS Error, Nan similar or negative values
Hello R experts and Vegan users, I am re-posting my msg as I didn't get any
reply. I am not sure if it was not sent properly. Please help.
Sorry for repeated post.
I want to do ordination plots using vegan metaMDS.
I have a where many cells have zero values.
Data structure:
X[1:10,1:14]
Height.1 Height.2 Height.3 Height.4 Height.5 Height.6 Height.7
Height.8 Height.9 Height.10 Height.11 Height.12 Height.13
D30I1A 46 0 0 0 0 0 0
0 0 0 39 0 98
D30I1B 46 0 0 0 0 0 0
0 0 0 39 0 98
D30I1C 70 0 0 0 0 0 0
0 0 0 0 85 0
D30I2A 47 0 0 0 0 0 0
0 0 0 49 0 105
D30I2B 68 0 0 0 0 0 0
0 0 0 83 0 214
D30I2C 0 75 0 0 0 0 0
0 0 0 0 83 0
D30I3A 48 0 0 0 0 0 0
0 0 0 42 0 107
D30I3B 64 0 0 0 0 0 0
0 0 0 72 0 177
D30I3C 72 0 0 0 0 0 0
0 0 0 0 96 0
D30M1A 60 0 0 0 0 0 0
0 0 0 74 0 169
When I tried to perform metaMDS, it was not working, with the
error> ord1 <- metaMDS(
X
="bray")
Square root transformation
Wisconsin double standardization
Error in if (any(dist < -sqrt(.Machine$double.eps))) warning("some
dissimilarities are negative -- is this intentional?") :
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In distfun(comm, method = distance, ...) :
you have empty rows: their dissimilarities may be meaningless in method
“bray”
2: In distfun(comm, method = distance, ...) : missing values in results
I realised some of the values are either zero or similar.
I tried to check it with
distance
X
.dist <- metaMDSdist(
X
, method="bray")
got the error:
Square root transformation
Wisconsin double standardization
Error in distfun(comm, method = distance, ...) :
formal argument "method" matched by multiple actual arguments
When I checked the distance I see some of the distances are NaN as for
example some rows of dist matrix:
D3M1A NaN 1.000000000 1.000000000 1.000000000 1.000000000
1.000000000 NaN 1.000000000 1.000000000 NaN
::::
D3R1A NaN 1.000000000 1.000000000 1.000000000 1.000000000
1.000000000 NaN 1.000000000 1.000000000 NaN
I searched all the details of metaMDS where it is suggested to avail the
argument 'zerodist'
So I tried both
X.dist1 <- metaMDSdist(X, method="bray",zerodist =
"ignore")
X.dist2 <- metaMDSdist(X, method="bray",zerodist = "add")
But for both the cases I still have those NaN values in some distances.
I have read, one of the discussion says modify zero dissimilarities as:
If there is a good reason, and you want to include all samples, then you'll
need to come up with a means for handling them. metaMDSdist allow you to
add a small value to the zero dissimilarities. The details are in the code,
but effectively all zero distances are replaced by half the smallest non
zero distance. You could do a similar replacement yourself if you feel this
is warranted and/or justified.
minDij <- min(Dij[Dij > 0) / 2
Dij[Dij <= 0] <- minDij
But still I don't understand how can I modify the NaN values. In my data I
don't have any NA values. All the cells are either +ve or zero.
Please help me with this. Should I just replace all the NaN values with
zero? Please advice.
Thanks a lot,
Mitra
[[alternative HTML version deleted]]