Hi guys
My data is Tasmania txt
There are *N *= 16 samples, consisting of 8 replicate cores (taken from
different areas across the sandflat) from each of 2 natural
'treatments' (either
disturbed "D" or undisturbed "U" by soldier crab burrowing
activity. The
abundances of each of *p *= 56 species were recorded from each core
(variables 1 to 39 in the file are nematode worms and variables 40-56 in
the file are copepods, as identified by the column headed "Taxon").
Note
that the *rows *are the species and the *columns *are the scores (sample
units) in the raw data file.
When i want to do ANOSIM i get an NaN error message. What is wrong?
R output is here under> tasmania.df=read.table(file.choose(),header=T)
> attach=(tasmania.df)
> tasmania.df
Species Taxon D1 D2 D3 D4 D5 D6 D7 D8 U1
U2 U3 U4 U5 U6 U7 U8
1 Actinonema.sp Nem 0 0.000 0 0 0.000 0.000 0 0 0
2.48 0.000 2 1 0 0 0.000
2 Axonolaimus.sp Nem 10 8.995 12 14 6.325 0.000 0 4 51
48.36 49.237 26 9 5 37 50.550
3 Bathylaimus.sp Nem 0 0.000 0 1 72.105 42.570 15 16 1
0.00 6.005 0 51 8 21 11.795
4 Calyptronema.sp Nem 0 0.000 0 0 0.000 0.000 0 0 0
0.00 0.000 0 1 0 1 1.685
5 Chaetonema.sp Nem 0 0.000 0 0 13.915 7.095 0 2 0
0.00 0.000 0 1 0 0 1.685
6 Chromaspirina.sp Nem 0 0.000 0 0 0.000 0.000 0 0 0
0.00 1.201 1 0 0 0 0.000
7 Comesoma.sp Nem 0 0.000 0 0 0.000 0.000 3 0 0
0.00 4.804 0 4 2 0 0.000
8 Daptonema.sp Nem 0 0.000 0 3 1.265 9.460 3 1 0
9.92 6.005 6 5 0 3 5.055
9 Desmodora.sp.A Nem 0 0.000 0 0 0.000 0.000 0 1 2
2.48 0.000 0 1 0 0 0.000
10 Desmodora.sp.B Nem 0 0.000 0 0 0.000 0.000 0 0 0
0.00 8.406 2 4 2 0 3.370
11 Enoploides.sp Nem 0 0.000 0 0 1.265 0.000 0 0 0
0.00 0.000 0 0 0 0 1.685
12 Enoplus.sp Nem 0 0.000 0 0 0.000 0.000 0 2 0
0.00 0.000 0 0 0 0 0.000
13 Epacanthion.sp.A Nem 1 10.280 1 5 1.265 0.000 3 1 0
3.72 1.201 1 1 0 5 13.480
14 Epacanthion.sp.B Nem 3 3.855 0 0 0.000 0.000 1 4 16
14.88 3.603 0 0 0 1 1.685
15 Eubostrichus.sp Nem 0 0.000 0 0 0.000 0.000 1 0 0
0.00 1.201 0 0 0 0 1.685
16 Eurystomina.sp Nem 1 0.000 0 0 1.265 0.000 1 1 1
3.72 0.000 1 0 0 1 0.000
17 Hypodontolaimus.sp.A Nem 45 201.745 106 69 78.430 319.275 50 87 18
12.40 109.283 92 6 6 9 23.590
18 Hypodontolaimus.sp.B Nem 0 0.000 0 0 1.265 0.000 0 0 51
85.56 15.612 14 2 1 2 5.055
19 Leptolaimus.sp Nem 0 0.000 0 0 0.000 0.000 0 0 0
0.00 0.000 0 1 0 0 0.000
20 Leptonemella.sp Nem 0 0.000 0 0 0.000 0.000 0 1 1
1.24 3.603 0 1 1 0 0.000
21 Mesacanthion.sp Nem 14 15.990 18 8 2.530 7.095 0 3 30
28.52 8.406 6 1 1 5 15.165
22 Microlaimus.sp Nem 0 0.000 0 0 0.000 0.000 0 0 0
0.00 0.000 0 0 2 2 26.960
23 Monhystera.sp Nem 0 0.000 1 1 0.000 0.000 3 0 0
0.00 0.000 0 0 0 0 0.000
24 Nannolaimoides.sp.A Nem 0 0.000 2 1 1.265 2.365 0 1 7
1.24 3.603 3 1 3 7 8.425
25 Nannolaimoides.sp.B Nem 0 0.000 0 0 0.000 0.000 1 2 0
0.00 0.000 0 0 0 1 1.685
26 Neochromadora.sp.A Nem 1 5.140 10 6 10.120 0.000 7 18 7
2.48 13.210 4 2 1 9 20.220
27 Neochromadora.sp.B Nem 0 2.570 0 0 0.000 2.365 0 0 1
0.00 0.000 1 1 0 0 0.000
28 Odontophora.sp Nem 1 0.000 0 0 1.265 0.000 1 0 0
0.00 1.201 0 28 1 4 1.685
29 Oncholaimus.sp Nem 1 1.285 4 2 16.445 14.190 16 17 1
7.44 7.205 6 11 4 25 50.550
30 Onyx.sp Nem 0 0.000 0 0 29.095 37.840 12 15 3
1.24 8.406 1 1 4 49 85.935
31 Paracanthonchus.sp Nem 0 1.285 1 2 1.265 0.000 1 0 0
8.68 6.005 7 1 1 3 0.000
32 Polysigma.sp Nem 0 0.000 1 0 0.000 0.000 0 0 0
0.00 0.000 0 0 0 0 0.000
33 Praeacanthonchus.sp Nem 0 1.285 0 0 1.265 0.000 0 6 2
0.00 6.005 0 5 4 8 5.055
34 Promonhystera.sp Nem 4 1.285 6 12 6.325 18.920 1 0 0
1.24 2.402 5 1 0 0 0.000
35 Pseudosteineria.sp Nem 0 0.000 0 2 0.000 0.000 0 0 0
0.00 2.402 0 0 0 0 0.000
36 Sabatieria.sp Nem 1 0.000 0 0 3.795 11.825 3 0 0
0.00 0.000 0 12 1 2 0.000
37 Spilophorella.sp Nem 0 0.000 0 0 0.000 0.000 0 0 0
0.00 0.000 0 1 0 0 0.000
38 Symplocostoma.sp Nem 0 0.000 0 0 0.000 0.000 0 2 2
3.72 0.000 0 0 0 0 0.000
39 Viscosia.sp Nem 0 1.285 0 0 2.530 0.000 0 1 2
8.68 0.000 1 0 0 3 0.000
40 Ameira.sp Cop 43 63.000 4 5 7.000 6.000 69 5 124
105.00 91.000 57 10 60 142 96.000
41 Apodopsyllus.sp Cop 0 0.000 0 0 0.000 0.000 4 1 0
0.00 0.000 0 0 1 3 2.000
42 Ectinosoma.sp Cop 0 0.000 0 0 0.000 0.000 1 0 0
2.00 0.000 0 1 4 6 7.000
43 Ectinosomatidae.sp Cop 1 15.000 14 4 2.000 3.000 1 1 7
7.00 4.000 5 5 0 2 1.000
44 Haloshizopera.sp Cop 0 0.000 0 0 0.000 0.000 0 0 2
0.00 0.000 0 0 0 0 0.000
45 Leptastacus.sp.A Cop 30 97.000 27 35 3.000 1.000 29 47 151
117.00 15.000 88 3 0 6 2.000
46 Leptastacus.sp.B Cop 1 11.000 3 0 0.000 0.000 0 1 0
0.00 2.000 5 0 0 0 0.000
47 Leptastacus.sp.C Cop 0 0.000 0 0 10.000 180.000 3 1 0
0.00 0.000 0 0 10 0 0.000
48 Mictyricolatypica Cop 0 0.000 8 3 0.000 1.000 3 5 0
0.00 0.000 0 1 0 0 0.000
49 Parevansula.sp Cop 0 0.000 2 0 0.000 0.000 0 0 0
1.00 0.000 1 0 0 0 0.000
50 Quinquelaophonte.sp Cop 0 0.000 0 0 0.000 0.000 0 0 2
3.00 0.000 0 0 0 2 0.000
51 Rhizothrix.sp Cop 1 0.000 0 0 0.000 0.000 0 0 6
6.00 0.000 0 0 0 0 0.000
52 Undetermined.A Cop 0 0.000 0 0 0.000 0.000 0 0 0
1.00 0.000 0 0 0 0 0.000
53 Undetermined.B Cop 1 0.000 0 0 0.000 0.000 0 0 0
0.00 0.000 0 0 0 0 0.000
54 Undetermined.C Cop 0 0.000 0 0 0.000 0.000 0 0 0
0.00 0.000 0 1 0 0 0.000
55 Undetermined.D Cop 0 0.000 0 0 0.000 0.000 0 0 0
0.00 0.000 0 0 0 0 1.000
56 Undetermined.E Cop 0 0.000 0 0 0.000 0.000 0 0 0
0.00 0.000 0 0 0 0 1.000> Y=t(tasmania.df[,3:18])
> Y.t=Y^(0.5)
> library(MASS)
> my.dist = function (Y,measure="Euc") {
+ N=dim(Y)[1]; p=dim(Y)[2]
+ d=matrix(0,nrow=N,ncol=N)
+ for(i in 1:(N-1)) {
+ for(j in (i+1):N) {
+ d[i,j] = switch(measure,
+ SM =
1.0-(sum((Y[i,]>0)&(Y[j,]>0))+sum((Y[i,]==0)&(Y[j,]==0)))/p,
+ Jac =
1.0-sum((Y[i,]>0)&(Y[j,]>0))/sum((Y[i,]>0)|(Y[j,]>0)),
+ Euc = sqrt( sum((Y[i,]-Y[j,])^2) ),
+ BC=(sum(abs(Y[i,]-Y[j,]))/sum(Y[i,]+Y[j,])),
+ Man=sum(abs(Y[i,]-Y[j,])),
+ Manx= sum(abs(Y[i,]-Y[j,]))/length(Y[i,][Y[i,]+Y[j,]>0]),
+ Chi=sqrt(sum( (sum(Y)/apply(Y,2,sum))*
+ ( Y[i,]/sum(Y[i,]) - Y[j,]/sum(Y[j,]) )^2))
+ )}
+ }
+ d = d+t(d)
+ return(as.dist(d))
+ }> D=as.matrix( my.dist(Y.t,measure="BC") )
> tasmania.df=my.dist(Y.t,measure="BC")
> tasmania.mds=isoMDS(tasmania.df, k=2)
initial value 15.803771
iter 5 value 11.418948
iter 10 value 10.784872
final value 10.663487
converged> plot(tasmania.mds$points, type = "n", axes=FALSE,
+ xlab="",ylab="", main="MDS of Tasmania
data")> text(tasmania.mds$points, labels = rownames(Y))
> box()
> tasmania.mds$stress
[1] 10.66349> tasmania.stress=round(tasmania.mds$stress/100,digits=3)
> mtext(paste("Stress = ",tasmania.stress,sep=""))
> group=rownames(Y)
> N=length(group)
> d.vec=rep(0,(N*(N-1)/2) )
> iwithin=rep(0,(N*(N-1)/2) )
> icount=0
> for(i in 1:(N-1)) {
+ for(j in (i+1):N) {
+ icount=icount+1
+ d.vec[icount]=D[i,j]
+ if(group[i]==group[j]) iwithin[icount]=1
+ }
+ }> r=rank(d.vec)
> r
[1] 8 15 16 74 116 36 60 59 64 44 19 109 96 83 95 7 20
79 103 63 50 32 41 26 5 113 114 86 93 2 58 97 68
[34] 33 89 82 35 10 104 118 108 112 42 88 37 31 87 76 28 11
84 117 85 102 14 23 9 107 106 40 53 30 65 22 57 77
[67] 71 120 119 92 99 78 115 101 105 13 98 81 25 56 66 49 18
48 67 80 29 47 70 91 43 54 1 27 21 111 100 38 62
[100] 24 6 94 110 39 69 4 51 52 17 12 75 90 55 73 45 46
72 34 61 3> r.w=sum(r*iwithin)/sum(iwithin)
> r.w
[1] NaN
Thanks
Uma
[[alternative HTML version deleted]]