Skip to content

Clarify write_vcf docs, and allow empty individuals list to be passed #3463

@hyanwong

Description

@hyanwong

It appears that if you try:

import msprime
ts = msprime.sim_mutations(msprime.sim_ancestry(20, ploidy=1, sequence_length=1000, random_seed=42), rate=1e-3, random_seed=42)
print(ts.num_sites)
print(ts.as_vcf(individuals=[0]))

All 5 sites in the tree sequence are exported, as well as the REF and ALT alleles over all the samples, even though only one haploid genome is actually present in the VCF. This seems the right behaviour to me: if the user wants to exclude individuals and their variable sites, they should simplify first. But I think this behaviour should be documented (possibly in https://tskit.dev/tskit/docs/stable/export.html?)

Also, it is relatively common to want to export a VCF of just the positions, but no data, so I think we should probably allow ts.write_vcf(file, individuals=[])?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions