// constant for sampling ages 2-19 - proportion
defineConstant("SampProp", c(0.003, 0.003, 0.008, 0.027, 0.041, 0.099, 0.109, 0.134, 0.152, 0.145, 0.125, 0.076, 0.034, 0.029, 0.008, 0.002, 0.002, 0.002));
// sample 5% of possible sample population during years 90 to 95, inclusive
90:95 late() {
// get the total number of indivdiuals of age 2 to 19
num_2_to_19 = sum(tabulate(p1.individuals.age, maxbin = 50)[2:19]);
nsamp = rbinom(1,num_2_to_19,0.1);
for(a in 1:17) {
TmpProp = SampProp[a];
// get number for the given age
ns = rbinom(1, nsamp, TmpProp);
if(ns > 0) {
// then sample them:
samps = p1.sampleIndividuals(ns, minAge = a+1, maxAge = a+1);
// output sample into a VCF format
samps.outputIndividuals();
samps.outputIndividualsToVCF("SampleVCF_SLiMTest.vcf",append=T);
// then write these out:
for(s in samps) {
s_name = paste0(s.sex, sim.cycle - s.age, "_0_", s.tag);
line = paste(s_name, "", "", sim.cycle, "0", "", "", sep = "\t");
writeFile("spip_samples.tsv", line, append = T);
}
}
}
}
--
SLiM forward genetic simulation: http://messerlab.org/slim/
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/slim-discuss/d54bbb22-1d85-460d-91ec-5e1238df5807n%40googlegroups.com.