|
| 1 | +# vcf2zarr |
| 2 | + |
| 3 | + |
| 4 | +Convert a VCF to zarr format: |
| 5 | + |
| 6 | +``` |
| 7 | +$ vcf2zarr convert <VCF1> <VCF2> <zarr> |
| 8 | +``` |
| 9 | + |
| 10 | +Converts the VCF to zarr format. |
| 11 | + |
| 12 | +**Do not use this for anything but the smallest files** |
| 13 | + |
| 14 | +The recommended approach is to use a multi-stage conversion |
| 15 | + |
| 16 | +First, convert the VCF into the intermediate format: |
| 17 | + |
| 18 | +``` |
| 19 | +vcf2zarr explode tests/data/vcf/sample.vcf.gz tmp/sample.exploded |
| 20 | +``` |
| 21 | + |
| 22 | +Then, (optionally) inspect this representation to get a feel for your dataset |
| 23 | +``` |
| 24 | +vcf2zarr inspect tmp/sample.exploded |
| 25 | +``` |
| 26 | + |
| 27 | +Then, (optionally) generate a conversion schema to describe the corresponding |
| 28 | +Zarr arrays: |
| 29 | + |
| 30 | +``` |
| 31 | +vcf2zarr mkschema tmp/sample.exploded > sample.schema.json |
| 32 | +``` |
| 33 | + |
| 34 | +View and edit the schema, deleting any columns you don't want, or tweaking |
| 35 | +dtypes and compression settings to your taste. |
| 36 | + |
| 37 | +Finally, encode to Zarr: |
| 38 | +``` |
| 39 | +vcf2zarr encode tmp/sample.exploded tmp/sample.zarr -s sample.schema.json |
| 40 | +``` |
| 41 | + |
| 42 | +Use the ``-p, --worker-processes`` argument to control the number of workers used |
| 43 | +in the ``explode`` and ``encode`` phases. |
| 44 | + |
| 45 | +## To be merged with above |
| 46 | + |
| 47 | +The simplest usage is: |
| 48 | + |
| 49 | +``` |
| 50 | +$ vcf2zarr convert [VCF_FILE] [ZARR_PATH] |
| 51 | +``` |
| 52 | + |
| 53 | + |
| 54 | +This will convert the indexed VCF (or BCF) into the vcfzarr format in a single |
| 55 | +step. As this writes the intermediate columnar format to a temporary directory, |
| 56 | +we only recommend this approach for small files (< 1GB, say). |
| 57 | + |
| 58 | +The recommended approach is to run the conversion in two passes, and |
| 59 | +to keep the intermediate columnar format ("exploded") around to facilitate |
| 60 | +experimentation with chunk sizes and compression settings: |
| 61 | + |
| 62 | +``` |
| 63 | +$ vcf2zarr explode [VCF_FILE_1] ... [VCF_FILE_N] [ICF_PATH] |
| 64 | +$ vcf2zarr encode [ICF_PATH] [ZARR_PATH] |
| 65 | +``` |
| 66 | + |
| 67 | +The inspect command provides a way to view contents of an exploded ICF |
| 68 | +or Zarr: |
| 69 | + |
| 70 | +``` |
| 71 | +$ vcf2zarr inspect [PATH] |
| 72 | +``` |
| 73 | + |
| 74 | +This is useful when tweaking chunk sizes and compression settings to suit |
| 75 | +your dataset, using the mkschema command and --schema option to encode: |
| 76 | + |
| 77 | +``` |
| 78 | +$ vcf2zarr mkschema [ICF_PATH] > schema.json |
| 79 | +$ vcf2zarr encode [ICF_PATH] [ZARR_PATH] --schema schema.json |
| 80 | +``` |
| 81 | + |
| 82 | +By editing the schema.json file you can drop columns that are not of interest |
| 83 | +and edit column specific compression settings. The --max-variant-chunks option |
| 84 | +to encode allows you to try out these options on small subsets, hopefully |
| 85 | +arriving at settings with the desired balance of compression and query |
| 86 | +performance. |
| 87 | + |
0 commit comments