Hi Gian,
A Mantel test looks right for your problem. Check also protest in vegan.
Best,
Juan A. Balbuena
Dear Gian,
I'm not a statistician but software developer... hope that other members
of the mailing list are expert of distance matrices and can answer your
question.
Have a nice week,
?kos
2019.06.03. 17:44 keltez?ssel, Gian Maria Niccol? Benucci ?rta:
Hi Akos,
Thank you for the code. It worked. I reordered the dist objects as I
cannot access the dataset of one of the two distance matrix.
dist_b_reordered <- as.dist(as.matrix(dist_b)[attr(dist_a,
"Labels"), attr(dist_a, "Labels")])
all.equal(dist_a, dist_b_reordered, check.attributes = FALSE)
[1] "Mean relative difference: 0.8977224"
There is any statistical test that you suggest to compare the two
distances? I would like to see if the two matrices show a similar
pattern, e.g. mantel test?
Thanks,
Gian
On Sat, 1 Jun 2019 at 00:55, Bede-Fazekas ?kos <bfalevlist at gmail.com
<mailto:bfalevlist at gmail.com>> wrote:
Dear Gian,
Let's do a small reproducible example:
library(vegan)
data(varespec)
set.seed(12345)
df_a <- t(varespec)
df_b <- t(varespec[, sample.int
<http://sample.int>(ncol(varespec))]) # shuffle the original
column order
dist_a <- vegdist(df_a); dist_b <- vegdist(df_b)
all.equal(dist_a, dist_b, check.attributes = FALSE)
Now, you have two options. If you have access to the original
data.frame/matrix from which the dist object was created, you can
reorder the rows of the second dataset to match that of the first
one.
Then do the distance matrix calculation again.
df_b_reordered <- df_b[rownames(df_a), ]
dist_b_reordered1 <- vegdist(df_b_reordered)
all.equal(dist_a, dist_b_reordered1, check.attributes = FALSE)
If you have no access to the original dataset and/or can not
recalculate
the distance matrix (e.g. due to computer capacity or time), you
reorder the distance matrix (both the rows and columns).
dist_b_reordered2 <- as.dist(as.matrix(dist_b)[attr(dist_a,
"Labels"),
attr(dist_a, "Labels")])
all.equal(dist_a, dist_b_reordered2, check.attributes = FALSE)
HTH,
?kos Bede-Fazekas
Hungarian Academy of Sciences
2019.06.01. 1:53 keltez?ssel, Gian Maria Niccol? Benucci ?rta:
> Hello,
>
> I have two vegan::vegdist objects I want to use into a
> However, rows and columns of the two objects are not in the same
> there a way to reorder them one another?
>
> For example,
>
> Lycovolu Hupeaust Lycofast Lycodeut
> Hupeaust 0.9045557
>
> Lycofast 0.6835441 0.8569781
>
> Lycodeut 0.8036577 0.8294657 0.7958988 ...
> ...
>
> Lycodeut Lycofast Lycoscar Lycovolu
> Lycofast 0.09340659
>
> Lycoscar 0.08974359 0.01831502
>
> Lycovolu 0.09073476 0.01099655 0.01008080 ...
> ...
>
> Thanks,
>