Skip to content

Commit

Permalink
fix: change on yaml and id range (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyue1214 authored Mar 19, 2024
1 parent a2a2f47 commit 8d4f99b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion bin/accession_id.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ then
helpFunction
fi

id=$(echo $GCST|sed 's/GCST/1/g')
ida=$(echo $GCST|sed 's/GCST/1/g')
id=$(($ida-1))
lower=$((10#$id/1000*1000+1))
upper=$(((10#$id/1000+1)*1000))

Expand Down
7 changes: 4 additions & 3 deletions bin/lib/SumStatRecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, chrom, pos, other_al, effect_al, beta, oddsr,
self.other_al = other_al
self.effect_al = effect_al
self.data = data
self.beta = float(beta) if beta is not None else None
self.beta = safe_float(beta) if beta is not None else None
self.oddsr = safe_float(oddsr) if oddsr is not None else None
self.oddsr_lower = safe_float(oddsr_lower) if oddsr_lower is not None else None
self.oddsr_upper = safe_float(oddsr_upper) if oddsr_upper is not None else None
Expand Down Expand Up @@ -74,8 +74,9 @@ def flip_beta(self):
to flipping.
"""
# Flip beta
if self.beta and self.beta != 0:
self.beta = self.beta * -1
if self.beta:
if self.beta != 0:
self.beta = self.beta * -1
# Flip OR
if self.oddsr:
self.oddsr = self.oddsr ** -1
Expand Down
9 changes: 6 additions & 3 deletions bin/main_pysam.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,12 @@ def main():
out_raw["hm_coordinate_conversion"] = ss_rec.data["hm_coordinate_conversion"]
out_raw["variant_id"] = vcf_rec.hgvs()[0] if vcf_rec and ss_rec.is_harmonised else args.na_rep_out
out_raw["rsid"] = ss_rec.hm_rsid if vcf_rec and ss_rec.is_harmonised else args.na_rep_out
out_raw["standard_error"]=ss_rec.data["standard_error"] if ss_rec.data["standard_error"] is not None else args.na_rep_out
try:
out_raw["standard_error"]=ss_rec.data["standard_error"] if ss_rec.data["standard_error"] is not None else args.na_rep_out
except:
out_raw["standard_error"]=args.na_rep_out
# Add other data from summary stat file
outed=["chromosome","base_pair_location","p_value","effect_allele","other_allele","effect_allele_frequency","beta","odds_ratio","standard_error","rsid","ci_upper","ci_lower","hm_coordinate_conversion"]
outed=["chromosome","base_pair_location","p_value","effect_allele","other_allele","effect_allele_frequency","beta","odds_ratio","rsid","standard_error","ci_upper","ci_lower","hm_coordinate_conversion"]
for key in ss_rec.data:
if key not in outed:
value = ss_rec.data[key] if ss_rec.data[key] else args.na_rep_out
Expand Down Expand Up @@ -262,7 +265,7 @@ def parse_args():
'(b) 0_base '),
nargs='?',
type=str,
const="1-based")
default="1-based")
mode_group.add_argument('--palin_mode', metavar="[infer|forward|reverse|drop]",
help=('Mode to use for palindromic variants:\n'
'(a) infer strand from effect-allele freq, '
Expand Down
7 changes: 4 additions & 3 deletions modules/local/harmonization_log.nf
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ process harmonization_log {
data_file_name="${GCST}.h.tsv.gz"
out_yaml="${GCST}.h.tsv.gz-meta.yaml"
data_file_md5sum=\$(md5sum<${launchDir}/$GCST/final/${GCST}.h.tsv.gz | awk '{print \$1}')
date_last_modified=\$(date +"%Y-%m-%d")
date_metadata_last_modified=\$(date +"%Y-%m-%d")
harmonisation_reference=\$(tabix -H "${params.ref}/homo_sapiens-${chr}.vcf.gz" | grep reference | cut -f2 -d '=')
gwas_metadata.py \
-i $raw_yaml \
-o \$out_yaml \
--dataFileName \$data_file_name \
-e \
--data_file_name \$data_file_name \
--data_file_md5sum \$data_file_md5sum \
--is_harmonised True \
--is_sorted True \
--genome_assembly GRCh38 \
--coordinate_system 1-based \
--date_last_modified \$date_last_modified \
--date_metadata_last_modified \$date_metadata_last_modified \
--harmonisation_reference \$harmonisation_reference \
"""
}

0 comments on commit 8d4f99b

Please sign in to comment.