Skip to content

Simplify a tree sequence down so as to collapse clonal lineages #1220

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

You must be logged in to vote

An updated answer based on my previous comments. It's more complicated because we need to follow up the trail from existing non-clonal edges and mark all their ancestors as non-clonal too.

import numpy as np
def clonal_mrcas(ts, most_recent=True):
    """
    Identify the nodes in a tree sequence which define clonal subtrees (i.e. in which the
    samples descending from that node are identical and show identical relationships
    to each other over the entire tree sequence). This includes, at its limit, nodes
    with only a single descendant sample.
    
    :param bool most_recent: If True, and the clonal node is a unary node, return IDs of the
        most recent node that defines the…

Replies: 7 comments 20 replies

Comment options

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

hyanwong Feb 24, 2021
Maintainer Author

@jeromekelleher
Comment options

@jeromekelleher
Comment options

@hyanwong
Comment options

hyanwong Feb 24, 2021
Maintainer Author

Comment options

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

hyanwong Feb 24, 2021
Maintainer Author

@hyanwong
Comment options

hyanwong Feb 24, 2021
Maintainer Author

@petrelharp
Comment options

Comment options

hyanwong
Feb 24, 2021
Maintainer Author

You must be logged in to vote
2 replies
@petrelharp
Comment options

@hyanwong
Comment options

hyanwong Feb 24, 2021
Maintainer Author

Comment options

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

hyanwong Feb 24, 2021
Maintainer Author

@hyanwong
Comment options

hyanwong Feb 24, 2021
Maintainer Author

@jeromekelleher
Comment options

Comment options

hyanwong
Feb 26, 2021
Maintainer Author

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

hyanwong Feb 26, 2021
Maintainer Author

@jeromekelleher
Comment options

@jeromekelleher
Comment options

@jeromekelleher
Comment options

@a-ignatieva
Comment options

Comment options

hyanwong
Feb 4, 2023
Maintainer Author

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

hyanwong Feb 4, 2023
Maintainer Author

@hyanwong
Comment options

hyanwong Feb 4, 2023
Maintainer Author

Comment options

hyanwong
Feb 4, 2023
Maintainer Author

You must be logged in to vote
1 reply
@hyanwong
Comment options

hyanwong Feb 4, 2023
Maintainer Author

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
4 participants