BACKGROUND
these years witness popularity of coalescent based inference of evolutionary parameters, either through exact or approximate methods in order to understand within-species, and in particular human, evolution.
this is fuelled by large scale efforts to collect data from different human populations, e.g.
the hapmap  <cit>  and encode projects in humans.
important aims are to link genetic variation to phenotypic traits, e.g.
complex disease, in order to identify the causal variants, as well as the human genetic history and dispersal.
the coalescent models are good null models to test specific hypotheses against, and therefore it is often useful to simulate genetic data under different coalescent models.
coalescent simulation of data sets and subsequent calculation of some summary statistics on the data set can be used to obtain the distribution of this summary statistic under a given scenario, and this can be compared to the value of the summary statistic calculated from real data.
parametric bootstrapping can be done by estimating parameters from data under a given  model, apply coalescent simulations under some model using the observed value of the parameters and see if the value observed is compatible with the simulation model.
the efficiency of new methods can also be evaluated: methods for inference of recombination rate and its variation, the importance of gene conversion versus recombination, as well as methods for association mapping under different genetic models have to rely on some heuristic approximations of the full likelihood models which are generally too computationally complex.
validating these approximations and inferring the importance of misspecification of the model of analysis employed is usually done using some variant of coalescent simulations.
various applications for the simulation of the coalescent process are already available .
the present application aims at attaining maximum flexibility in model specification.
population size changes, bottlenecks and demographics  can be specified precisely, there is a choice of mutation models , recombination and gene conversion can be specified precisely and are allowed to vary over the region.
furthermore, complex disease models including arbitrary interactions between genes, varying penetrance and environmental effects, can also be specified.
case-control data sets under these disease models and any ascertainment scheme can then be generated for subsequent evaluation of association mapping methods aiming at detecting disease causing variants.
implementation
installation
coasim can be obtained at , where instructions for the installation are also provided.
coasim is written in c++ and is available as source code and in a binary version for linux operating system as rpm-files.
an introduction to the simulator is provided as a "getting started" manual, where also the gui version is described.
the gui is an intuitive interface to the simulator, allowing novice users to immediately start the simulations of sequences.
markers are added manually and the simulation stages can be monitored .
for more advanced purposes, users should turn to the guile-scheme version of coasim.
controlling the simulations through scheme makes coasim a very flexible and powerful simulation tool.
running the application
the coasim guile manual gives a number of examples of simple and advanced usage of the guile scheme version.
scripts that allow the iterative simulation of population samples under various demographic scenarios and disease models are introduced.
an example demographic scenario is illustrated in figure  <dig>  population merging times, sizes, migration rates etc.
needs to be specified in the scheme script.
an example script that simulates the situation in figure  <dig> is shown in figure  <dig>  the advanced usage of the tool for extracting summary statistics such as the mean of the total branch length of the simulated args, the mean of the total tree height, the mean number of recombination nodes and coalescent nodes are all exemplified in scripts accompanying the distribution.
the output format of the sequence or marker data sets  can be specified in the scheme script.
RESULTS
coalescent models
for an introduction to coalescent theory, see for example  <cit> .
basically, the ancestral history of a sample is simulated by repeated drawing of random numbers from competing exponential distributions corresponding to different evolutionary forces such as coalescence, migration, recombination, gene conversion.
coalescent intensities depend on the population size in each of demes where sampled genes are present.
the number of demes, their sizes and the migration matrix are allowed to vary arbitrarily as specified by the input to the simulations.
when an event  occurs, the state of the sample is updated and the intensities of the exponential distributions for the next event calculated.
the process is continued until all parts of the gene have found a most recent common ancestor.
the resulting graph, termed the ancestral recombination graph , is then used to generate data under different mutation models as specified by the user.
data can be generated either under the infinite sites or finite sites model of mutation.
the marker positions can either be specified or chosen randomly, with uniform probability of distribution within the interval.
it is possible either to condition on a mutation rate or on a given number of segregating sites for replicated simulations.
the finite sites model can have any number k of states for a given position.
there are three kinds of built-in markers:
trait markers are binary polymorphisms  with a simple mutation model: after simulating the arg, a mutation is placed uniformly at random on the tree local to the marker position, nodes below the mutation will have the mutant allele while all others will have the wild-type allele.
a range of accepted mutant-frequencies can be specified and a simple rejection-sampling scheme is used to ensure it: if, after placing the mutation, the number of mutant leaves is not within the range, the arg is rejected and the simulation restarted.
this insures an unbiased collection of args with a binary marker within a given frequency range.
snp markers resemble trait markers in that they are binary polymorphisms, and use the same mutation model as the trait-markers.
they differ from the trait-markers in how the mutant-frequency is ensured: if, after the mutation has been placed, the number of mutant leaves does not fall within the accepted range, the mutation is re-placed, but the arg is not rejected and re-simulated.
this places a bias on the markers, but one that resembles the ascertainment bias seen in association studies, where snps are chosen to have frequencies in certain ranges.
an unbiased sampling of mutations within the required frequency range can be obtained by constructing a new arg and repeating the simulation process, until the required frequencies are attained.
microsatellite markers have a specified number of alleles, k, and a different mutation model than traits and snps.
for microsatellite markers, each edge in the local tree at the marker is considered in turn and, with the likelihood of mutation being an exponential distribution that depends on the specified mutation rate and the length of the edge.
if mutation occurs, a randomly chosen allele from  <dig> to k- <dig> is placed on the child node; if no mutation occurs, the child node gets a copy of the allele at the parent node.
in addition to the built-in marker types, scheme scripting allows specification of most conceivable mutation models, the stepwise mutation model for microsatellites is included as an example.
trait markers can be marked as being involved in disease susceptibility under a specified, but arbitrary model of disease risk as a function of biallelic variants at a number of sites specified a priori.
a multidimensional matrix specifies disease risk for any combination of variants.
thus, from the simulated data and the disease model, case-control data of any size can be generated.
diploid data with known or unknown phase can be easily generated by calling the relevant function from the scheme script as specified in the manual.
splitting the sequences into cases and controls based solely on the allele at a trait marker or combination of alleles in a more complex disease determination is not always appropriate since it assumes full penetrance.
however, in many complex diseases, penetrance is incomplete and dependent on environmental factors and general genetic background, and the same disease phenotypically can be caused by a different genetic pathway.
hence, it is possible to control the likelihood of a given individual belonging to the case or control group by specifying the probabilities given the possible genotypes.
population size changes, bottlenecks, merging of populations  and migration between sub-populations can vary arbitrarily as specified through the definitions of epochs in the scheme script controlling the simulation .
speed issues
we have measured execution times for a series of simulations.
simulating  <dig>  snp markers with a minor allele frequency of 10% for  <dig>  chromosomes with a recombination rate of  <dig> took  <dig> seconds on a  <dig>  ghz pentium  <dig>   <dig> gb ram machine.
increasing the recombination rate to  <dig> caused the execution time to increase to  <dig> seconds.
we also simulated a scenario that in likely to find applications in simulating interacting disease loci.
in this scenario,  <dig> sequences were simulated for a setup where two trait markers which frequencies range between 20% to 40% were located in a region of  <dig> snp markers with a minor allele frequency of 10%,.
this simulation took  <dig> seconds.
improvements to existing packages
hudsons program ms provides many of coasims features for population growth, migration, recombination, gene conversion, arbitrary ascertainment schemes, recombination rate variation across the chromosome, stepwise mutation models, trait markers and cases and controls specified by the interaction between genes and genotype-specific penetrance probabilities.
a difference is the ease of extracting the desired output.
using ms, the user has to post-process the output using custom made scripts, whereas coasim provides the required functionalities.
with ms, it is not possible to specify the position of markers, to employ a finite sites mutation model or to simulate linked microsatellites.
some example applications of coasim
we have used coasim for three applications that demonstrate some of its flexibility.
<dig>  estimation of recombination rate and effective population size in iceland from microsatellite data.
in this study, microsatellite diploid, phase unknown, markers were simulated under different mutation models and for different rates of recombination.
the expected decay of different measures of linkage disequilibrium with recombination rate could then be estimated and compared to the expected decay in a large microsatellite data set from iceland.
this allowed us to estimate the effective population size of the icelandic population and to investigate whether the population bears any sign of recent population growth  <cit> .
<dig>  case-control data sets were generated under a simple disease model  but with various rates of heterogeneity and penetrance.
the data with disease causing mutation removed was then directly piped into the generecon program  <cit>  that attempts to infer the disease marker position from all the simulated markers.
this allowed us to investigate the effect of marker density, penetrance, heterogeneity, number of cases/controls etc .
<dig>  the effect of single recombination event.
genealogies were simulated for a given recombination rate but only genealogies with exactly one recombination event were used for simulation of marker  data sets.
these data sets were then used as input to programs aimed at estimating the recombination rate, allowing us to estimate the variance in effect on data that a single recombination event can have and relate this to number of markers, population growth etc .
CONCLUSIONS
the coasim software package was designed for flexibility and with adaptations and extensions of the various scheme scripts provided and the user manual, a wide range of situations can be accommodated.
it provides the user with a much wider range of demographical models, of marker types and disease models without much loss of user friendliness compared to competing software.
availability and requirements
project name: coasim  <dig>
project home page:
source codes for guile and gui versions are supplied
operating system: linux fedora 1– <dig>  redhat  <dig>  and macosx
programming language: c++ and scheme
other requirements: guile scheme version  <dig> .
the gui requires qt version  <dig>
license: gnu
authors' contributions
tm, mhs, cnsp, jnm, ls, planned the project.
tm, jnm and pjmm wrote the software, tm wrote the documentation.
ls and tm tested the software.
mhs, tm, ls and cnsp wrote the paper.
all authors read and approved the final manuscript.
supplementary material
additional file 1
click here for file
additional file 2
click here for file
additional file 3
click here for file
additional file 4
click here for file
acknowledgements
we thank thomas bataillon for useful comments to the manuscript.
tm received support from isis katrinebjerg, mhs, ls and cnsp acknowledges support from the danish natural sciences research council.

 these years witness popularity of coalescent based inference of evolutionary parameters, either through exact or approximate methods in order to understand within-species, and in particular human, evolution. this is fuelled by large scale efforts to collect data from different human populations, e.g. the hapmap and encode projects in humans. important aims are to link genetic variation to phenotypic traits, e.g. complex disease, in order to identify the causal variants, as well as the human genetic history and dispersal. the coalescent models are good null models to test specific hypotheses against, and therefore it is often useful to simulate genetic data under different coalescent models. coalescent simulation of data sets and subsequent calculation of some summary statistics on the data set can be used to obtain the distribution of this summary statistic under a given scenario, and this can be compared to the value of the summary statistic calculated from real data. parametric bootstrapping can be done by estimating parameters from data under a given model, apply coalescent simulations under some model using the observed value of the parameters and see if the value observed is compatible with the simulation model. the efficiency of new methods can also be evaluated: methods for inference of recombination rate and its variation, the importance of gene conversion versus recombination, as well as methods for association mapping under different genetic models have to rely on some heuristic approximations of the full likelihood models which are generally too computationally complex. validating these approximations and inferring the importance of misspecification of the model of analysis employed is usually done using some variant of coalescent simulations. various applications for the simulation of the coalescent process are already available. the present application aims at attaining maximum flexibility in model specification. population size changes, bottlenecks and demographics can be specified precisely, there is a choice of mutation models, recombination and gene conversion can be specified precisely and are allowed to vary over the region. furthermore, complex disease models including arbitrary interactions between genes, varying penetrance and environmental effects, can also be specified. case-control data sets under these disease models and any ascertainment scheme can then be generated for subsequent evaluation of association mapping methods aiming at detecting disease causing variants. implementation installation coasim can be obtained at, where instructions for the installation are also provided. coasim is written in c++ and is available as source code and in a binary version for linux operating system as rpm-files. an introduction to the simulator is provided as a "getting started" manual, where also the gui version is described. the gui is an intuitive interface to the simulator, allowing novice users to immediately start the simulations of sequences. markers are added manually and the simulation stages can be monitored. for more advanced purposes, users should turn to the guile-scheme version of coasim. controlling the simulations through scheme makes coasim a very flexible and powerful simulation tool. running the application the coasim guile manual gives a number of examples of simple and advanced usage of the guile scheme version. scripts that allow the iterative simulation of population samples under various demographic scenarios and disease models are introduced. an example demographic scenario is illustrated in figure population merging times, sizes, migration rates etc. needs to be specified in the scheme script. an example script that simulates the situation in figure is shown in figure the advanced usage of the tool for extracting summary statistics such as the mean of the total branch length of the simulated args, the mean of the total tree height, the mean number of recombination nodes and coalescent nodes are all exemplified in scripts accompanying the distribution. the output format of the sequence or marker data sets can be specified in the scheme script.  coalescent models for an introduction to coalescent theory, see for example. basically, the ancestral history of a sample is simulated by repeated drawing of random numbers from competing exponential distributions corresponding to different evolutionary forces such as coalescence, migration, recombination, gene conversion. coalescent intensities depend on the population size in each of demes where sampled genes are present. the number of demes, their sizes and the migration matrix are allowed to vary arbitrarily as specified by the input to the simulations. when an event occurs, the state of the sample is updated and the intensities of the exponential distributions for the next event calculated. the process is continued until all parts of the gene have found a most recent common ancestor. the resulting graph, termed the ancestral recombination graph, is then used to generate data under different mutation models as specified by the user. data can be generated either under the infinite sites or finite sites model of mutation. the marker positions can either be specified or chosen randomly, with uniform probability of distribution within the interval. it is possible either to condition on a mutation rate or on a given number of segregating sites for replicated simulations. the finite sites model can have any number k of states for a given position. there are three kinds of built-in markers: trait markers are binary polymorphisms with a simple mutation model: after simulating the arg, a mutation is placed uniformly at random on the tree local to the marker position, nodes below the mutation will have the mutant allele while all others will have the wild-type allele. a range of accepted mutant-frequencies can be specified and a simple rejection-sampling scheme is used to ensure it: if, after placing the mutation, the number of mutant leaves is not within the range, the arg is rejected and the simulation restarted. this insures an unbiased collection of args with a binary marker within a given frequency range. snp markers resemble trait markers in that they are binary polymorphisms, and use the same mutation model as the trait-markers. they differ from the trait-markers in how the mutant-frequency is ensured: if, after the mutation has been placed, the number of mutant leaves does not fall within the accepted range, the mutation is re-placed, but the arg is not rejected and re-simulated. this places a bias on the markers, but one that resembles the ascertainment bias seen in association studies, where snps are chosen to have frequencies in certain ranges. an unbiased sampling of mutations within the required frequency range can be obtained by constructing a new arg and repeating the simulation process, until the required frequencies are attained. microsatellite markers have a specified number of alleles, k, and a different mutation model than traits and snps. for microsatellite markers, each edge in the local tree at the marker is considered in turn and, with the likelihood of mutation being an exponential distribution that depends on the specified mutation rate and the length of the edge. if mutation occurs, a randomly chosen allele from to k- is placed on the child node; if no mutation occurs, the child node gets a copy of the allele at the parent node. in addition to the built-in marker types, scheme scripting allows specification of most conceivable mutation models, the stepwise mutation model for microsatellites is included as an example. trait markers can be marked as being involved in disease susceptibility under a specified, but arbitrary model of disease risk as a function of biallelic variants at a number of sites specified a priori. a multidimensional matrix specifies disease risk for any combination of variants. thus, from the simulated data and the disease model, case-control data of any size can be generated. diploid data with known or unknown phase can be easily generated by calling the relevant function from the scheme script as specified in the manual. splitting the sequences into cases and controls based solely on the allele at a trait marker or combination of alleles in a more complex disease determination is not always appropriate since it assumes full penetrance. however, in many complex diseases, penetrance is incomplete and dependent on environmental factors and general genetic background, and the same disease phenotypically can be caused by a different genetic pathway. hence, it is possible to control the likelihood of a given individual belonging to the case or control group by specifying the probabilities given the possible genotypes. population size changes, bottlenecks, merging of populations and migration between sub-populations can vary arbitrarily as specified through the definitions of epochs in the scheme script controlling the simulation. speed issues we have measured execution times for a series of simulations. simulating snp markers with a minor allele frequency of 10% for chromosomes with a recombination rate of took seconds on a ghz pentium gb ram machine. increasing the recombination rate to caused the execution time to increase to seconds. we also simulated a scenario that in likely to find applications in simulating interacting disease loci. in this scenario, sequences were simulated for a setup where two trait markers which frequencies range between 20% to 40% were located in a region of snp markers with a minor allele frequency of 10%,. this simulation took seconds. improvements to existing packages hudsons program ms provides many of coasims features for population growth, migration, recombination, gene conversion, arbitrary ascertainment schemes, recombination rate variation across the chromosome, stepwise mutation models, trait markers and cases and controls specified by the interaction between genes and genotype-specific penetrance probabilities. a difference is the ease of extracting the desired output. using ms, the user has to post-process the output using custom made scripts, whereas coasim provides the required functionalities. with ms, it is not possible to specify the position of markers, to employ a finite sites mutation model or to simulate linked microsatellites. some example applications of coasim we have used coasim for three applications that demonstrate some of its flexibility. estimation of recombination rate and effective population size in iceland from microsatellite data. in this study, microsatellite diploid, phase unknown, markers were simulated under different mutation models and for different rates of recombination. the expected decay of different measures of linkage disequilibrium with recombination rate could then be estimated and compared to the expected decay in a large microsatellite data set from iceland. this allowed us to estimate the effective population size of the icelandic population and to investigate whether the population bears any sign of recent population growth. case-control data sets were generated under a simple disease model but with various rates of heterogeneity and penetrance. the data with disease causing mutation removed was then directly piped into the generecon program that attempts to infer the disease marker position from all the simulated markers. this allowed us to investigate the effect of marker density, penetrance, heterogeneity, number of cases/controls etc. the effect of single recombination event. genealogies were simulated for a given recombination rate but only genealogies with exactly one recombination event were used for simulation of marker data sets. these data sets were then used as input to programs aimed at estimating the recombination rate, allowing us to estimate the variance in effect on data that a single recombination event can have and relate this to number of markers, population growth etc.  the coasim software package was designed for flexibility and with adaptations and extensions of the various scheme scripts provided and the user manual, a wide range of situations can be accommodated. it provides the user with a much wider range of demographical models, of marker types and disease models without much loss of user friendliness compared to competing software. availability and requirements project name: coasim project home page: source codes for guile and gui versions are supplied operating system: linux fedora 1– redhat and macosx programming language: c++ and scheme other requirements: guile scheme version. the gui requires qt version license: gnu authors' contributions tm, mhs, cnsp, jnm, ls, planned the project. tm, jnm and pjmm wrote the software, tm wrote the documentation. ls and tm tested the software. mhs, tm, ls and cnsp wrote the paper. all authors read and approved the final manuscript. supplementary material additional file 1 click here for file additional file 2 click here for file additional file 3 click here for file additional file 4 click here for file acknowledgements we thank thomas bataillon for useful comments to the manuscript. tm received support from isis katrinebjerg, mhs, ls and cnsp acknowledges support from the danish natural sciences research council.
coalescent simulations are playing a large role in interpreting large scale intra-specific sequence or polymorphism surveys and for planning and evaluating association studies. coalescent simulations of data sets under different models can be compared to the actual data to test the importance of different evolutionary factors and thus get insight into these.
 coalescent simulations are playing a large role in interpreting large scale intra-specific sequence or polymorphism surveys and for planning and evaluating association studies. coalescent simulations of data sets under different models can be compared to the actual data to test the importance of different evolutionary factors and thus get insight into these.  we have created the coasim application as a flexible environment for monte carlo simulation of various types of genetic data under equilibrium and non-equilibrium coalescent processes for a variety of applications. interaction with the tool is through the guile version of the scheme scripting language. scheme scripts for many standard and advanced applications are provided and these can easily be modified by the user for a much wider range of applications. a graphical user interface with less functionality and flexibility is also included. it is primarily intended as an exploratory and educational tool  coasim is a powerful tool because of its flexibility and ease of use. this is illustrated through very varied uses of the application, e.g. evaluation of association mapping methods, parametric bootstrapping, and design and choice of markers for specific questions 