Pandas-plink’s documentation¶
You can get the source and open issues on Github.
Install¶
The recommended way of installing it is via conda:
conda install -c conda-forge pandas-plink
An alternative way would be via pip:
pip install pandas-plink
Usage¶
It is as simple as:
from pandas_plink import read_plink
(bim, fam, G) = read_plink('/path/to/data')
assuming that you have the files
- /path/to/data.bim
- /path/to/data.fam
- /path/to/data.bed
Functions¶
-
pandas_plink.
read_plink
(file_prefix, verbose=True)[source]¶ Convert PLINK files into Pandas data frames.
Parameters: Returns: parsed data containing:
pandas.DataFrame
: alleles.pandas.DataFrame
: samples.numpy.ndarray
: genotype.
Return type: Examples
We have shipped this package with an example so can load and inspect by doing
from pandas_plink import read_plink from pandas_plink import example_file_prefix (bim, fam, G) = read_plink(example_file_prefix()) print(bim.head()) print(fam.head()) print(G)
Running the above code will print
snp cm a0 a1 i chrom pos 1 45162 rs10399749 0.0 G C 0 45257 rs2949420 0.0 C T 1 45413 rs2949421 0.0 0 0 2 46844 rs2691310 0.0 A T 3 72434 rs4030303 0.0 0 G 4 father mother gender trait i fid iid Sample_1 Sample_1 0 0 1 -9 0 Sample_2 Sample_2 0 0 2 -9 1 Sample_3 Sample_3 Sample_1 Sample_2 2 -9 2 [[2 2 1] [2 1 2] [3 3 3] [3 3 1] [2 2 2] [2 2 2] [2 1 0] [2 2 2] [1 2 2] [2 1 2]]