Hy4m / linkET

Everything is Linkable
135 stars 38 forks source link

can we set spec_dist to none when the input is bray distance? #28

Closed lixiaopi1985 closed 2 weeks ago

lixiaopi1985 commented 3 weeks ago

Hi,

As you mentioned in other posts, the row sum of the OTU table can not be zero in order to use the bray distance in the mantel_test().

I checked the out table I am working with, and there was no zero row sum:

> sum(rowSums(otuITS.OR) == 0)
[1] 0

Still encountered the error:

Error in `purrr::pmap()`:
ℹ In index: 1.
Caused by error in `cor()`:
! missing observations in cov/cor
Run `rlang::last_trace()` to see where the error occurred.
Warning messages:
1: In .FUN(.data, ...) : you have empty rows: their dissimilarities may be
                 meaningless in method “bray”
2: In .FUN(.data, ...) : missing values in results

With this, I wondered whether we could calculate bray distance and use this matrix as input for the mantel_test? - I did not get an error for using the vegdist() to calculate the bray distance. Also, does the mantel_test scale for the env matrix?

Maybe something like this:

dist16S = as.matrix(vegdist(otu16S, method = "bray", upper = T, diag = T))
mantest.16S = mantel_test(
  spec = dist16S,
  env = scale(soilprop16S),
  spec_dist = "none",
  env_dist = "euclidean",
)

Thank you, Xiao