Hi Ben and all,
First, thanks for SLiM5!
Ben, I have this model with more than one subpopulation. I want to export a vcf file from SLiM to be further transformed to a genlight in R for downstream analyses.
On my previous code, I had VCFs being exported for each subpopulation which was combined a posteriori:
(something along these lines:)
if (sim.cycle > burnin)
{
if (logclock == sampfr)
{
for (l in community.logFiles)
{
l.logRow();
}
for (b in sim.subpopulations)
{
b.genomes.outputVCF(paste0(directory,"/VCF_p"+b.id+"_"+idtag+"_g"+sim.cycle+".vcf"), outputMultiallelics = F);
}
defineGlobal("logclock", 0);
} }
Which worked, just required some extra work after to combine, make sure they had the same size, etc.
Now as I am updating my code to SLiM5, I wonder if there is anyway I can export a single vcf for individuals from all subpopulations and be able to know who is who when I process the vcf later on.
I have tried the following:
sim.subpopulations.haplosomes.outputHaplosomesToVCF(filePath="/PATH/slim5/test.vcf" ,outputMultiallelics=F, simplifyNucleotides=T, groupAsIndividuals=T);
Which does produce a single vcf with all the individuals at the time of export (e.g. p1.individualCount = 81, p2.individualCount = 102, VCF has 183 individuals).
But I can't seem to find any information about who comes from where in the vcf/genlight later on.
In R, when I transform this test VCF into genlight and I ask for individual names, I get i0, i1, i2,...,i182 (total 183 individuals), with no subpop info.
Is it safe to assume that the first 81 individuals (i0 to i80) come from p1 and the following 102 inds (i81 to i182) come from p2? Is that how the inds in the VCF file produced by SLiM are organized? If so, that is straight forward to figure out later on who comes from where.
There is also a way to append the subpop info to the ind name?
Thanks Ben!
Cheers
JP