pyplink

Navigation

  • Installation
  • pyplink’s API
    • PyPlink
      • PyPlink.close()
      • PyPlink.get_acgt_geno_marker()
      • PyPlink.get_bim()
      • PyPlink.get_duplicated_markers()
      • PyPlink.get_fam()
      • PyPlink.get_geno_marker()
      • PyPlink.get_nb_markers()
      • PyPlink.get_nb_samples()
      • PyPlink.iter_acgt_geno()
      • PyPlink.iter_acgt_geno_marker()
      • PyPlink.iter_geno()
      • PyPlink.iter_geno_marker()
      • PyPlink.next()
      • PyPlink.seek()
      • PyPlink.write_genotypes()
    • test()

Related Topics

  • Documentation overview
    • Previous: Installation

Quick search

pyplink’s API¶

class pyplink.PyPlink(prefix, mode='r', bed_format='SNP-major')[source]¶

Reads and store a set of binary Plink files.

Parameters:
  • prefix (str) – The prefix of the binary Plink files.

  • mode (str) – The open mode for the binary Plink file.

  • bed_format (str) – The type of bed (SNP-major or INDIVIDUAL-major).

Reads or write binary Plink files (BED, BIM and FAM).

from pyplink import PyPlink

# Reading BED files
with PyPlink("plink_file_prefix") as bed:
    pass

# Writing BED files
with PyPlink("plink_file_prefix", "w") as bed:
    pass
close()[source]¶

Closes the BED file.

get_acgt_geno_marker(marker)[source]¶

Gets the genotypes for a given marker (ACGT format).

Parameters:

marker (str) – The name of the marker.

Returns:

The genotypes of the marker (ACGT format).

Return type:

numpy.ndarray

get_bim()[source]¶

Returns the BIM file.

Returns:

The BIM file.

Return type:

pandas.DataFrame

get_duplicated_markers()[source]¶

Returns the duplicated markers, if any.

Returns:

The set of duplicated marker (might be empty).

Return type:

dict

get_fam()[source]¶

Returns the FAM file.

Returns:

The FAM file.

Return type:

pandas.DataFrame

get_geno_marker(marker, return_index=False)[source]¶

Gets the genotypes for a given marker.

Parameters:
  • marker (str) – The name of the marker.

  • return_index (bool) – Wether to return the marker’s index or not.

Returns:

The genotypes of the marker (additive format).

Return type:

numpy.ndarray

get_nb_markers()[source]¶

Returns the number of markers.

Returns:

The number of markers in the dataset.

Return type:

int

get_nb_samples()[source]¶

Returns the number of samples.

Returns:

The number of samples in the dataset.

Return type:

int

iter_acgt_geno()[source]¶

Iterates over genotypes (ACGT format).

Returns:

The name of the marker as a string, and its genotypes as a numpy.ndarray (ACGT format).

Return type:

tuple

iter_acgt_geno_marker(markers)[source]¶

Iterates over genotypes for a list of markers (ACGT format).

Parameters:

markers (list) – The list of markers to iterate onto.

Returns:

The name of the marker as a string, and its genotypes as a numpy.ndarray (ACGT format).

Return type:

tuple

iter_geno()[source]¶

Iterates over genotypes from the beginning of the BED file.

Returns:

The name of the marker as a string, and its genotypes as a numpy.ndarray (additive format).

Return type:

tuple

iter_geno_marker(markers, return_index=False)[source]¶

Iterates over genotypes for a list of markers.

Parameters:
  • markers (list) – The list of markers to iterate onto.

  • return_index (bool) – Wether to return the marker’s index or not.

Returns:

The name of the marker as a string, and its genotypes as a numpy.ndarray (additive format).

Return type:

tuple

next()[source]¶

Returns the next marker.

Returns:

The marker name as a string and its genotypes as a numpy.ndarray.

Return type:

tuple

seek(n)[source]¶

Gets to a certain marker position in the BED file.

Parameters:

n (int) – The index of the marker to seek to.

write_genotypes(genotypes)[source]¶

Write genotypes to binary file.

Parameters:

genotypes (numpy.ndarray) – The genotypes to write in the BED file.

A module to read Plink’s binary files.

pyplink.test(verbosity=1)[source]¶

Executes all the tests for pyplink.

Parameters:

verbosity (int) – The verbosity level for unittest.

Just set verbosity to an integer higher than 1 to have more information about the tests.

©2017, Louis-Philippe Lemieux Perreault. | Powered by Sphinx 7.3.7 & Alabaster 0.7.16 | Page source