[R] Error with metaMDS

Sarah Goslee sarah.goslee at gmail.com
Mon Jun 24 20:43:57 CEST 2013


Hi,

On Mon, Jun 24, 2013 at 12:04 PM, Suparna Mitra
<suparna.mitra.sm at gmail.com> wrote:
> Dear Sarah,
>   Thanks for your reply. But I don't have any site where all the species are
> 0.

Well, that's what this says:
> 1: In distfun(comm, method = distance, ...) :
>   you have empty rows: their dissimilarities may be meaningless in method
> “bray”

> Is there anyway to calculate the dissimilarity between sites where it
> computes only the non-zero species values. Excluding all the zero event will
> result a big loss in species data. I don't want to delete the cases where
> may be 5out of 8 sites have species info, only 3 don't have.

There's no reason to delete those. Bray-Curtis and similar metrics
consider only joint presences, not joint absences. If you have a lot
of sites with no species in common, it can also cause problems. That's
what vegan::stepacross is intended to deal with.

>  Should I replace zero with a very small number. What is the best thing to
> do in such cases?

The best thing to do in such cases is to provide a reproducible
example to R-help. At the very least,
str(X)
str(data) # called in metaMDS() but not described; also, don't call
your data data

and double-check to make sure you don't have any all-zero rows or NA
values in your data.

Sarah

> On 24 June 2013 21:24, Sarah Goslee <sarah.goslee at gmail.com> wrote:
>>
>> Hi,
>>
>> What do you expect the dissimilarity between a site with no species
>> and a site with some species to be?
>>
>> If you want to use Bray-Curtis dissimilarity, you need to drop the
>> sites with no species, as the error message suggests.
>>
>> But if you can answer my first question, you may be able to select a
>> different dissimilarity metric that matches your expectations
>> numerically.
>>
>> Sarah
>>
>>
>> On Mon, Jun 24, 2013 at 7:33 AM, Suparna Mitra
>> <suparna.mitra.sm at gmail.com> wrote:
>> >  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
>> >
>> > Another data structure
>> >> Genus_data[1:10,1:14]
>> >      Sample Acanthamoeba Acidianus Aegilops Alphapapillomavirus
>> > Asfivirus
>> > Brassica Buchnera Coprinellus Diaphorobacter Hartmannella Ignicoccus
>> > 1    HS1_S1            0         0        0                   0
>> > 0
>> >      0        0           0              0            0          0
>> > 2    HS2_S2            0         1        1                   0
>> > 0
>> >      0        0           0              0            1          0
>> > 3    HS3_S3            0         0        0                   1
>> > 0
>> >      0        1           1              1            0          0
>> > 4    HS4_S4            0         0        0                   0
>> > 1
>> >      0        0           0              0            0          0
>> > 5   HS13_S5            0         0        0                   0
>> > 0
>> >      0        0           0              0            0          0
>> > 6   HS14_S6            0         0        0                   0
>> > 0
>> >      1        0           0              0            0          0
>> > 7   HS15_S7            0         0        0                   0
>> > 0
>> >      0        0           0              0            0          0
>> > 8   HS16_S8            0         0        0                   0
>> > 0
>> >      0        0           0              0            0          1
>> > 9   HS25_S9            1         0        0                   0
>> > 0
>> >      0        0           0              0            0          0
>> >
>> > I am having two different kind of errors for these two data...
>> > Error 1
>> >> 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
>> >
>> > Error 2
>> > ord.data= metaMDS(data, distance="bray")
>> > Error in if (any(autotransform, noshare > 0, wascores) && any(comm < 0))
>> > {
>> > :
>> >   missing value where TRUE/FALSE needed
>> > In addition: Warning message:
>> > In Ops.factor(left, right) : < not meaningful for factors
>> >
>> > 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")
>> >
>> > Can Please help me with this.
>> > Thanks,
>> > Mitra
>> >
>>



-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list