8000 GitHub - arzwa/SlimWrap
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

arzwa/SlimWrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EditURL = "doc/README.jl"

Translation of currocam's slim_wrap.py to Julia.

Workflow example with SlimWrap + PyCall

Example

using SlimWrap
using PyCall
tskit = pyimport("tskit")
pyslim = pyimport("pyslim")
msprime = pyimport("msprime")
PyObject <module 'msprime' from '/home/arzwa/.local/lib/python3.10/site-packages/msprime/__init__.py'>

Define and run the SLiM simulation

M = SLiMModel(templates.wf)
params = Dict(
    "POPSIZE"=>100,
    "CHRSIZE"=>1_000_000,
    "RECRATE"=>1e-8,
    "NGEN"   =>1000,
    "OUTFILE"=>tempname())
run(M, constants=params)
Process(`slim -s 6563984953498643476 -l 2 -d "SLIM_WRAP_PARAMS = Dictionary(readFile('/tmp/jl_cJCHGD2DQv'))" -p -d "POPSIZE=SLIM_WRAP_PARAMS.getValue('POPSIZE');" -d "NGEN=SLIM_WRAP_PARAMS.getValue('NGEN');" -d "CHRSIZE=SLIM_WRAP_PARAMS.getValue('CHRSIZE');" -d "RECRATE=SLIM_WRAP_PARAMS.getValue('RECRATE');" -d "OUTFILE=SLIM_WRAP_PARAMS.getValue('OUTFILE');" /home/arzwa/dev/SlimWrap/src/templates/wf.slim`, ProcessExited(0))

Load and simplify the tree sequence

ts = tskit.load(params["OUTFILE"])
alive = pyslim.individuals_alive_at(ts, 0) .+ 1
sts = ts.simplify(
    ts.individuals_nodes[alive],
    keep_input_roots=true)
demography = msprime.Demography.from_tree_sequence(sts)
rts = pyslim.recapitate(
    sts, random_seed=11,
    demography=demography,
    ploidy=2,
    recombination_rate=params["RECRATE"]
);

Simulate neutral mutations

mts = msprime.sim_mutations(
    ts, random_seed=11,
    rate=1e-8,
    keep=false
);

Get coalescence times

tmrca = mts.diversity(mts.samples(population=1),
    mode="branch", windows=0:100_000:params["CHRSIZE"]) / 2
10-element Vector{Float64}:
 202.50725526130654
 204.2841005829146
 190.5178457778894
 167.17291633165817
 175.7796540577888
 220.64733668341697
 220.88865190251246
 221.7803015075376
 221.3815927698492
 223.83476951557773

This page was generated using Literate.jl.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0