logo

Contents:

  • Getting Started
  • User Guide
  • Reading VCF
  • API reference
    • sgkit.io.bgen.bgen_to_zarr
    • sgkit.io.bgen.read_bgen
    • sgkit.io.bgen.rechunk_bgen
    • sgkit.io.plink.read_plink
    • sgkit.io.vcf.vcf_to_zarr
    • sgkit.io.vcf.partition_into_regions
    • sgkit.io.vcf.vcf_to_zarrs
    • sgkit.io.vcf.zarrs_to_dataset
    • sgkit.read_vcfzarr
    • sgkit.load_dataset
    • sgkit.save_dataset
    • sgkit.count_call_alleles
    • sgkit.count_cohort_alleles
    • sgkit.count_variant_alleles
    • sgkit.divergence
    • sgkit.diversity
    • sgkit.Fst
    • sgkit.Garud_H
    • sgkit.gwas_linear_regression
    • sgkit.hardy_weinberg_test
    • sgkit.pc_relate
    • sgkit.regenie
    • sgkit.sample_stats
    • sgkit.Tajimas_D
    • sgkit.variant_stats
    • sgkit.convert_probability_to_call
    • sgkit.display_genotypes
    • sgkit.filter_partial_calls
    • sgkit.simulate_genotype_call_dataset
    • sgkit.window
    • sgkit.variables.base_prediction_spec
    • sgkit.variables.call_allele_count_spec
    • sgkit.variables.call_dosage_spec
    • sgkit.variables.call_dosage_mask_spec
    • sgkit.variables.call_genotype_complete_spec
    • sgkit.variables.call_genotype_complete_mask_spec
    • sgkit.variables.call_genotype_spec
    • sgkit.variables.call_genotype_mask_spec
    • sgkit.variables.call_genotype_phased_spec
    • sgkit.variables.call_genotype_probability_spec
    • sgkit.variables.call_genotype_probability_mask_spec
    • sgkit.variables.cohort_allele_count_spec
    • sgkit.variables.covariates_spec
    • sgkit.variables.dosage_spec
    • sgkit.variables.genotype_counts_spec
    • sgkit.variables.loco_prediction_spec
    • sgkit.variables.meta_prediction_spec
    • sgkit.variables.pc_relate_phi_spec
    • sgkit.variables.sample_call_rate_spec
    • sgkit.variables.sample_id_spec
    • sgkit.variables.sample_n_called_spec
    • sgkit.variables.sample_n_het_spec
    • sgkit.variables.sample_n_hom_alt_spec
    • sgkit.variables.sample_n_hom_ref_spec
    • sgkit.variables.sample_n_non_ref_spec
    • sgkit.variables.sample_pcs_spec
    • sgkit.variables.stat_divergence_spec
    • sgkit.variables.stat_diversity_spec
    • sgkit.variables.stat_Fst_spec
    • sgkit.variables.stat_Garud_h1_spec
    • sgkit.variables.stat_Garud_h12_spec
    • sgkit.variables.stat_Garud_h123_spec
    • sgkit.variables.stat_Garud_h2_h1_spec
    • sgkit.variables.stat_Tajimas_D_spec
    • sgkit.variables.traits_spec
    • sgkit.variables.variant_allele_spec
    • sgkit.variables.variant_allele_count_spec
    • sgkit.variables.variant_allele_frequency_spec
    • sgkit.variables.variant_allele_total_spec
    • sgkit.variables.variant_beta_spec
    • sgkit.variables.variant_call_rate_spec
    • sgkit.variables.variant_contig_spec
    • sgkit.variables.variant_hwe_p_value_spec
    • sgkit.variables.variant_id_spec
    • sgkit.variables.variant_n_called_spec
    • sgkit.variables.variant_n_het_spec
    • sgkit.variables.variant_n_hom_alt_spec
    • sgkit.variables.variant_n_hom_ref_spec
    • sgkit.variables.variant_n_non_ref_spec
    • sgkit.variables.variant_p_value_spec
    • sgkit.variables.variant_position_spec
    • sgkit.variables.variant_t_value_spec
    • sgkit.variables.window_start_spec
    • sgkit.variables.window_stop_spec
  • Contributing to sgkit
Theme by the Executable Book Project

sgkit.io.plink.read_plink¶

sgkit.io.plink.read_plink(*, path=None, bed_path=None, bim_path=None, fam_path=None, chunks='auto', fam_sep=' ', bim_sep='\\t', bim_int_contig=False, count_a1=True, lock=False, persist=True)¶

Read PLINK dataset.

Loads a single PLINK dataset as dask arrays within a Dataset from bed, bim, and fam files.

Parameters
path : str, Path, NoneUnion[str, Path, None] (default: None)

Path to PLINK file set. This should not include a suffix, i.e. if the files are at data.{bed,fam,bim} then only ‘data’ should be provided (suffixes are added internally). Either this path must be provided or all 3 of bed_path, bim_path and fam_path.

bed_path : str, Path, NoneUnion[str, Path, None] (default: None)

Path to PLINK bed file. This should be a full path including the .bed extension and cannot be specified in conjunction with path.

bim_path : str, Path, NoneUnion[str, Path, None] (default: None)

Path to PLINK bim file. This should be a full path including the .bim extension and cannot be specified in conjunction with path.

fam_path : str, Path, NoneUnion[str, Path, None] (default: None)

Path to PLINK fam file. This should be a full path including the .fam extension and cannot be specified in conjunction with path.

chunks : str, int, tupleUnion[str, int, tuple] (default: 'auto')

Chunk size for genotype (i.e. .bed) data, by default “auto”

fam_sep : strstr (default: ' ')

Delimiter for .fam file, by default ” “

bim_sep : strstr (default: '\t')

Delimiter for .bim file, by default ” “

bim_int_contig : boolbool (default: False)

Whether or not the contig/chromosome name in the .bim file should be interpreted as an integer, by default False. If False, then the variant/contig field in the resulting dataset will contain the indexes of corresponding strings encountered in the first .bim field.

count_a1 : boolbool (default: True)

Whether or not allele counts should be for A1 or A2, by default True. Typically A1 is the minor allele and should be counted instead of A2. This is not enforced by PLINK though and it is up to the data generating process to ensure that A1 is in fact an alternate/minor/effect allele. See https://www.cog-genomics.org/plink/1.9/formats for more details.

lock : boolbool (default: False)

Whether or not to synchronize concurrent reads of .bed file blocks, by default False. This is passed through to [dask.array.from_array](https://docs.dask.org/en/latest/array-api.html#dask.array.from_array).

persist : boolbool (default: True)

Whether or not to persist .fam and .bim information in memory, by default True. This is an important performance consideration as the plain text files for this data will be read multiple times when False. This can lead to load times that are upwards of 10x slower.

Return type

DatasetDataset

Returns

A dataset containing genotypes as 3 dimensional calls along with all accompanying pedigree and variant information. The content of this dataset includes:

  • sgkit.variables.variant_id_spec (variants)

  • sgkit.variables.variant_contig_spec (variants)

  • sgkit.variables.variant_position_spec (variants)

  • sgkit.variables.variant_allele_spec (variants)

  • sgkit.variables.sample_id_spec (samples)

  • sgkit.variables.call_genotype_spec (variants, samples, ploidy)

  • sgkit.variables.call_genotype_mask_spec (variants, samples, ploidy)

The following pedigree-specific fields are also included:

  • sample_family_id: Family identifier commonly referred to as FID

  • sample_id: Within-family identifier for sample

  • sample_paternal_id: Within-family identifier for father of sample

  • sample_maternal_id: Within-family identifier for mother of sample

  • sample_sex: Sex code equal to 1 for male, 2 for female, and -1

    for missing

  • sample_phenotype: Phenotype code equal to 1 for control, 2 for case,

    and -1 for missing

See https://www.cog-genomics.org/plink/1.9/formats#fam for more details.

Raises

ValueError – If path and one of bed_path, bim_path or fam_path are provided.

sgkit.io.bgen.rechunk_bgen sgkit.io.vcf.vcf_to_zarr

By sgkit developers
© Copyright 2020, sgkit developers.