Accessing an object's tag in a TreeSequence

5 views
Skip to first unread message

Alfredo Marin

unread,
Dec 17, 2025, 12:13:20 PM (2 days ago) Dec 17
to slim-discuss
Hi all!

In my simulation, I set the tagL0 property of some individuals to True. Is there a way to access this information in the output TreeSequence using tskit? For example, can I  simplify my TreeSequence such that I keep only the individuals with tagL0=T?

Thanks!

Peter Ralph

unread,
Dec 17, 2025, 12:38:51 PM (2 days ago) Dec 17
to slim-discuss, Alfredo Marin
To do this, you need to explicitly store it, best is probably in top-level metadata. So, for instance:

treeSeqOutput("out.trees", metadata=Dictionary("tags", p1.individuals.tagL0, "ids", p1.individuals.pedigreeID))

Then, after loading the tree sequence, you'd extract this like:

tags = ts.metadata['SLiM']['user_metadata']['tags']
ids = ts.metadata['SLiM']['user_metadata']['ids']

... and then you could use this to figure out which nodes to simplify to. Here I'm outputting IDs, so that you can make sure you know which tags match which individuals in the tree sequence; and then remember that simplify wants nodes, not individuals.

--peter


From: 'Alfredo Marin' via slim-discuss <slim-d...@googlegroups.com>
Sent: Wednesday, December 17, 2025 9:13 AM
To: slim-discuss <slim-d...@googlegroups.com>
Subject: Accessing an object's tag in a TreeSequence
 
Hi all! In my simulation, I set the tagL0 property of some individuals to True. Is there a way to access this information in the output TreeSequence using tskit? For example, can I  simplify my TreeSequence such that I keep only the individuals
ZjQcmQRYFpfptBannerStart
This message originated outside the UO email ecosystem.
Use caution with links and attachments. Learn more about this email warning tag.
 
ZjQcmQRYFpfptBannerEnd
Hi all!

In my simulation, I set the tagL0 property of some individuals to True. Is there a way to access this information in the output TreeSequence using tskit? For example, can I  simplify my TreeSequence such that I keep only the individuals with tagL0=T?

Thanks!

--
SLiM forward genetic simulation: http://messerlab.org/slim/
Before posting, please read http://benhaller.com/slim/bugs_and_questions.html
---
You received this message because you are subscribed to the Google Groups "slim-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to slim-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/slim-discuss/07760b0c-a779-4eb9-8d76-5bb1506d9815n%40googlegroups.com.

Alfredo Marin

unread,
Dec 17, 2025, 2:36:33 PM (2 days ago) Dec 17
to slim-discuss
Oh okay, so the idea is to make the information I want a metadata of the TreeSequence itself instead of the individuals in the TreeSequence. Also, just for completeness, to use p1.individuals.pedigreeID, I need to add initializeSLiMOptions(keepPedigrees=T) to my script, right?
Reply all
Reply to author
Forward
0 new messages