pybgen’s API¶
Main PyBGEN class¶
-
class
pybgen.
PyBGEN
(fn, mode='r', prob_t=0.9, _skip_index=False, probs_only=False)[source]¶ Reads and store a set of BGEN files.
- Parameters
Reads or write BGEN files.
from pybgen import PyBGEN # Reading a BGEN file with PyBGEN("bgen_file_name") as bgen: pass
-
get_specific_variant
(chrom, pos, ref, alt)[source]¶ Get specific variant with allele lookup
- Parameters
- Returns
A list containing all the value for a given variant. The list has more than one item if there are duplicated variants.
- Return type
-
iter_variants
()[source]¶ Iterates over variants from the beginning of the BGEN file.
- Returns
A variant and the dosage.
- Return type
-
iter_variants_by_names
(names)[source]¶ Iterates over variants using a list of names.
- Parameters
names (list) – A list of names to extract specific variants.
-
property
nb_samples
¶ Returns the number of samples.
- Returns
The number of samples in the dataset.
- Return type
-
property
nb_variants
¶ Returns the number of markers.
- Returns
The number of markers in the dataset.
- Return type
-
next
()[source]¶ Returns the next variant.
- Returns
The variant’s information and its genotypes (dosage) as
numpy.ndarray
.- Return type
A module to read BGEN files.
Parallel PyBGEN class¶
We provide a wrapper class called ParallelPyBGEN
which implements
two functions to iterate over variants in parallel. This is useful for huge
datasets such as the UK Biobank imputation files.