What are the labels in my rstats distance matrix?

I have a distance matrix generated by hierfstat, thusly, with a link to the fasta file here:

library(adegenet)
library(hierfstat)
snps <- fasta2DNAbin('test.fa', chunkSize = 50)
gi <- DNAbin2genind(snps)
# manually define the populations for passing to pairwise.fst
p <- c('Botswana', 'Botswana', 'Botswana', 'Botswana', 'France', 'France', 'Vietnam', 'Vietnam', 'Uganda', 'Uganda', 'Uganda', 'Uganda', 'Vietnam', 'Vietnam', 'Laos', 'Laos', 'Laos', 'Vietnam', 'Vietnam', 'Vietnam', 'Vietnam', 'Vietnam')
f <- pairwise.fst(gi, p, res.type = c('dist', 'matrix'))
as.matrix(f)


which produces

    1   2   3   4   5
1   0   0.2189008   0.225567409 0.1821518   0.259409722
2   0.2189008   0   0.130736953 0.1648034   0.191050772
3   0.2255674   0.130737    0   0.1669077   0.006396789
4   0.1821518   0.1648034   0.166907683 0   0.203931457
5   0.2594097   0.1910508   0.006396789 0.2039315   0


Is it safe to assume that 1 = Botswana, 2 = France, 3 = Vietnam, 4 = Uganda and 5 = Laos? i.e. that the distance matrix rows/columns follow the order that each population first appeared in p?

Is there a way to determine for certain, which row/column in the distance matrix corresponds to which population?

• Welcome to Bioinformatics! You can change the order of your columns in the input and see how is the output, if the columns in the output follow the columns in the input, then it would be safer. But this is from adegenet package, isn't it? Could you provide some test data to try myself? Otherwise you could check the source code of pairwise.fst
– llrs
Jun 28 '17 at 7:10
• added a test file and the libraries I was using :-) i guess i could go into the source code or permute the samples to check, but seems sensible that there would be a option just to print them somehow... Jun 28 '17 at 8:08

Disclaimer: I don't have adagenet and hierfstat installed, I just looked at the source code. It seems like pairwise.fst (the deprecated code from the adagenet package, which you seem to be using) already returns a matrix. Set res.type="matrix" and try calling rownames(f) and colnames(f) afterwards.
• I was searching for the source code. There are pairwise.fst functions in adagenet and in hierfstat. If you look at the function in the adagenet repo, you will see that it is commented out (R/fstat.R). It is, to my (limited) understanding, one of the functions that have been outsourced/exported to the hierfstat package. Jun 29 '17 at 11:10