Test TreeSequences with different mutation rates

Test TreeSequences with different mutation rates#

Load a tree sequence object and try to change the mutation rate.

import numpy as np
import msprime
import tskit

from tskitetude import get_data_dir

Now load the tree sequence file generated with msprime

tsm100M300I = tskit.load(get_data_dir() / "sheepTSsimMilano/tsm100M300I.trees")
tsm100M300I
Tree Sequence
Trees2 695 768
Sequence Length1e+08
Time Unitsgenerations
Sample Nodes4 810
Total Size536.2 MiB
MetadataNo Metadata
Table Rows Size Has Metadata
Edges 10 271 864 313.5 MiB
Individuals 2 405 65.8 KiB
Migrations 0 8 Bytes
Mutations 1 727 679 61.0 MiB
Nodes 1 590 538 42.5 MiB
Populations 18 880 Bytes
Provenances 2 6.9 KiB
Sites 1 712 620 40.8 MiB
Provenance Timestamp Software Name Version Command Full record
11 September, 2024 at 07:03:07 AM msprime 1.2.0 sim_mutations
Details
dict schema_version: 1.0.0
software:
dict name: msprime
version: 1.2.0

parameters:
dict command: sim_mutations
tree_sequence:
dict __constant__: __current_ts__

rate: 5.87e-09
model: None
start_time: None
end_time: None
discrete_genome: None
keep: None
random_seed: 13

environment:
dict
os:
dict system: Linux
node: node2i15.ecdf.ed.ac.uk
release: 3.10.0-1160.108.1.el7.x86_64
version: #1 SMP Wed Jan 24 08:37:16 CST
2024
machine: x86_64

python:
dict implementation: CPython
version: 3.8.13

libraries:
dict
kastore:
dict version: 2.1.1

tskit:
dict version: 0.5.2

gsl:
dict version: 2.6



11 September, 2024 at 07:03:00 AM msprime 1.2.0 sim_ancestry
Details
dict schema_version: 1.0.0
software:
dict name: msprime
version: 1.2.0

parameters:
dict command: sim_ancestry
samples:
dict MM: 5
II: 300
A: 300
B: 300
C: 300
D: 300
E: 300
F: 300
G: 300

demography:
dict
populations:
list
dict initial_size: 76000
growth_rate: 0
name: MManc
description:
extra_metadata:
dict

default_sampling_time: 5000
initially_active: False
id: 0

dict initial_size: 76000
growth_rate: 0
name: MM
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 1

dict initial_size: 170000
growth_rate: 0
name: IIanc
description:
extra_metadata:
dict

default_sampling_time: 3000
initially_active: False
id: 2

dict initial_size: 170000
growth_rate: 0
name: II
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 3

dict initial_size: 850
growth_rate: 0
name: Aanc
description:
extra_metadata:
dict

default_sampling_time: 1500
initially_active: False
id: 4

dict initial_size: 850
growth_rate: 0
name: A
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 5

dict initial_size: 850
growth_rate: 0
name: Banc
description:
extra_metadata:
dict

default_sampling_time: 750
initially_active: False
id: 6

dict initial_size: 850
growth_rate: 0
name: B
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 7

dict initial_size: 850
growth_rate: 0
name: Canc
description:
extra_metadata:
dict

default_sampling_time: 375
initially_active: False
id: 8

dict initial_size: 850
growth_rate: 0
name: C
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 9

dict initial_size: 850
growth_rate: 0
name: Danc
description:
extra_metadata:
dict

default_sampling_time: 188
initially_active: False
id: 10

dict initial_size: 850
growth_rate: 0
name: D
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 11

dict initial_size: 850
growth_rate: 0
name: Eanc
description:
extra_metadata:
dict

default_sampling_time: 94
initially_active: False
id: 12

dict initial_size: 850
growth_rate: 0
name: E
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 13

dict initial_size: 850
growth_rate: 0
name: Fanc
description:
extra_metadata:
dict

default_sampling_time: 47
initially_active: False
id: 14

dict initial_size: 850
growth_rate: 0
name: F
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 15

dict initial_size: 850
growth_rate: 0
name: Ganc
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 16

dict initial_size: 850
growth_rate: 0
name: G
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 17


events:
list
dict time: 47
derived:
list F
G

ancestral: Fanc

dict time: 94
derived:
list Fanc
E

ancestral: Eanc

dict time: 188
derived:
list Eanc
D

ancestral: Danc

dict time: 375
derived:
list Danc
C

ancestral: Canc

dict time: 750
derived:
list Canc
B

ancestral: Banc

dict time: 1500
derived:
list Banc
A

ancestral: Aanc

dict time: 3000
derived:
list Aanc
II

ancestral: IIanc

dict time: 5000
derived:
list IIanc
MM

ancestral: MManc


migration_matrix:
list
list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0


__class__: msprime.demography.Demography

sequence_length: 100000000
discrete_genome: None
recombination_rate: 1e-08
gene_conversion_rate: None
gene_conversion_tract_length: None
population_size: None
ploidy: None
model:
list
dict duration: 500
__class__: msprime.ancestry.DiscreteTimeW
rightFisher

dict duration: None
__class__: msprime.ancestry.StandardCoale
scent


initial_state: None
start_time: None
end_time: None
record_migrations: None
record_full_arg: None
num_labels: None
random_seed: 12
replicate_index: 0

environment:
dict
os:
dict system: Linux
node: node2i15.ecdf.ed.ac.uk
release: 3.10.0-1160.108.1.el7.x86_64
version: #1 SMP Wed Jan 24 08:37:16 CST
2024
machine: x86_64

python:
dict implementation: CPython
version: 3.8.13

libraries:
dict
kastore:
dict version: 2.1.1

tskit:
dict version: 0.5.2

gsl:
dict version: 2.6



To cite this software, please consult the citation manual: https://tskit.dev/citation/

cut first 1MB from the treesequence object: remember to trim the right sequence (with no data)

intervals = np.array([[1, 1_000_000]])
tsm1M300I = tsm100M300I.keep_intervals(intervals).rtrim()
tsm1M300I
Tree Sequence
Trees27 108
Sequence Length1 000 000
Time Unitsgenerations
Sample Nodes4 810
Total Size6.1 MiB
MetadataNo Metadata
Table Rows Size Has Metadata
Edges 112 392 3.4 MiB
Individuals 2 405 65.8 KiB
Migrations 0 8 Bytes
Mutations 17 099 617.9 KiB
Nodes 26 740 731.2 KiB
Populations 17 840 Bytes
Provenances 4 7.8 KiB
Sites 16 954 413.9 KiB
Provenance Timestamp Software Name Version Command Full record
19 December, 2025 at 01:36:25 PM tskit 1.0.0b3 rtrim
Details
dict schema_version: 1.0.0
software:
dict name: tskit
version: 1.0.0b3

parameters:
dict command: rtrim

environment:
dict
os:
dict system: Linux
node: node1
release: 5.15.0-58-generic
version: #64-Ubuntu SMP Thu Jan 5
11:43:13 UTC 2023
machine: x86_64

python:
dict implementation: CPython
version: 3.12.12

libraries:
dict
kastore:
dict version: 2.1.1



19 December, 2025 at 01:36:25 PM tskit 1.0.0b3 keep_intervals
Details
dict schema_version: 1.0.0
software:
dict name: tskit
version: 1.0.0b3

parameters:
dict command: keep_intervals
TODO: add parameters

environment:
dict
os:
dict system: Linux
node: node1
release: 5.15.0-58-generic
version: #64-Ubuntu SMP Thu Jan 5
11:43:13 UTC 2023
machine: x86_64

python:
dict implementation: CPython
version: 3.12.12

libraries:
dict
kastore:
dict version: 2.1.1



11 September, 2024 at 07:03:07 AM msprime 1.2.0 sim_mutations
Details
dict schema_version: 1.0.0
software:
dict name: msprime
version: 1.2.0

parameters:
dict command: sim_mutations
tree_sequence:
dict __constant__: __current_ts__

rate: 5.87e-09
model: None
start_time: None
end_time: None
discrete_genome: None
keep: None
random_seed: 13

environment:
dict
os:
dict system: Linux
node: node2i15.ecdf.ed.ac.uk
release: 3.10.0-1160.108.1.el7.x86_64
version: #1 SMP Wed Jan 24 08:37:16 CST
2024
machine: x86_64

python:
dict implementation: CPython
version: 3.8.13

libraries:
dict
kastore:
dict version: 2.1.1

tskit:
dict version: 0.5.2

gsl:
dict version: 2.6



11 September, 2024 at 07:03:00 AM msprime 1.2.0 sim_ancestry
Details
dict schema_version: 1.0.0
software:
dict name: msprime
version: 1.2.0

parameters:
dict command: sim_ancestry
samples:
dict MM: 5
II: 300
A: 300
B: 300
C: 300
D: 300
E: 300
F: 300
G: 300

demography:
dict
populations:
list
dict initial_size: 76000
growth_rate: 0
name: MManc
description:
extra_metadata:
dict

default_sampling_time: 5000
initially_active: False
id: 0

dict initial_size: 76000
growth_rate: 0
name: MM
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 1

dict initial_size: 170000
growth_rate: 0
name: IIanc
description:
extra_metadata:
dict

default_sampling_time: 3000
initially_active: False
id: 2

dict initial_size: 170000
growth_rate: 0
name: II
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 3

dict initial_size: 850
growth_rate: 0
name: Aanc
description:
extra_metadata:
dict

default_sampling_time: 1500
initially_active: False
id: 4

dict initial_size: 850
growth_rate: 0
name: A
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 5

dict initial_size: 850
growth_rate: 0
name: Banc
description:
extra_metadata:
dict

default_sampling_time: 750
initially_active: False
id: 6

dict initial_size: 850
growth_rate: 0
name: B
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 7

dict initial_size: 850
growth_rate: 0
name: Canc
description:
extra_metadata:
dict

default_sampling_time: 375
initially_active: False
id: 8

dict initial_size: 850
growth_rate: 0
name: C
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 9

dict initial_size: 850
growth_rate: 0
name: Danc
description:
extra_metadata:
dict

default_sampling_time: 188
initially_active: False
id: 10

dict initial_size: 850
growth_rate: 0
name: D
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 11

dict initial_size: 850
growth_rate: 0
name: Eanc
description:
extra_metadata:
dict

default_sampling_time: 94
initially_active: False
id: 12

dict initial_size: 850
growth_rate: 0
name: E
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 13

dict initial_size: 850
growth_rate: 0
name: Fanc
description:
extra_metadata:
dict

default_sampling_time: 47
initially_active: False
id: 14

dict initial_size: 850
growth_rate: 0
name: F
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 15

dict initial_size: 850
growth_rate: 0
name: Ganc
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 16

dict initial_size: 850
growth_rate: 0
name: G
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 17


events:
list
dict time: 47
derived:
list F
G

ancestral: Fanc

dict time: 94
derived:
list Fanc
E

ancestral: Eanc

dict time: 188
derived:
list Eanc
D

ancestral: Danc

dict time: 375
derived:
list Danc
C

ancestral: Canc

dict time: 750
derived:
list Canc
B

ancestral: Banc

dict time: 1500
derived:
list Banc
A

ancestral: Aanc

dict time: 3000
derived:
list Aanc
II

ancestral: IIanc

dict time: 5000
derived:
list IIanc
MM

ancestral: MManc


migration_matrix:
list
list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0


__class__: msprime.demography.Demography

sequence_length: 100000000
discrete_genome: None
recombination_rate: 1e-08
gene_conversion_rate: None
gene_conversion_tract_length: None
population_size: None
ploidy: None
model:
list
dict duration: 500
__class__: msprime.ancestry.DiscreteTimeW
rightFisher

dict duration: None
__class__: msprime.ancestry.StandardCoale
scent


initial_state: None
start_time: None
end_time: None
record_migrations: None
record_full_arg: None
num_labels: None
random_seed: 12
replicate_index: 0

environment:
dict
os:
dict system: Linux
node: node2i15.ecdf.ed.ac.uk
release: 3.10.0-1160.108.1.el7.x86_64
version: #1 SMP Wed Jan 24 08:37:16 CST
2024
machine: x86_64

python:
dict implementation: CPython
version: 3.8.13

libraries:
dict
kastore:
dict version: 2.1.1

tskit:
dict version: 0.5.2

gsl:
dict version: 2.6



To cite this software, please consult the citation manual: https://tskit.dev/citation/
n_mutations = sum(1 for m in tsm1M300I.mutations())
print(f"Number of mutations in tsm1M300I: {n_mutations}")
Number of mutations in tsm1M300I: 17099

Attempt to remove the mutations: collect the tables, remove mutations and generate a new tree sequence:

tables = tsm1M300I.dump_tables()
tables.mutations.clear()
tsm1M300I_no_mutations = tables.tree_sequence()
tsm1M300I_no_mutations
Tree Sequence
Trees27 108
Sequence Length1 000 000
Time Unitsgenerations
Sample Nodes4 810
Total Size5.5 MiB
MetadataNo Metadata
Table Rows Size Has Metadata
Edges 112 392 3.4 MiB
Individuals 2 405 65.8 KiB
Migrations 0 8 Bytes
Mutations 0 16 Bytes
Nodes 26 740 731.2 KiB
Populations 17 840 Bytes
Provenances 4 7.8 KiB
Sites 16 954 413.9 KiB
Provenance Timestamp Software Name Version Command Full record
19 December, 2025 at 01:36:25 PM tskit 1.0.0b3 rtrim
Details
dict schema_version: 1.0.0
software:
dict name: tskit
version: 1.0.0b3

parameters:
dict command: rtrim

environment:
dict
os:
dict system: Linux
node: node1
release: 5.15.0-58-generic
version: #64-Ubuntu SMP Thu Jan 5
11:43:13 UTC 2023
machine: x86_64

python:
dict implementation: CPython
version: 3.12.12

libraries:
dict
kastore:
dict version: 2.1.1



19 December, 2025 at 01:36:25 PM tskit 1.0.0b3 keep_intervals
Details
dict schema_version: 1.0.0
software:
dict name: tskit
version: 1.0.0b3

parameters:
dict command: keep_intervals
TODO: add parameters

environment:
dict
os:
dict system: Linux
node: node1
release: 5.15.0-58-generic
version: #64-Ubuntu SMP Thu Jan 5
11:43:13 UTC 2023
machine: x86_64

python:
dict implementation: CPython
version: 3.12.12

libraries:
dict
kastore:
dict version: 2.1.1



11 September, 2024 at 07:03:07 AM msprime 1.2.0 sim_mutations
Details
dict schema_version: 1.0.0
software:
dict name: msprime
version: 1.2.0

parameters:
dict command: sim_mutations
tree_sequence:
dict __constant__: __current_ts__

rate: 5.87e-09
model: None
start_time: None
end_time: None
discrete_genome: None
keep: None
random_seed: 13

environment:
dict
os:
dict system: Linux
node: node2i15.ecdf.ed.ac.uk
release: 3.10.0-1160.108.1.el7.x86_64
version: #1 SMP Wed Jan 24 08:37:16 CST
2024
machine: x86_64

python:
dict implementation: CPython
version: 3.8.13

libraries:
dict
kastore:
dict version: 2.1.1

tskit:
dict version: 0.5.2

gsl:
dict version: 2.6



11 September, 2024 at 07:03:00 AM msprime 1.2.0 sim_ancestry
Details
dict schema_version: 1.0.0
software:
dict name: msprime
version: 1.2.0

parameters:
dict command: sim_ancestry
samples:
dict MM: 5
II: 300
A: 300
B: 300
C: 300
D: 300
E: 300
F: 300
G: 300

demography:
dict
populations:
list
dict initial_size: 76000
growth_rate: 0
name: MManc
description:
extra_metadata:
dict

default_sampling_time: 5000
initially_active: False
id: 0

dict initial_size: 76000
growth_rate: 0
name: MM
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 1

dict initial_size: 170000
growth_rate: 0
name: IIanc
description:
extra_metadata:
dict

default_sampling_time: 3000
initially_active: False
id: 2

dict initial_size: 170000
growth_rate: 0
name: II
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 3

dict initial_size: 850
growth_rate: 0
name: Aanc
description:
extra_metadata:
dict

default_sampling_time: 1500
initially_active: False
id: 4

dict initial_size: 850
growth_rate: 0
name: A
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 5

dict initial_size: 850
growth_rate: 0
name: Banc
description:
extra_metadata:
dict

default_sampling_time: 750
initially_active: False
id: 6

dict initial_size: 850
growth_rate: 0
name: B
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 7

dict initial_size: 850
growth_rate: 0
name: Canc
description:
extra_metadata:
dict

default_sampling_time: 375
initially_active: False
id: 8

dict initial_size: 850
growth_rate: 0
name: C
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 9

dict initial_size: 850
growth_rate: 0
name: Danc
description:
extra_metadata:
dict

default_sampling_time: 188
initially_active: False
id: 10

dict initial_size: 850
growth_rate: 0
name: D
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 11

dict initial_size: 850
growth_rate: 0
name: Eanc
description:
extra_metadata:
dict

default_sampling_time: 94
initially_active: False
id: 12

dict initial_size: 850
growth_rate: 0
name: E
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 13

dict initial_size: 850
growth_rate: 0
name: Fanc
description:
extra_metadata:
dict

default_sampling_time: 47
initially_active: False
id: 14

dict initial_size: 850
growth_rate: 0
name: F
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 15

dict initial_size: 850
growth_rate: 0
name: Ganc
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 16

dict initial_size: 850
growth_rate: 0
name: G
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 17


events:
list
dict time: 47
derived:
list F
G

ancestral: Fanc

dict time: 94
derived:
list Fanc
E

ancestral: Eanc

dict time: 188
derived:
list Eanc
D

ancestral: Danc

dict time: 375
derived:
list Danc
C

ancestral: Canc

dict time: 750
derived:
list Canc
B

ancestral: Banc

dict time: 1500
derived:
list Banc
A

ancestral: Aanc

dict time: 3000
derived:
list Aanc
II

ancestral: IIanc

dict time: 5000
derived:
list IIanc
MM

ancestral: MManc


migration_matrix:
list
list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0


__class__: msprime.demography.Demography

sequence_length: 100000000
discrete_genome: None
recombination_rate: 1e-08
gene_conversion_rate: None
gene_conversion_tract_length: None
population_size: None
ploidy: None
model:
list
dict duration: 500
__class__: msprime.ancestry.DiscreteTimeW
rightFisher

dict duration: None
__class__: msprime.ancestry.StandardCoale
scent


initial_state: None
start_time: None
end_time: None
record_migrations: None
record_full_arg: None
num_labels: None
random_seed: 12
replicate_index: 0

environment:
dict
os:
dict system: Linux
node: node2i15.ecdf.ed.ac.uk
release: 3.10.0-1160.108.1.el7.x86_64
version: #1 SMP Wed Jan 24 08:37:16 CST
2024
machine: x86_64

python:
dict implementation: CPython
version: 3.8.13

libraries:
dict
kastore:
dict version: 2.1.1

tskit:
dict version: 0.5.2

gsl:
dict version: 2.6



To cite this software, please consult the citation manual: https://tskit.dev/citation/

Now generate TS objects with mutations:

mu = 5.87e-9
mutations = [0.1, 0.5, 2, 10]
mutation_rates = [mutation * mu for mutation in mutations]

def simulate_mutations(ts, mutation_rate):
    return(msprime.sim_mutations(ts, rate=mutation_rate, random_seed=42))

simulated_trees = [simulate_mutations(tsm1M300I_no_mutations, mutation_rate) for mutation_rate in mutation_rates]

inspect a simulated tree:

simulated_trees[0]
Tree Sequence
Trees27 108
Sequence Length1 000 000
Time Unitsgenerations
Sample Nodes4 810
Total Size5.6 MiB
MetadataNo Metadata
Table Rows Size Has Metadata
Edges 112 392 3.4 MiB
Individuals 2 405 65.8 KiB
Migrations 0 8 Bytes
Mutations 1 737 62.8 KiB
Nodes 26 740 731.2 KiB
Populations 17 840 Bytes
Provenances 5 8.5 KiB
Sites 18 659 455.6 KiB
Provenance Timestamp Software Name Version Command Full record
19 December, 2025 at 01:36:25 PM msprime 1.3.4 sim_mutations
Details
dict schema_version: 1.0.0
software:
dict name: msprime
version: 1.3.4

parameters:
dict command: sim_mutations
tree_sequence:
dict __constant__: __current_ts__

rate: 5.87e-10
model: None
start_time: None
end_time: None
discrete_genome: None
keep: None
random_seed: 42

environment:
dict
os:
dict system: Linux
node: node1
release: 5.15.0-58-generic
version: #64-Ubuntu SMP Thu Jan 5
11:43:13 UTC 2023
machine: x86_64

python:
dict implementation: CPython
version: 3.12.12

libraries:
dict
kastore:
dict version: 2.1.1

tskit:
dict version: 1.0.0b3

gsl:
dict version: 2.6



19 December, 2025 at 01:36:25 PM tskit 1.0.0b3 rtrim
Details
dict schema_version: 1.0.0
software:
dict name: tskit
version: 1.0.0b3

parameters:
dict command: rtrim

environment:
dict
os:
dict system: Linux
node: node1
release: 5.15.0-58-generic
version: #64-Ubuntu SMP Thu Jan 5
11:43:13 UTC 2023
machine: x86_64

python:
dict implementation: CPython
version: 3.12.12

libraries:
dict
kastore:
dict version: 2.1.1



19 December, 2025 at 01:36:25 PM tskit 1.0.0b3 keep_intervals
Details
dict schema_version: 1.0.0
software:
dict name: tskit
version: 1.0.0b3

parameters:
dict command: keep_intervals
TODO: add parameters

environment:
dict
os:
dict system: Linux
node: node1
release: 5.15.0-58-generic
version: #64-Ubuntu SMP Thu Jan 5
11:43:13 UTC 2023
machine: x86_64

python:
dict implementation: CPython
version: 3.12.12

libraries:
dict
kastore:
dict version: 2.1.1



11 September, 2024 at 07:03:07 AM msprime 1.2.0 sim_mutations
Details
dict schema_version: 1.0.0
software:
dict name: msprime
version: 1.2.0

parameters:
dict command: sim_mutations
tree_sequence:
dict __constant__: __current_ts__

rate: 5.87e-09
model: None
start_time: None
end_time: None
discrete_genome: None
keep: None
random_seed: 13

environment:
dict
os:
dict system: Linux
node: node2i15.ecdf.ed.ac.uk
release: 3.10.0-1160.108.1.el7.x86_64
version: #1 SMP Wed Jan 24 08:37:16 CST
2024
machine: x86_64

python:
dict implementation: CPython
version: 3.8.13

libraries:
dict
kastore:
dict version: 2.1.1

tskit:
dict version: 0.5.2

gsl:
dict version: 2.6



11 September, 2024 at 07:03:00 AM msprime 1.2.0 sim_ancestry
Details
dict schema_version: 1.0.0
software:
dict name: msprime
version: 1.2.0

parameters:
dict command: sim_ancestry
samples:
dict MM: 5
II: 300
A: 300
B: 300
C: 300
D: 300
E: 300
F: 300
G: 300

demography:
dict
populations:
list
dict initial_size: 76000
growth_rate: 0
name: MManc
description:
extra_metadata:
dict

default_sampling_time: 5000
initially_active: False
id: 0

dict initial_size: 76000
growth_rate: 0
name: MM
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 1

dict initial_size: 170000
growth_rate: 0
name: IIanc
description:
extra_metadata:
dict

default_sampling_time: 3000
initially_active: False
id: 2

dict initial_size: 170000
growth_rate: 0
name: II
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 3

dict initial_size: 850
growth_rate: 0
name: Aanc
description:
extra_metadata:
dict

default_sampling_time: 1500
initially_active: False
id: 4

dict initial_size: 850
growth_rate: 0
name: A
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 5

dict initial_size: 850
growth_rate: 0
name: Banc
description:
extra_metadata:
dict

default_sampling_time: 750
initially_active: False
id: 6

dict initial_size: 850
growth_rate: 0
name: B
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 7

dict initial_size: 850
growth_rate: 0
name: Canc
description:
extra_metadata:
dict

default_sampling_time: 375
initially_active: False
id: 8

dict initial_size: 850
growth_rate: 0
name: C
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 9

dict initial_size: 850
growth_rate: 0
name: Danc
description:
extra_metadata:
dict

default_sampling_time: 188
initially_active: False
id: 10

dict initial_size: 850
growth_rate: 0
name: D
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 11

dict initial_size: 850
growth_rate: 0
name: Eanc
description:
extra_metadata:
dict

default_sampling_time: 94
initially_active: False
id: 12

dict initial_size: 850
growth_rate: 0
name: E
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 13

dict initial_size: 850
growth_rate: 0
name: Fanc
description:
extra_metadata:
dict

default_sampling_time: 47
initially_active: False
id: 14

dict initial_size: 850
growth_rate: 0
name: F
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 15

dict initial_size: 850
growth_rate: 0
name: Ganc
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 16

dict initial_size: 850
growth_rate: 0
name: G
description:
extra_metadata:
dict

default_sampling_time: None
initially_active: None
id: 17


events:
list
dict time: 47
derived:
list F
G

ancestral: Fanc

dict time: 94
derived:
list Fanc
E

ancestral: Eanc

dict time: 188
derived:
list Eanc
D

ancestral: Danc

dict time: 375
derived:
list Danc
C

ancestral: Canc

dict time: 750
derived:
list Canc
B

ancestral: Banc

dict time: 1500
derived:
list Banc
A

ancestral: Aanc

dict time: 3000
derived:
list Aanc
II

ancestral: IIanc

dict time: 5000
derived:
list IIanc
MM

ancestral: MManc


migration_matrix:
list
list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

list 0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0


__class__: msprime.demography.Demography

sequence_length: 100000000
discrete_genome: None
recombination_rate: 1e-08
gene_conversion_rate: None
gene_conversion_tract_length: None
population_size: None
ploidy: None
model:
list
dict duration: 500
__class__: msprime.ancestry.DiscreteTimeW
rightFisher

dict duration: None
__class__: msprime.ancestry.StandardCoale
scent


initial_state: None
start_time: None
end_time: None
record_migrations: None
record_full_arg: None
num_labels: None
random_seed: 12
replicate_index: 0

environment:
dict
os:
dict system: Linux
node: node2i15.ecdf.ed.ac.uk
release: 3.10.0-1160.108.1.el7.x86_64
version: #1 SMP Wed Jan 24 08:37:16 CST
2024
machine: x86_64

python:
dict implementation: CPython
version: 3.8.13

libraries:
dict
kastore:
dict version: 2.1.1

tskit:
dict version: 0.5.2

gsl:
dict version: 2.6



To cite this software, please consult the citation manual: https://tskit.dev/citation/
for idx, ts in enumerate(simulated_trees):
    outfile = get_data_dir() / "sheepTSsimMilano" / f"tsm1M300I_{mutations[idx]}mu.trees"
    ts.dump(outfile)
    print(f"Dumped {outfile}")
Dumped /home/core/TSKITetude/data/sheepTSsimMilano/tsm1M300I_0.1mu.trees
Dumped /home/core/TSKITetude/data/sheepTSsimMilano/tsm1M300I_0.5mu.trees
Dumped /home/core/TSKITetude/data/sheepTSsimMilano/tsm1M300I_2mu.trees
Dumped /home/core/TSKITetude/data/sheepTSsimMilano/tsm1M300I_10mu.trees