pyplink’s API¶
-
class
pyplink.
PyPlink
(prefix, mode='r', bed_format='SNP-major')[source]¶ Reads and store a set of binary Plink files.
Parameters: 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
-
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: Returns: The genotypes of the marker (additive format).
Return type:
-
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: Returns: The name of the marker as a string, and its genotypes as a
numpy.ndarray
(additive format).Return type:
-
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.