hail.vds.local_to_global

hail.vds.local_to_global(array, local_alleles, n_alleles, fill_value, number)[source]

Reindex a locally-indexed array to globally-indexed.

Examples

>>> local_alleles = hl.array([0, 2])
>>> local_ad = hl.array([9, 10])
>>> local_pl = hl.array([94, 0, 123])
>>> hl.eval(local_to_global(local_ad, local_alleles, n_alleles=3, fill_value=0, number='R'))
[9, 0, 10]
>>> hl.eval(local_to_global(local_pl, local_alleles, n_alleles=3, fill_value=999, number='G'))
[94, 999, 999, 0, 999, 123]

Notes

The number parameter matches the VCF specification number definitions:

  • A indicates one value per allele, excluding the reference.

  • R indicates one value per allele, including the reference.

  • G indicates one value per unique diploid genotype.

Warning

Using this function can lead to an enormous explosion in data size, without increasing information capacity. Its appropriate use is to conform to antiquated and badly-scaling representations (e.g. pVCF), but even so, caution should be exercised. Reindexing local PLs (or any G-numbered field) at a site with 1000 alleles will produce an array with more than 5,000 values per sample – with 100,000 samples, nearly 50GB per variant!

See also

lgt_to_gt()

Parameters
  • array (ArrayExpression) – Array to reindex.

  • local_alleles (ArrayExpression) – Local alleles array.

  • n_alleles (Int32Expression) – Total number of alleles to reindex to.

  • fill_value – Value to fill in at global indices with no data.

  • number (str) – One of ‘A’, ‘R’, ‘G’.

Returns

ArrayExpression