pandas-plink
latest

Table of contents

  • Install
  • Usage
  • API
    • pandas_plink.Chunk
    • pandas_plink.get_data_folder
    • pandas_plink.read_grm
    • pandas_plink.read_plink
    • pandas_plink.read_plink1_bin
    • pandas_plink.read_rel
    • pandas_plink.write_plink1_bin
    • pandas_plink.test
pandas-plink
  • »
  • API »
  • pandas_plink.read_rel
  • Edit on GitHub

pandas_plink.read_rel¶

pandas_plink.read_rel(filepath, id_filepath=None)[source]¶

Read PLINK realized relationship matrix files [b].

It supports plain text, binary, and compressed files. The usual file extensions for those types are .rel, .rel.bin, and .rel.zst, respectively.

Example

>>> from os.path import join
>>> from pandas_plink import read_rel
>>> from pandas_plink import get_data_folder
>>> filepath = join(get_data_folder(), "rel-bin", "plink2.rel.bin")
>>> id_filepath = join(get_data_folder(), "rel-bin", "plink2.rel.id")
>>> K = read_rel(filepath, id_filepath)
>>> print(K)
<xarray.DataArray (sample_0: 10, sample_1: 10)>
array([[ 0.89,  0.23, -0.19, -0.01, -0.14,  0.29,  0.27, -0.23, -0.10,
        -0.21],
       [ 0.23,  1.08, -0.45,  0.19, -0.19,  0.17,  0.41, -0.01, -0.13,
        -0.13],
       [-0.19, -0.45,  1.18, -0.04, -0.15, -0.20, -0.31, -0.04,  0.30,
        -0.01],
       [-0.01,  0.19, -0.04,  0.90, -0.07,  0.01,  0.06, -0.19, -0.09,
         0.17],
       [-0.14, -0.19, -0.15, -0.07,  1.18,  0.09, -0.03,  0.10,  0.22,
         0.17],
       [ 0.29,  0.17, -0.20,  0.01,  0.09,  0.96,  0.07, -0.04, -0.09,
        -0.23],
       [ 0.27,  0.41, -0.31,  0.06, -0.03,  0.07,  0.71, -0.10, -0.09,
        -0.06],
       [-0.23, -0.01, -0.04, -0.19,  0.10, -0.04, -0.10,  1.42, -0.30,
        -0.07],
       [-0.10, -0.13,  0.30, -0.09,  0.22, -0.09, -0.09, -0.30,  0.91,
        -0.02],
       [-0.21, -0.13, -0.01,  0.17,  0.17, -0.23, -0.06, -0.07, -0.02,
         0.91]])
Coordinates:
  * sample_0  (sample_0) object 'HG00419' 'HG00650' ... 'NA20508' 'NA20753'
  * sample_1  (sample_1) object 'HG00419' 'HG00650' ... 'NA20508' 'NA20753'
    fid       (sample_1) object 'HG00419' 'HG00650' ... 'NA20508' 'NA20753'
    iid       (sample_1) object 'HG00419' 'HG00650' ... 'NA20508' 'NA20753'
Parameters
  • filepath (str) – Path to the matrix file.

  • id_filepath (str, optional) – Path to the file containing family and individual IDs. It defaults to None, in which case it will try to be inferred.

Returns

rel – Realized relationship matrix.

Return type

xarray.DataArray

References

b

Read PLINK realized relationship matrix files. https://www.cog-genomics.org/plink/2.0/distance

Next Previous

© Copyright 2018, Danilo Horta. Revision b580df7f.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
Downloads
html
On Read the Docs
Project Home
Builds