typing
Support for type hints.
|
Genotype. |
|
Partition of variants. |
|
Variants. |
- class cbgen.typing.Genotype(probability, phased, ploidy, missing)[source]
Genotype.
>>> import cbgen >>> >>> bgen = cbgen.bgen_file(cbgen.example.get("haplotypes.bgen")) >>> mf = cbgen.bgen_metafile(cbgen.example.get("haplotypes.bgen.metafile")) >>> part = mf.read_partition(0) >>> gt = bgen.read_genotype(part.variants.offset[0]) >>> print(type(gt)) <class 'cbgen.typing.Genotype'> >>> print(gt.probability) [[1. 0. 1. 0.] [0. 1. 1. 0.] [1. 0. 0. 1.] [0. 1. 0. 1.]] >>> print(gt.phased) True >>> print(gt.ploidy) [2 2 2 2] >>> print(gt.missing) [False False False False] >>> mf.close() >>> bgen.close()
- Probability
Probability.
- phased
Phasedness.
- Type
Any
- ploidy
Ploidy.
- Type
Any
- missing
Missingness.
- Type
Any
- class cbgen.typing.Partition(offset, variants)[source]
Partition of variants.
>>> import cbgen >>> >>> bgen = cbgen.bgen_file(cbgen.example.get("haplotypes.bgen")) >>> mf = cbgen.bgen_metafile(cbgen.example.get("haplotypes.bgen.metafile")) >>> part = mf.read_partition(0) >>> print(type(part)) <class 'cbgen.typing.Partition'> >>> print(part.offset) 0 >>> print(type(part.variants)) <class 'cbgen.typing.Variants'> >>> mf.close() >>> bgen.close()
- variants
Variants.
- class cbgen.typing.Variants(id, rsid, chromosome, position, nalleles, allele_ids, offset)[source]
Variants.
>>> import cbgen >>> >>> bgen = cbgen.bgen_file(cbgen.example.get("haplotypes.bgen")) >>> mf = cbgen.bgen_metafile(cbgen.example.get("haplotypes.bgen.metafile")) >>> part = mf.read_partition(0) >>> variants = part.variants >>> print(type(variants)) <class 'cbgen.typing.Variants'> >>> print(variants.size) 4 >>> print(variants.id[3]) b'SNP4' >>> print(variants.rsid[3]) b'RS4' >>> print(variants.chromosome[3]) b'1' >>> print(variants.position[3]) 4 >>> print(variants.nalleles[3]) 2 >>> print(variants.allele_ids[3]) b'A,G' >>> print(variants.offset[3]) 273 >>> mf.close() >>> bgen.close()
- id
Identification.
- Type
Any
- rsid
Reference SNP cluster ID.
- Type
Any
- chromosome
Chromosome.
- Type
Any
- position
Position.
- Type
Any
- nalleles
Number of alleles per variant.
- Type
Any
- allele_ids
Allele identifications.
- Type
Any
- offset
Variant offset.
- Type
Any