--
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 on the web visit https://groups.google.com/d/msgid/slim-discuss/9796a122-63ba-4bb1-882e-5315a708beb0n%40googlegroups.com.
Hi Benjamin,
I have been working with Tiina to use the slim software to calculate FST values of a simulated population after six generations, then using these simulated VCFs to compare statistics with our real populations after six generations to disentangle the effect of drift and selection. Following your previous advice is the below code correct? We also wanted to calculate FST values for our real data so it is the same methodology, and to make sure it is identical to simulation methods. I wrote the code (listed below the simulation code) and found the FST values to be very high (0.3) whilst the simulated values are much smaller (0.0012-0.0013) and tenfold higher than other methods such as through VCFtools. Could you please advice why this may be the case?
Kind regards,
Danny
Code for simulating six generations:
// set up a simple neutral simulation (manual p. 519)
initialize() {
initializeSLiMOptions(nucleotideBased=T);
length = initializeAncestralNucleotides("chr2.fa");
defineConstant("L", length);
initializeMutationTypeNuc("m1", 0.5, "f", 0.0); //neutral mutations
m1.convertToSubstitution = F;
initializeGenomicElementType("g1", m1, 1.0, mmJukesCantor(0.0)); //jukescantor for selection only from standing genetic variation
initializeGenomicElement(g1, 0, L-1); //chr length from fasta
initializeRecombinationRate(1e-8);
}
1 early() {
sim.addSubpop("p1", 42); //create a subpopulation of 42 individuals
p1.genomes.readFromVCF("chr2.vcf.vcf", m1); //creates the SNPs from the VCF file as mutations in the target genomes. This example contains 1192 snps
//p2.genomes.readFromVCF("chr2.vcf.vcf", m1);
p1.setSubpopulationSize(500);
}
2 early() {
sim.addSubpop("p2", 250); //create a subpopulation of 42 individuals
sim.addSubpop("p3",250); //create a subpopulation of 42 individuals
p2.setMigrationRates(c(p1), c(0.5));
p3.setMigrationRates(c(p1),c(0.5));
log = community.createLogFile("sim_log_2.txt", logInterval=1);
//for each interal do this
log.addCycle();
log.addCustomColumn("FST", "calcFST(p2.genomes, p3.genomes);");
log.addCustomColumn("mutations","sim.mutations.size();");
}
6 late() {
//sim.outputFull();
// get a sample of 42 individuals, and then get the genomes
s1 = sample(p2.individuals, 42).genomes;
s2 = sample(p3.individuals, 42).genomes;
sampleFST=calcFST(p3.genomes, p3.genomes);
catn("sample FST "+ sampleFST);
p1.genomes.outputVCF("simulated_p1.vcf",simplifyNucleotides=T);
p2.genomes.outputVCF("simulated_p2.vcf",simplifyNucleotides=T);
sim.simulationFinished();
}
Slim code 2 for FST values of real data six generations later (note it is written in a format for a batch script to run each chromosome separately and run the simulation 50 times):
#!/bin/bash
chr=$1
inputvcf=$2
# Path to the Slim executable
slim_executable="slim"
# Number of simulations to run
num_simulations=1
# Loop to run the simulation 50 times
for ((i = 1; i <= num_simulations; i++)); do
slimfiletext='
initialize() {
initializeSLiMOptions(nucleotideBased=T);
length = initializeAncestralNucleotides("'"${chr}"'.fa");
defineConstant("L", length);
initializeMutationTypeNuc("m1", 0.5, "f", 0.0); //neutral mutations
m1.convertToSubstitution = F;
initializeGenomicElementType("g1", m1, 1.0, mmJukesCantor(0.0)); //jukescantor for selection only from standing genetic variation
initializeGenomicElement(g1, 0, L-1); //chr length from fasta
initializeRecombinationRate(1e-8);
}
1 early() {
sim.addSubpop("p1", 41); //create a subpopulation of 42 individuals
sim.addSubpop("p4", 41);
p1.genomes.readFromVCF("'"${inputvcf}"'", m1); //creates the SNPs from the VCF file as mutations in the target genomes. This example contains 1192 snps
p4.genomes.readFromVCF("RS1_chr1_inpute.vcf.vcf", m1);
p1.setSubpopulationSize(500);
p4.setSubpopulationSize(500);
}
1 early() {
log = community.createLogFile("sim_log_'"${chr}"'_'"${i}"'.txt", logInterval=1);
//for each internal do this
log.addCycle();
log.addCustomColumn("FST", "calcFST(p1.genomes, p4.genomes);");
log.addCustomColumn("mutations","sim.mutations.size();");
sampleFST=calcFST(p1.genomes, p4.genomes);
catn("sample FST "+ sampleFST);
}'
echo "${slimfiletext}" > slimsim_"${chr}"_"${i}".txt
# Run the Slim simulation with a unique output file and log file for each run
$slim_executable slimsim_"${chr}"_"${i}".txt > output_"${chr}"_"${i}".log 2>&1
done
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/7d96b961-7180-415e-9ca0-f68d7dcb8ce2n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/slim-discuss/e61cc199-2a19-4cf9-b1fb-6a1ae9d23753n%40googlegroups.com.