I/O module

HDF5 reader

CSV reader

limix.io.read_csv(filename, sep=None, header=True)[source]

Read a CSV file.

Parameters:
  • filename (str) – Path to a CSV file.
  • sep (str) – Separator.
Returns:

data

Return type:

dask dataframes

Examples

>>> from limix.io import read_csv
>>> from limix.io.examples import csv_file_example
>>>
>>> df = read_csv(csv_file_example())
>>> print(df.compute()) 
   pheno   attr1 attr2 attr3
0    sex  string    10     a
1   size   float    -3     b
2  force     int     f     c

GEN reader

limix.io.read_gen(prefix)[source]

Read GEN files into Pandas data frames.

Parameters:prefix (str) – Path prefix to the set of GEN files.
Returns:
  • sample (dask dataframe)
  • genotype (dask dataframe)

Examples

>>> from limix.io import read_gen
>>> from limix.io.examples import gen_file_example
>>>
>>> data = read_gen(gen_file_example())
>>> print(data['sample']) 
  sample_id subject_id  missing  gender  age  age_of_onset  phenotype_1
0       1A0       W001     0.00       2    4            -9            0
1       1A1       W002     0.00       2    4            -9            0
2       1A2       W003     0.00       2    4            -9            1
3       1A3       W004     0.09       2    4            -9            1
4       1A4       W005     0.00       2    4            -9            1
>>> print(data['genotype'].head()) 
  snp_id  rs_id       pos alleleA alleleB 1A0       1A1       1A2       1A3  \
                                           AA AB BB  AA AB BB  AA AB BB  AA
0    SA1  rs001  10000000       A       G   0  0  1   0  0  1   0  0  1   0
1    SA2  rs002  10010000       A       G   0  0  1   0  1  0   1  0  0   0
2    SA3  rs003  10020000       C       T   1  0  0   0  1  0   0  0  1   0
3    SA4  rs004  10030000       G       T   1  0  0   0  1  0   0  0  1   0
4    SA5  rs005  10040000       C       G   0  0  1   0  1  0   1  0  0   0

                  1A4
       AB      BB  AA      AB      BB
0  0.4277  0.5721   0  0.0207  0.9792
1  1.0000  0.0000   1  0.0000  0.0000
2  0.9967  0.0000   0  0.0000  1.0000
3  1.0000  0.0000   0  0.0000  1.0000
4  1.0000  0.0000   1  0.0000  0.0000