[R] Problems with ecodist
Sarah Goslee
sarah.goslee at gmail.com
Thu Jan 20 12:56:12 CET 2011
Hi,
If you read the help for mantel, it says that the data must be either
vectors of dissimilarities or objects of class dist. Since you are
reading in your data as full symmetric matrices, you have two options:
> mantel(as.dist(distancematrix) ~ as.dist(distancematrix1))
mantelr pval1 pval2 pval3 llim.2.5% ulim.97.5%
0.07596818 0.29100000 0.71000000 0.73000000 -0.02049799 0.22440245
> mantel(lower(distancematrix) ~ lower(distancematrix1))
mantelr pval1 pval2 pval3 llim.2.5% ulim.97.5%
0.07596818 0.31400000 0.68700000 0.74000000 -0.03329888 0.20299330
Sarah
On Thu, Jan 20, 2011 at 3:03 AM, deyan <gedy at ioz.ac.cn> wrote:
>
> Dear Dr.Goslee and anyone may intrested in matrix manipulate,
> I am using your ecodist to do mantel and partial mantel test, I have
> locality data and shape variation data, and the two distance matrixs are
> given as belowings. When I run the analysis, it is always report that the
> matrix is not square, but I didn't know what's wrong with my data. Would you
> please help me on this. I am quite new to R.
>
> Thanks.
>
>> distancematrix <- as.matrix(read.table("test1.txt"))
>> distancematrix1 <- as.matrix(read.table("test2.txt"))
>> distancematrix1
> Loc1 Loc2 Loc3 Loc4 Loc5 Loc6 Loc7
> Loc8 Loc9 Loc10 Loc11 Loc12
> Loc1 0.000 2293.8671 2180.7127 7563.934 2494.5049 2522.3946 5953.609
> 2511.5994 2047.683 4448.721 3180.844 3112.6798
> Loc2 2293.867 0.0000 443.2497 9831.220 472.2009 397.4316 8213.580
> 1114.9120 2087.877 6723.807 2407.192 1314.6927
> Loc3 2180.713 443.2497 0.0000 9620.263 915.4497 836.5849 8001.565
> 708.1212 2377.024 6627.808 2818.822 1063.8092
> Loc4 7563.934 9831.2199 9620.2627 0.000 10057.8311 10085.8054 1619.041
> 9639.4505 8967.156 3482.672 10046.113 10253.9565
> Loc5 2494.505 472.2009 915.4497 10057.831 0.0000 112.6242 8448.063
> 1569.7006 1846.755 6845.471 1983.525 1670.4862
> Loc6 2522.395 397.4316 836.5849 10085.805 112.6242 0.0000 8473.279
> 1473.1610 1951.517 6897.051 2092.925 1558.8962
> Loc7 5953.609 8213.5803 8001.5652 1619.041 8448.0626 8473.2789 0.000
> 8034.9093 7447.264 2171.838 8568.467 8654.3923
> Loc8 2511.599 1114.9120 708.1212 9639.451 1569.7006 1473.1610 8034.909
> 0.0000 3064.747 6870.287 3518.951 631.5406
> Loc9 2047.683 2087.8774 2377.0240 8967.156 1846.7549 1951.5175 7447.264
> 3064.7466 0.000 5528.956 1182.826 3397.4896
> Loc10 4448.721 6723.8068 6627.8081 3482.672 6845.4709 6897.0513 2171.838
> 6870.2865 5528.956 0.000 6572.264 7497.8614
> Loc11 3180.844 2407.1921 2818.8222 10046.113 1983.5246 2092.9254 8568.467
> 3518.9508 1182.826 6572.264 0.000 3647.8307
> Loc12 3112.680 1314.6927 1063.8092 10253.957 1670.4862 1558.8962 8654.392
> 631.5406 3397.490 7497.861 3647.831 0.0000
>> distancematrix
> sample1 sample2 sample3 sample4 sample5 sample6 sample7 sample8
> sample9 sample10 sample11 sample12
> sample1 0.0000 0.0229 0.0258 0.0394 0.0295 0.0337 0.0269 0.0345
> 0.0314 0.0418 0.0577 0.0853
> sample2 0.0229 0.0000 0.0219 0.0373 0.0337 0.0352 0.0320 0.0310
> 0.0275 0.0508 0.0533 0.0739
> sample3 0.0258 0.0219 0.0000 0.0349 0.0375 0.0332 0.0309 0.0233
> 0.0246 0.0522 0.0539 0.0748
> sample4 0.0394 0.0373 0.0349 0.0000 0.0590 0.0514 0.0356 0.0321
> 0.0354 0.0737 0.0365 0.0652
> sample5 0.0295 0.0337 0.0375 0.0590 0.0000 0.0311 0.0482 0.0474
> 0.0401 0.0331 0.0726 0.0931
> sample6 0.0337 0.0352 0.0332 0.0514 0.0311 0.0000 0.0406 0.0362
> 0.0363 0.0429 0.0708 0.0903
> sample7 0.0269 0.0320 0.0309 0.0356 0.0482 0.0406 0.0000 0.0359
> 0.0370 0.0536 0.0625 0.0888
> sample8 0.0345 0.0310 0.0233 0.0321 0.0474 0.0362 0.0359 0.0000
> 0.0267 0.0649 0.0498 0.0662
> sample9 0.0314 0.0275 0.0246 0.0354 0.0401 0.0363 0.0370 0.0267
> 0.0000 0.0569 0.0583 0.0693
> sample10 0.0418 0.0508 0.0522 0.0737 0.0331 0.0429 0.0536 0.0649
> 0.0569 0.0000 0.0919 0.1150
> sample11 0.0577 0.0533 0.0539 0.0365 0.0726 0.0708 0.0625 0.0498
> 0.0583 0.0919 0.0000 0.0601
> sample12 0.0853 0.0739 0.0748 0.0652 0.0931 0.0903 0.0888 0.0662
> 0.0693 0.1150 0.0601 0.0000
>> mantel(distancematrix~distancematrix1)
> error mantel(distancematrix ~ distancematrix1) : Matrix not square.
> --
> View this message in context: http://r.789695.n4.nabble.com/Problems-with-ecodist-tp3225480p3225480.html
> Sent from the R help mailing list archive at Nabble.com.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Sarah Goslee
http://www.stringpage.com
http://www.astronomicum.com
http://www.functionaldiversity.org
More information about the R-help
mailing list