gl.fst.pop matrix confusion

54 views
Skip to first unread message

Rafa Martin

unread,
Feb 28, 2023, 11:30:48 AM2/28/23
to dartR
Hi, new user here,
 I'm trying to get a pairwise fst matrix for my 12 pops from my filtered data for using to compute IBD with non-euclidean geographic distance matrix for my 12 points, but I'm getting a matrix that I cannot use for the comparison (too large compared to the 12 by 12 of my non-eucl. dist) when I use the "gl.fst.pop" function. What I'm getting wrong? This is my code so far:

##################################################

##Loading and filtering of my data##
###########################
SLat<-gl.read.dart(filename="PreviousData.csv.csv", ind.metafile="laminaria2.csv", nas="-", topskip= 6, probar=TRUE)

SL<-gl.drop.pop(SLat, pop.list=c("Alaska", "Connecticut","Ireland", "Maine", "Rhode_island", "Norway", "washington", "russia", "NewHampshire", "NewYork", "Iceland", "Korea", "Denmark", "CapeCod"))

SL1 <- gl.filter.monomorphs(SL, v=0)

SL2 <- gl.filter.callrate(SL1, method = "loc", threshold = 0.95) #filter for loci with more than 5% of missing data

SL3 <- gl.filter.secondaries(SL2) #filter for doubled loci

SL4 <- gl.filter.callrate(SL3, method = "ind", threshold = 0.80) #filter for individuals with more than 20% of missing data

SL5 <- gl.filter.callrate(SL4, method = "loc", threshold = 0.97)#filter for loci with more than 3% of missing data

SL6 <- gl.filter.callrate(SL5, method = "ind", threshold = 0.97)#filter for individuals with more than 3% of missing data

SL7 <- gl.filter.callrate(SL6, method = "loc", threshold = 0.995)#filter for loci with more than 0.5% of missing data

###Producing the fst pairwise matrix by pops####
#####################################

GenNeo <- gl.fst.pop(SL7, nboots = 100, percent = 95, nclusters = 1, verbose = NULL)

FST <- as.numeric(unlist(GenNeo))

FSTNeo <- as.matrix(as.dist(FST))
############################################################



Thnx!

Jose Luis Mijangos

unread,
Feb 28, 2023, 6:04:28 PM2/28/23
to dartR
Hi,

You can try the following code:

library(dartR)
library(dismo)
test <- platypus.gl
# Genetic distance matrix
res <- gl.fst.pop(test)
# converting to distance matrix
D_gen <- as.dist(res$Fsts)
# Geographic distance matrix
coords <- Mercator(test@other$latlon[, c("lon", "lat")])
pop.xy <- apply(coords, 2, function(a){
    tapply(a, pop(test), mean, na.rm = TRUE)
  })
D_geo <- dist(pop.xy)
# IBD analysis
res_2 <- gl.ibd(test,Dgen = D_gen, Dgeo = D_geo)

Cheers,
Luis
Reply all
Reply to author
Forward
0 new messages