PLINK conversion#
vcztools view-plink transcodes a VCZ store into a
PLINK 1 binary fileset (.bed/.bim/.fam). The format semantics
are described in the PLINK 1 file format page; this page walks
through the command itself.
The examples run against the example dataset data/sample.vcz.zip (see
Reading VCZ).
Basic conversion#
-o gives the output stem. The dataset contains multi-allelic sites, which
PLINK cannot represent, so -M 2 is required to skip them (mirroring plink2 --vcf X --max-alleles 2 --make-bed):
!vcztools view-plink data/sample.vcz.zip -M 2 -o sample
This writes three files:
!ls sample.bed sample.bim sample.fam
sample.bed sample.bim sample.fam
The .bed holds the packed genotypes (binary). The .fam lists one line per
sample and the .bim one line per variant:
!cat sample.fam
NA00001 NA00001 0 0 0 -9
NA00002 NA00002 0 0 0 -9
NA00003 NA00003 0 0 0 -9
!cat sample.bim
19 . 0 111 C A
19 . 0 112 G A
20 rs6054257 0 14370 A G
20 . 0 17330 A T
20 . 0 1230237 . T
20 . 0 1235237 . T
Subsetting by sample#
Pass -s (or -S FILE) to convert only a subset of samples. Here we keep two
of the three:
!vcztools view-plink data/sample.vcz.zip -M 2 -s NA00001,NA00003 -o subset
The .fam now lists just those samples:
!cat subset.fam
NA00001 NA00001 0 0 0 -9
NA00003 NA00003 0 0 0 -9
Only the selected samples are read from the store, so pulling a handful of samples out of a very wide cohort is cheap — the full cohort is never materialised.
Filtering over the sample subset#
-i/-e expression filters that reference sample-derived INFO fields
(AC, AN, AF, NS) are evaluated over the selected samples. With
a -s/-S subset, those values are recomputed for that subset rather
than read from the file’s stored (full-cohort) INFO. So
view-plink -s cohort.txt -i 'AC>0 & AC<AN' keeps the variants that vary
in your cohort (both alleles present, 0 < AC < AN), dropping sites whose
ALT alleles are carried only by excluded samples — even where the source
file’s stored INFO/AC is non-zero.
This is deliberately different from
vcztools view and
vcztools query, which follow bcftools and
evaluate -i/-e against the original
record’s stored INFO (so the same -i 'AC>0 & AC<AN' keeps a site on its
stored full-cohort count). The rationale: a PLINK fileset is the input to an
association analysis run on the exported cohort, so filters should reflect
that cohort, not the source dataset. It is also the cheaper path on large
datasets — only the selected samples are read.
Note this applies to expression filters. The allele-based filters
(-m/-M/-v/-V) remain record-level.
Sidecars#
The .bim and .fam sidecars are written by default; pass --no-bim or
--no-fam to suppress them.
See also#
The PLINK 1 file format page — format details.
Format conversion — the equivalent Python writer API.