Skip to content
Snippets Groups Projects
Commit 1f8e9867 authored by Hanna  JULIENNE's avatar Hanna JULIENNE
Browse files

added title and description to test data

parent 36d25d6c
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ import re ...@@ -9,6 +9,7 @@ import re
import glob import glob
import logging import logging
from pandas import HDFStore, DataFrame, read_csv, concat, options, read_hdf from pandas import HDFStore, DataFrame, read_csv, concat, options, read_hdf
import h5py
import pandas as pd import pandas as pd
# create (or open) an hdf5 file and opens in append mode # create (or open) an hdf5 file and opens in append mode
import numpy as np import numpy as np
...@@ -29,10 +30,13 @@ class InitMeta(object): ...@@ -29,10 +30,13 @@ class InitMeta(object):
def get_inittable_meta(file_name): def get_inittable_meta(file_name):
init_store = HDFStore(file_name, mode='r') init_store = HDFStore(file_name, mode='r')
nb_snps = init_store.get_storer("SumStatTab").nrows nb_snps = init_store.get_storer("SumStatTab").nrows
name=f"Name of {file_name.split('/')[-1]}"
desc=f"Description {file_name.split('/')[-1]}"
init_store.close() init_store.close()
nb_phenotypes = read_hdf(file_name, "PhenoList").shape[0] nb_phenotypes = read_hdf(file_name, "PhenoList").shape[0]
f = h5py.File(file_name, mode='r')
name=f.attrs['title']
desc=f.attrs["description"]
f.close()
return dict( return dict(
nb_snps=int(nb_snps), nb_snps=int(nb_snps),
nb_phenotypes=int(nb_phenotypes), nb_phenotypes=int(nb_phenotypes),
...@@ -40,6 +44,15 @@ def get_inittable_meta(file_name): ...@@ -40,6 +44,15 @@ def get_inittable_meta(file_name):
desc=desc, desc=desc,
) )
def add_inittable_meta(file_name, title, description):
"""
add description in hdf5 attributes
"""
f = h5py.File(file_name, mode='a')
f.attrs['title'] = title
f.attrs["description"] = description
f.close()
def get_gwasname(file_name): def get_gwasname(file_name):
return "_".join(os.path.basename(file_name).split("_")[0:3]) return "_".join(os.path.basename(file_name).split("_")[0:3])
...@@ -51,7 +64,6 @@ def check_if_SNP_unique(z_gwas_chrom): ...@@ -51,7 +64,6 @@ def check_if_SNP_unique(z_gwas_chrom):
) )
raise IOError(msg) raise IOError(msg)
def get_gwas_dict(input_data_path): def get_gwas_dict(input_data_path):
gwas_dict = {} gwas_dict = {}
# retrieve all files corresponding to glob patterns # retrieve all files corresponding to glob patterns
......
File mode changed from 100755 to 100644
No preview for this file type
No preview for this file type
from jass.models.inittable import get_inittable_meta, add_inittable_meta
# we need python package h5py to read/write .hdf5 file
if __name__ == "__main__":
title = 'Curated GWAS summary statistics on African ancestry on 19 blood count traits and glycemic traits (hg38)'
des = 'Genome wide curated summary statistics on 19 blood count traits and glycemic traits' \
'File format is the inittable format intended to be used with the Joint Analysis of Summary Statistics (JASS), which allows to perform multi-trait GWAS:' \
'https://gitlab.pasteur.fr/statistical-genetics/jass' \
'GWAS of hematological traits originate from Chen et al paper and were downloaded from the GWAS Catalog (https://www.ebi.ac.uk/gwas/publications/32888493#study_panel). GWAS of glycemic traits come from the (18) study downloadable from GWAS Catalog (https://www.ebi.ac.uk/gwas/publications/34059833).'
hdf5_file = '/pasteur/zeus/projets/p02/GGS_JASS/jass_pipeline_dev_copie/jass/jass/test/data_test2/initTable.hdf5'
add_inittable_meta(hdf5_file, title, des)
print(get_inittable_meta(hdf5_file))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment