Hi,
I have just started using the gl.spatial.autoCorr() function and I already have issues at the start.... :/
The functions runs fine, but the plot looks weird, no matter which distances (max and bins) I use.
I don't get any curve/lines representing the relatedness of samples across bins, I only get a bar for each population or for each sex (I tried both with pop = pop, or pop=sex) that is fixed at the start...
What am I doing wrong?
I checked my lon and lat info:
it is reported correctly i think:
head(my_dataset_genlight@other$latlon)
ind ID lat lon
1 -25.5 153.35
I tried also to convert the lat lon data with Mercator:
the Mercator function was giving me this warning message:
# Warning message:
# In .pointsToMatrix(p, checkLonLat = FALSE) :
# Suspect column names (longitude and latitude reversed?)
So, I reversed the order of lat lon in my genlight, like this
my_dataset_genlight@other$latlon =
my_dataset_genlight@other$latlon[ ,c(2,1)]
then run Mercator:
my_dataset_genlight@other$latlon = Mercator(
my_dataset_genlight@other$latlon , inverse= T)
ind ID lat lon
1 -0.00022 0.0013
Although I am not sure if I should transform to Mercator, if my lat and lon is taken from Google map positions?
Anyways, this is the code I used:
gl.spatial.autoCorr(my_dataset_genlight,
bins = seq(0, 1500000, 100000),
plot.pops.together = FALSE,
plot.colors.pop = c('#E69F00', '#5D3FD3', "red", "blue", "green", "violet"))
I also tried running the functions in this way:
- plot.pops.together = TRUE
- replace pop(my_dataset_genlight) = my_dataset_genlight@other$ind.metrics$sex
- changing the bins to seq(0, 150, 10)
But I always get the same result with no lines plotted...and a single bar for each pop/each sex at the very start of the plot...
I also tried to convert to Mercator, but with inverse = F (which seems more correct as I am passing from latlon to Mercator), but then when I run the spatial autocorrelation with the dataset converted in this way, i get the message:
Error in x_temp@other$latlon[ , c("lon", "lat")]: suscript out of bound
What am I doing wrong?
See plot attached...
I would really appreciate some help!!
Thanks a lot!
Gabriella