-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
50 harmonised file conforms to new standard format (#71)
* ticket #49 #50 This branch is design to solved ticket 49 to read genome build from the yaml file (here, suppose the yaml file is under the same folder), and ticket 50 to rearrange the output file with the new format. * Update map_to_build.nf * Update common_constants.py main.py using the --rsid_col rsid not the variant_id to solve the problem if there are multiple reference records for one site. * Update main_pysam.py keep harmonised header in specific order * Update gwascatalogharm.nf change the input file as [GCST,yaml path, input path] * bare bones meta client * Create GCSTtest.tsv.ymal * Update and rename GCSTtest_b37.tsv to GCSTtest.tsv * Rename test_data/GCSTtest.tsv.ymal to test_data/homes/yueji/.nextflow/assets/EBISPOT/gwas-sumstats-harmoniser/test_data/GCSTtest.tsv-meta.yamll * test yaml file add test yaml file * Update test.config new format test data * Create GCSTtest.tsv-meta.yaml * Update GCSTtest.tsv test data modify * Update GCSTtest.tsv-meta.yaml * Update GCSTtest.tsv * Update main_pysam.py tmp: keep the original variant_id and hm_varid column temporary for the qc since qc step need it. the column after the qc is fixed * Update GCSTtest.tsv modify the test input file * Update qc.nf will add bgzip and tabix in the qc.py using pysam * Update main_pysam.py FIx the hm_code and hm_coordinate_conversio at the position after the mandatory fields. * Update harmonization_log.nf new hm_code position * Yaml make raw_yaml available until the qc step * keep raw content in col 4 keep what in the raw column 4 * Update map_to_build_nf.py update master #65 update to the branch * Update main_pysam.py Allows the standard_error does not exist in the raw data. * Update main_pysam.py * Update qc.nf sort the qc result for tabix * sort chr and pos update the sorted by the chr and pos, also for data with mandatory columns only * Update harmonization.nf * adding metadata model, update yaml file and publish * add coord system to metadata * #70 #70 liftover with specified coordinate system * #70 Further update on converting the coordinate system: 1. map_to_build.py: bp-coordinate -> liftover -> bp'+1 2. main_pysam.py: if 0-base and indels and hm_coordinate_conversion="lo": vcf_rec=tabix(chr, bp-2,bp) else: vcf_rec=tabix(chr, bp-1,bp) 3. harmonisation.nf: read yaml file 4. test_data: 1_base and 0_base tsv file. * #70 * add one new row of the test data * #70 * import schema from gwas-sumstats-tools, camelCase to snake_case * add container.config * auto map col names to scheme use utils.py to map args for strand count * rename test input file * Create GCST0.tsv-meta.yaml * Create GCST1.tsv-meta.yaml * Update main_harm.nf * change on flip_beta * Change variant_id to rsid for map_to_build * Update container.config * qc base on rsid not variant_id * using gwas_sumstats_tools to reorder the columns reorder the output columns using the gwas_sumstats_tools function : _set_header_order() * Update main_pysam.py * Update main_pysam.py * wait for all previous process to finish * wait until all chr finish ten_sc process * Update main_pysam.py * Update container.config resetting default container config --------- Co-authored-by: jdhayhurst <hayhurst.jd@gmail.com> Co-authored-by: jdhayhurst <38317975+jdhayhurst@users.noreply.github.com>
- Loading branch information
1 parent
04caa52
commit f1542de
Showing
44 changed files
with
488 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
FROM python:3.7-slim-buster | ||
FROM python:3.9-slim-buster | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends gcc wget python-dev libmagic-dev tabix \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY . . | ||
|
||
RUN pip install --upgrade pip | ||
RUN pip install -r environments/requirements.txt \ | ||
&& apt-get purge -y --auto-remove gcc python-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env python | ||
|
||
import yaml | ||
import argparse | ||
|
||
from gwas_sumstats_tools.schema.metadata import SumStatsMetadata | ||
|
||
|
||
class MetadataClient: | ||
def __init__(self, meta_dict=None, | ||
in_file=None, | ||
out_file=None) -> None: | ||
self.metadata = SumStatsMetadata.construct() | ||
self._meta_dict = meta_dict | ||
self._in_file = in_file | ||
self._out_file = out_file | ||
|
||
def from_file(self) -> None: | ||
with open(self._in_file, "r") as fh: | ||
self._meta_dict = yaml.safe_load(fh) | ||
self.update_metadata(self._meta_dict) | ||
|
||
def to_file(self) -> None: | ||
with open(self._out_file, "w") as fh: | ||
yaml.dump(self.metadata.dict(exclude_none=True), | ||
fh, | ||
encoding='utf-8') | ||
|
||
def update_metadata(self, data_dict) -> None: | ||
""" | ||
Create a copy of the model and update (no validation occurs) | ||
""" | ||
self._meta_dict.update(data_dict) | ||
self.metadata = self.metadata.parse_obj(self._meta_dict) | ||
|
||
def __repr__(self) -> str: | ||
""" | ||
YAML str representation of metadata. | ||
""" | ||
return yaml.dump(self.metadata.dict()) | ||
|
||
|
||
def main(): | ||
argparser = argparse.ArgumentParser() | ||
argparser.add_argument('-i', help='Input metadata yaml file') | ||
argparser.add_argument('-o', help='output metadata yaml file') | ||
argparser.add_argument('-e', help='Edit mode, provide params to edit e.g. `-GWASID GCST123456` to edit/add that value', action='store_true') | ||
_, unknown = argparser.parse_known_args() | ||
for arg in unknown: | ||
if arg.startswith(("-", "--")): | ||
arg_pair = arg.split('=') | ||
argparser.add_argument(arg_pair[0]) | ||
args = argparser.parse_args() | ||
known_args = {'i', 'o', 'e'} | ||
in_file = args.i | ||
out_file = args.o | ||
edit_mode = args.e | ||
m = MetadataClient(in_file=in_file, out_file=out_file) | ||
if in_file: | ||
m.from_file() | ||
print(f"===========\nMetadata in\n===========\n{m}") | ||
if edit_mode: | ||
data_dict = {k: v for k, v in vars(args).items() if k not in known_args} | ||
m.update_metadata(data_dict) | ||
if out_file: | ||
print(f"============\nMetadata out\n============\n{m}") | ||
m.to_file() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.