[adegenet-forum] resampling individuals from genind

Thibaut Jombart thibautjombart at gmail.com
Mon Apr 16 14:06:25 CEST 2018


Hi Mark,

I wonder if there isn't a function doing just that in poppr, but here's a
simple way to do it using microbov:

## subset 10 pop (I can't use 20 here)
x <- microbov[pop = sample(seq_len(nPop(microbov)), 10)]

## sample individuals with replacement - here, 5 per pop
sampled_indiv <-  unlist(tapply(seq_len(nInd(x)), pop(x), sample, size = 5,
replace = TRUE))
new_data <- x[sampled_indiv]

Cheers
Thibaut


--
Dr Thibaut Jombart
Lecturer, Department of Infectious Disease Epidemiology, Imperial College
London
Head of RECON: repidemicsconsortium.org
WHO Consultant - outbreak analysis
https://thibautjombart.netlify.com
Twitter: @TeebzR
+44(0)20 7594 3658

On 12 April 2018 at 15:17, Mark Coulson <Mark.Coulson.ic at uhi.ac.uk> wrote:

> I have a genind object with ~40 populations of varying sample sizes. I
> want to take 20 of these groups and sample 10 individuals at random
> (without replacement) from each of these 20 populations into a new group
> (which will end up being 200 individuals). I can’t quite figure out how to
> best do this. Does it require seppop? If so then how do I avoid specifying
> a draw of twenty individual for each individually separate population?
>
>
>
> Thanks
>
> Mark
>
>
> Inverness College UHI, a partner in the University of the Highlands and
> Islands www.inverness.uhi.ac.uk Board of Management of Inverness College
> (known as Inverness College UHI), Scottish Charity No SC021197.
>
> _______________________________________________
> adegenet-forum mailing list
> adegenet-forum at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/
> listinfo/adegenet-forum
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20180416/9c770bbe/attachment-0001.html>


More information about the adegenet-forum mailing list