change order of populations in gl.fst.pop

27 views
Skip to first unread message

Sandra Erdmann

unread,
May 9, 2024, 5:06:22 AMMay 9
to dartR
Hi dartR Team,

I've been trying to do this for a while in many different ways, but without success. Is there any way that I can rearrange my populations when applying the function gl.fst.pop? I see that it works through the pairwise comparisons a bit randomly(!?), but I would like to manually sort them in geographical order. Of course, I can manipulate this after running the function, but that takes time when you have 15 populations... Does it make sense to sort the genlight object before using it to run that function or does the ordering occur when the function runs? If it makes sense to do beforehand, how does it work???
This might be more of a R wrangling issue, but I appreciate to get any tips how to do this.

Thanks,
Sunny

Jose Luis Mijangos

unread,
May 9, 2024, 9:24:40 PMMay 9
to dartR
Hi Sunny,

You can try:

library(dartR.base)
t1 <- bandicoot.gl
popNames(t1)
t2 <- gl.sort(t1,
        sort.by = "pop",
        order.by = c("NSW" ,"QLD","SA" , "VIC" ,"WA" ) )
fst <- gl.fst.pop(t2)

Cheers,
Luis 

Sandra Erdmann

unread,
May 20, 2024, 4:14:18 AMMay 20
to da...@googlegroups.com
Hi Luis,

Thank you so much! I've applied it to my dataset and it worked. So simple at the end. Hope this helps others, too.


Thanks,
Sunny


--
You received this message because you are subscribed to a topic in the Google Groups "dartR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dartr/0kJJ98keExQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dartr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartr/86b392e7-350a-4581-8645-afb972ba7233n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages