[R-sig-genetics] Suggestions regarding randomly repooling genind objects
Zhian Kamvar
kamvarz at science.oregonstate.edu
Thu Jan 5 15:46:29 CET 2017
Hi,
The function repool() can take a list object, and you can subset a list with replacement. The sample() function will allow you to randomly sample any vector with or without replacement.
For this problem, you should only need one loop/apply function.
Here's an example:
library(adegenet)
data(nancycats)
nanpop <- seppop(nancycats, drop = FALSE)
repooled <- lapply(seq(2, nPop(nancycats)), function(n) repool(nanpop[sample(17, n)]))
In the end, this will give you a list of repooled genind objects where each genind object only contains unique populations and the last object is the same size as the original, but in a different order. If you wanted the potential for duplicate populations within your data, you would add replace = TRUE to the sample() function.
Hope that helps,
Zhian
> On Jan 5, 2017, at 06:04 , Bhuller, Ravneet <ravneet.bhuller13 at imperial.ac.uk> wrote:
>
> Dear Members,
>
> I have subset the genind object by population using seppop.
>
> This has given me a new obj (which is a list of genind objects)
>
> Now I want to randomly repool genind objects - incrementing the repooling size by 1 every time:
>
> e.g.
>
> 1. randomly repool 2 genind objects, with replacement
> 2. randomly repool 3 genind objects, with replacement
>
> and so on until all the genind objects are repooled.
>
> Please if anyone can give me any suggestions on how to do this. I have tried various for loops but not successful.
>
> Many thanks,
>
> Rav
> _______________________________________________
> R-sig-genetics mailing list
> R-sig-genetics at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-genetics
More information about the R-sig-genetics
mailing list