Skip to content

sampling from subpopulations #2383

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

You must be logged in to vote

If you want to pull out the subset tree sequences for the different populations you can do this:

for pop_id in [1, 2, 3]:
    ts_subset = ts.simplify(ts.samples(population=pop_id), filter_sites=False)
    G = ts_subset.genotype_matrix()
    # G should be the per-population genotype matrix now

The filter_sites argument is required so that we don't remove any sites from the genotype matrices that don't have any mutations in the subset trees. See the documentation for simplify for details.

I haven't tested this, so beware!

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

Comment options

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

Answer selected by mshpak76
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