Thank you Juan and Akos for all your help. It worked.

Gian

On Mon, 3 Jun 2019 at 18:03, Juan Antonio Balbuena <j.a.balbu...@uv.es>
wrote:

> 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 <bfalevl...@gmail.com
> > > <mailto:bfalevl...@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
> can
> > >     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
> > >     vegan::mantel test.
> > >     > However, rows and columns of the two objects are not in the same
> > >     order. Is
> > >     > there a way to reorder them one another?
> > >     >
> > >     > For example,
> > >     >
> > >     >> dist_a
> > >     >          Lycovolu  Hupeaust  Lycofast  Lycodeut
> > >     > Hupeaust 0.9045557
> > >     >
> > >     > Lycofast 0.6835441 0.8569781
> > >     >
> > >     > Lycodeut 0.8036577 0.8294657 0.7958988   ...
> > >     > ...
> > >     >
> > >     >> dist_b
> > >     >           Lycodeut   Lycofast   Lycoscar   Lycovolu
> > >     > Lycofast 0.09340659
> > >     >
> > >     > Lycoscar 0.08974359 0.01831502
> > >     >
> > >     > Lycovolu 0.09073476 0.01099655 0.01008080   ...
> > >     > ...
> > >     >
> > >     > Thanks,
> > >     >
> > >
> > >     _______________________________________________
> > >     R-sig-ecology mailing list
> > >     R-sig-ecology@r-project.org <mailto:R-sig-ecology@r-project.org>
> > >     https://stat.ethz.ch/mailman/listinfo/r-sig-ecolog
> > >     <https://stat.ethz.ch/mailman/listinfo/r-sig-ecology>y
> > >
> > >
> > >
> > > /----- Do not print this email unless you really need to. Save paper
> > > and protect the environment! -----/
> >
> >
> >       [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-ecology mailing list
> > R-sig-ecology@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> >
>
>
> --
> --
> Dr. Juan A. Balbuena
> Cavanilles Institute of Biodiversity and Evolutionary
> Biology
> University of Valencia
> P.O. Box 22085
> 46071 Valencia, Spain
> e-mail: j.a.balbu...@uv.es    tel. +34 963 543 658
> +++++++++++++++++++++++++++++++++++++++++++++++++++
> NOTE! For shipments by EXPRESS COURIER use the
> following street address:
> C/ Catedrático José Beltrán 2, 46980 Paterna
> (Valencia), Spain.
> +++++++++++++++++++++++++++++++++++++++++++++++++++
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>


-- 
Gian Maria Niccolò Benucci, Ph.D.
Michigan State University
Department of Plant, Soil and Microbial Sciences
1066 Bogue Street
48825 East Lansing, MI
Lab: +1 (517) 844-6966
Email: gian.benu...@gmail.com


*----- Do not print this email unless you really need to. Save paper and
protect the environment! -----*

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology

Reply via email to