Skip to main content
added 113 characters in body
Source Link
Remi.b
  • 68.3k
  • 11
  • 144
  • 235

There are a number of tools but I don't know any that comes with an R library. They are usually all called from the command line. I don't either of any that produce FASTA file. SimBit (my own software) can produce vcf files which can easily be converted into FASTA with PGDspider.

However, if your simulations are so easy, you might not need these complex individual-based softwares. Just write the code yourself. It might only be take a few tens of lines. Here is a simple example

freq = 0.1 # initial frequency
N = 1000   # Constant population size
mu = 1e-7  # mutation rate

for (generation in 1:nbGenerations)
{
   # Drift
   freq = rbinom(1,N,freq) / N

   # Mutations
   oneWayMutations   = rbinom(1,N*freq,mu) / N
   otherWayMutations = rbinom(1,N*(1-freq),mu) / N
   freq = freq - oneWayMutations + otherWayMutations
}

If you need something more complex (such as several loci), then you should probably use one of the existing individual-based software. See the post Sequence evolution simulation tool

There are a number of tools but I don't know any that comes with an R library. They are usually all called from the command line. I don't either of any that produce FASTA file. SimBit (my own software) can produce vcf files which can easily be converted into FASTA with PGDspider

However, if your simulations are so easy, you might not need these complex individual-based softwares. Just write the code yourself. It might only be take a few tens of lines. Here is a simple example

for (generation in 1:nbGenerations)
{
   # Drift
   freq = rbinom(1,N,freq) / N

   # Mutations
   oneWayMutations   = rbinom(1,N*freq,mu) / N
   otherWayMutations = rbinom(1,N*(1-freq),mu) / N
   freq = freq - oneWayMutations + otherWayMutations
}

There are a number of tools but I don't know any that comes with an R library. They are usually all called from the command line. I don't either of any that produce FASTA file. SimBit (my own software) can produce vcf files which can easily be converted into FASTA with PGDspider.

However, if your simulations are so easy, you might not need these individual-based softwares. Just write the code yourself. It might only be take a few tens of lines. Here is a simple example

freq = 0.1 # initial frequency
N = 1000   # Constant population size
mu = 1e-7  # mutation rate

for (generation in 1:nbGenerations)
{
   # Drift
   freq = rbinom(1,N,freq) / N

   # Mutations
   oneWayMutations   = rbinom(1,N*freq,mu) / N
   otherWayMutations = rbinom(1,N*(1-freq),mu) / N
   freq = freq - oneWayMutations + otherWayMutations
}

If you need something more complex (such as several loci), then you should probably use one of the existing individual-based software. See the post Sequence evolution simulation tool

Source Link
Remi.b
  • 68.3k
  • 11
  • 144
  • 235

There are a number of tools but I don't know any that comes with an R library. They are usually all called from the command line. I don't either of any that produce FASTA file. SimBit (my own software) can produce vcf files which can easily be converted into FASTA with PGDspider

However, if your simulations are so easy, you might not need these complex individual-based softwares. Just write the code yourself. It might only be take a few tens of lines. Here is a simple example

for (generation in 1:nbGenerations)
{
   # Drift
   freq = rbinom(1,N,freq) / N

   # Mutations
   oneWayMutations   = rbinom(1,N*freq,mu) / N
   otherWayMutations = rbinom(1,N*(1-freq),mu) / N
   freq = freq - oneWayMutations + otherWayMutations
}