Skip to content

Removing samples not involved in recombination #2703

Answered by jeromekelleher
hyanwong asked this question in Q&A
Discussion options

You must be logged in to vote

You could do something like this:

tree = ts.first()
untouched_by_recomb = []
for sample in ts.samples():
     u = sample
     affected_by_recomb = False
     while u != -1:
         e = ts.edge(tree.edge(u))
         if e.left != 0 or e.right != ts.sequence_length:
              affected_by_recomb = True
              break
         u = tree.parent(u)
    if not affected_by_recomb:
         untouched_by_recomb.append(sample)

The idea is that a sample is not involved in recombination if it has a complete tree path all the way back to root, which seems like a reasonable definition, but perhaps its too strong?

I'm sure you could make this implementation more efficient, but this should be a g…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hyanwong
Comment options

hyanwong Jan 29, 2023
Maintainer Author

@jeromekelleher
Comment options

@hyanwong
Comment options

hyanwong Jan 30, 2023
Maintainer Author

@jeromekelleher
Comment options

Answer selected by hyanwong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants