项目作者: feng-bao-ucsf

项目描述 :
Explaining the genetic causality for complex diseases by deep association kernel learning
高级语言: Python
项目地址: git://github.com/feng-bao-ucsf/DAK.git
创建时间: 2019-11-29T18:14:25Z
项目社区:https://github.com/feng-bao-ucsf/DAK

开源协议:MIT License

下载


DAK: Explaining the genetic causality for complex diseases by deep association kernel learning

avatar

Causal loci contribute to complex diseases in various manners. The comprehensive identification of suspicious genes requires a general genome-wide association study (GWAS) model that can work with different types of genetic effects. Here, we introduce a deep association kernel learning (DAK) model to enable automatic causal genotype encoding for pathway-level GWAS. Therefore, DAK is able to detect common and rare variants with complicated genetic effects that existing approaches fail. DAK is published as a cover paper in Patterns.

Citation:
Bao, Feng, et al. “Explaining the Genetic Causality for Complex Phenotype via Deep Association Kernel Learning.” Patterns 1.6 (2020): 100057. Link to the paper

Package requirements

DAK requires the following packages for installation:

  • Python >= 3.6
  • TensorFlow-GPU >= 1.4.1
  • (TensorFlow >= 1.4.1 if only use CPU)
  • Numpy >= 1.13.0
  • Scipy >= 1.0.0
  • Pandas >= 0.22.0
  • os
  • time

Usage

Installation

  1. pip install dak

Data preparation

  1. Genotype data

    SNP loci in the same set are stored in one document in the n * m format, where n is the number of samples and m is the number of SNPs in the set. Each locus is in the additive genetic coding format and the DAK.one_hot_convert(geno) function will automatically transform the sequence to one-hot coding data.

    A demonstration genotype format file can be found in ./demo_data/pathway_*.raw_geno.txt

  2. Phenotype data

    Phenotype information is in the n*1 vector format with each row representing the disease status of one sample. 1: disease; 0: control.

    Refer to ./demo_data/pheno.txt for example.

  3. Cofounding data

    Cofounding of samples is in n*k matrix where k is the number of PCs/covariants.

  4. Dividing to batches

    Dividing all data into batch files for training and inference. Users can refer to Step 5 in Demonstration for detailed implementation.

DAK parameters

The parameters of DAK function is listed as follows:

  1. dak = DAK(sess, # tensorflow session that conducts learning task
  2. batch_path_prefix=batch_path_prefix, # file path of genotype data in batches
  3. label_path_prefix=label_path_prefix, # file path of label data in batches
  4. cov_path_prefix=cov_path_prefix, # file path of covariant data in
  5. p_val_path=p_val_path, # file path of p-values by DAK
  6. batch_num=batch_num, # the batch number of the data
  7. batch_size=batch_size, # sample number in each batch file
  8. pathway_num=pathway_num, # number of gene sets
  9. max_path_len=max_path_len, # the maximal SNP number among all gene sets
  10. );

Demonstration

  1. Define the file path of phenotype.

    1. # set the path of label data and covariants (optinal)
    2. label_path = './demo_data/pheno.txt'
    3. # cov_path = '../application/LC_pathway/LC_pathway_cov.txt'
  2. Define paths of outputs: p-value, genotype batches, label batches, one-hot coded genotype (for internal usage of DAK).

    1. # set the aim paths of result and
    2. result_path = './demo_data/p.txt'
    3. pathway_npy_path = './demo_data/pathway_onehot'
    4. batch_npy_path = './demo_data/batch'
    5. batch_label_path = './demo_data/label'
    6. # batch_cov_path = './demo_data/cov' # (optinal)
  3. Set the details of analyzed data

    1. pathway_num = 10 # number of gene sets
    2. indiv_num = 1000 #number of samples in total
    3. batch_size = 50 # number of samples in each batch file
    4. max_path_len = 20000 # maximal SNP numbers in all gene sets
  4. One-hot coding for genotype

    1. # convert raw format SNP into one-hot coding
    2. raw_path = '../application/LC_pathway'
    3. for path_iter in range(pathway_num):
    4. geno = pd.read_csv('./demo_data/pathway_' + str(path_iter) +
    5. '.raw_geno.txt', sep='\t', header=None, index_col=None)
    6. geno = geno.values
    7. gene_one_hot = DAK.one_hot_convert(geno)
    8. np.save(pathway_npy_path + '/pathway_' +
    9. str(path_iter) + '.npy', gene_one_hot)
    10. print('One hot conversion for pathway ' + str(path_iter))
  5. Divide data into batches
    ```python

    convert pathway to training batches

    batch_index = range(0, indiv_num, batch_size)
    label = pd.read_csv(label_path, sep=’\t’, header=0, index_col=None)
    label = np.squeeze(label.values)

cov = pd.read_csv(cov_path, sep=’\t’, header=0, index_col=None)

cov = cov.values.astype(np.float)

cov = stats.zscore(cov, axis=0)

divided to batches

for i in range(len(batchindex) - 1):
batch_seq = np.zeros(
[pathway_num, batch_size, max_path_len, 3], dtype=np.int8)
for path_iter in range(pathway_num):
path_data_buf = np.load(
pathway_npy_path + ‘/pathway
‘ + str(path_iter) + ‘.npy’)

  1. # [N,len,3]
  2. path_data_buf_select = path_data_buf[batch_index[i]:batch_index[i + 1], :, :]
  3. batch_seq[path_iter, :, :path_data_buf_select.shape[1],
  4. :] = path_data_buf_select
  5. batch_seq = batch_seq.astype(np.int8)
  6. np.save(batch_npy_path + '/batch_' + str(i) + '.npy', batch_seq)
  7. batch_label = label[batch_index[i]:batch_index[i + 1]]
  8. np.save(batch_label_path + '/batch_' + str(i) + '.npy', batch_label)
  9. # batch_cov = cov[batch_index[i]:batch_index[i + 1], :]
  10. # np.save(batch_cov_path + '/batch_' + str(i) + '.npy', batch_cov)
  11. print('make batch %d' % i)
  1. 6. Model training and significance test
  2. ```python
  3. # training DAK and test pathway
  4. DAK.train(batch_npy_path, batch_label_path, None, result_path,
  5. batch_num=len(batch_index) - 1, batch_size=batch_size, pathway_num=pathway_num, max_path_len=max_path_len)

Results were store in path specified in result_path.

Example

Code

See demo.py.

Data

In ./demo_data/:

  • Genotype: ./demo_data/pathway_*.raw_geno.txt
  • Phenoytpe: ./demo_data/pheno.txt

Software provided as is under MIT License.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.