Skip to main content

⌨️ Command-line scripts

With the krsim environment active, run the four main commands of the quick start example from a terminal, plus the optional helper coal-mut, which the quick start uses to show coalescence times. Results go to krsim_tutorial_output/ in the current folder (krsim creates it):

OUT=krsim_tutorial_output

krsim simulate   --Nh 3 --T 10 --K 2 --chi 0.18 --C 1 --random_seed 123 --output_dir $OUT
krsim mutate     --ts $OUT/ts_123.trees --random_seed 123 --output_dir $OUT
krsim vcf-strain --ts $OUT/ts_mut_123.trees --random_seed 123 --output_dir $OUT

# optional helper: coalescence and mutation time tables (small runs only)
krsim coal-mut   --ts $OUT/ts_mut_123.trees --random_seed 123 --output_dir $OUT

For the host VCF (stage 4), vcf-host-depth gives each host realistic read depth. The simplest way uses krsim’s depth model for sWGA samples, which needs no data:

krsim vcf-host-depth --strain_vcf $OUT/output_123_strain.vcf --ind_node_map_csv $OUT/sim_ind_node_map_123.csv \
                     --depth_model sWGA --random_seed 123 --output_dir $OUT

Use --depth_model gDNA for gDNA samples. To use the depth of real samples instead, give a zip of depth files, one per host or more; download a small one with three Pf8 samples from this website:

curl -O https://mrc-ide.github.io/KR_simulator/data/tutorial_depth.zip

krsim vcf-host-depth --strain_vcf $OUT/output_123_strain.vcf --ind_node_map_csv $OUT/sim_ind_node_map_123.csv \
                     --depth_zip tutorial_depth.zip --random_seed 123 --output_dir $OUT

Both write the same files, so run them in different --output_dir folders if you want to keep both.

Each command prints the files it wrote. Every file name ends in the random seed (123 here), and every command adds a record of what it ran to KR_sim_123.log.

Command Reads Writes
simulate — ts_123.trees, sim_ind_node_map_123.csv
mutate ts_123.trees ts_mut_123.trees
vcf-strain ts_mut_123.trees output_123_strain.vcf
vcf-host-depth output_123_strain.vcf, sim_ind_node_map_123.csv (and tutorial_depth.zip with --depth_zip) output_123_host_depth.vcf, host_depth_profiles_123.csv, host_depth_proportions_123.csv
coal-mut (helper) ts_mut_123.trees coal_T_123.csv, mut_T_123.csv

See the command-line reference for every option.