0

I am trying to upload a distance matrix for a PCoA plot produced by the qiime2 pathway into R for data transformation. I can't seem to attach the file here, but here is an example of what the file looks like:

sample distance matrix

The distance matrix is symmetrical in qiime, so the issue should lie within R. I imported the dataset using dm <- read.csv(file = "dm.csv", header = FALSE, row.names = 1) in R.

When I test to see if the distance matrix is symmetrical using isSymmetric.matrix(dm), the output is 'FALSE'. Any guidance as to how I would get a symmetrical distcance matrix would be greatly appreciated.

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • 2
    It _looks_ symmetric to the eye, I wonder if this is related to https://stackoverflow.com/q/9508518/3358272 – r2evans Jun 08 '23 at 19:09
  • 4
    Did you convert it to `matrix` class? `read.csv` returns a data frame, not a matrix. I wonder if that's why you're calling `isSymmetric.matrix(dm)` instead of just `isSymmetric(dm)`. If it is a `matrix`, you shouldn't need to specify. Try `isSymmetric(as.matrix(dm))` – Gregor Thomas Jun 08 '23 at 19:13
  • 1
    Check the CSV. You might have lost precision when saving the data as a CSV. E.g., I know that Excel only saves digits that are being displayed as a CSV. The screenshot show different numbers of digits for different columns. – Roland Jun 09 '23 at 05:23

0 Answers0