Call

class hail.genetics.Call[source]

An object that represents an individual’s call at a genomic locus.

Parameters:
  • alleles (list of int) – List of alleles that compose the call.

  • phased (bool) – If True, the alleles are phased and the order is specified by alleles.

Note

This object refers to the Python value returned by taking or collecting Hail expressions, e.g. mt.GT.take(5`). This is rare; it is much more common to manipulate the CallExpression object, which is constructed using the following functions:

Attributes

alleles

Get the alleles of this call.

phased

True if the call is phased.

ploidy

The number of alleles for this call.

Methods

is_diploid

True if the ploidy == 2.

is_haploid

True if the ploidy == 1.

is_het

True if the call contains two different alleles.

is_het_non_ref

True if the call contains two different alternate alleles.

is_het_ref

True if the call contains one reference and one alternate allele.

is_hom_ref

True if the call has no alternate alleles.

is_hom_var

True if the call contains identical alternate alleles.

is_non_ref

True if the call contains any non-reference alleles.

n_alt_alleles

Returns the count of non-reference alleles.

one_hot_alleles

Returns a list containing the one-hot encoded representation of the called alleles.

unphased_diploid_gt_index

Return the genotype index for unphased, diploid calls.

property alleles

Get the alleles of this call.

Returns:

list of int

is_diploid()[source]

True if the ploidy == 2.

Return type:

bool

is_haploid()[source]

True if the ploidy == 1.

Return type:

bool

is_het()[source]

True if the call contains two different alleles.

Return type:

bool

is_het_non_ref()[source]

True if the call contains two different alternate alleles.

Return type:

bool

is_het_ref()[source]

True if the call contains one reference and one alternate allele.

Return type:

bool

is_hom_ref()[source]

True if the call has no alternate alleles.

Return type:

bool

is_hom_var()[source]

True if the call contains identical alternate alleles.

Return type:

bool

is_non_ref()[source]

True if the call contains any non-reference alleles.

Return type:

bool

n_alt_alleles()[source]

Returns the count of non-reference alleles.

Return type:

int

one_hot_alleles(n_alleles)[source]

Returns a list containing the one-hot encoded representation of the called alleles.

Examples

>>> n_alleles = 2
>>> hom_ref = hl.Call([0, 0])
>>> het = hl.Call([0, 1])
>>> hom_var = hl.Call([1, 1])
>>> het.one_hot_alleles(n_alleles)
[1, 1]
>>> hom_var.one_hot_alleles(n_alleles)
[0, 2]

Notes

This one-hot representation is the positional sum of the one-hot encoding for each called allele. For a biallelic variant, the one-hot encoding for a reference allele is [1, 0] and the one-hot encoding for an alternate allele is [0, 1].

Parameters:

n_alleles (int) – Number of total alleles, including the reference.

Returns:

list of int

property phased

True if the call is phased.

Returns:

bool

property ploidy

The number of alleles for this call.

Returns:

int

unphased_diploid_gt_index()[source]

Return the genotype index for unphased, diploid calls.

Returns:

int