Skip to content

Commit

Permalink
Write pvals to analysis bucket (#221)
Browse files Browse the repository at this point in the history
* write to analysis

* lint

* lint
  • Loading branch information
hopedisastro authored May 22, 2024
1 parent c508027 commit 6c1c558
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion str/associatr/meta_analysis/meta_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def manage_concurrency_for_job(job: hb.batch.job.Job):
output_path(
f"meta_results/{cell_type}/{chromosome}/{gene}_100000bp_meta_results.tsv",
"analysis",
)
),
).exists():
continue
j = get_batch(name='compute_meta').new_python_job(name=f'compute_meta_{cell_type}_{chromosome}_{gene}')
Expand Down
18 changes: 13 additions & 5 deletions str/associatr/meta_analysis/raw_pval_extractor_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,18 @@
This script extracts the raw p-values from the results of the meta-analysis output files.
For downstream use to make a QQ plot.
analysis-runner --dataset "bioheart" --description "raw pval extractor" --access-level "test" \
--output-dir "str/associatr/tob_n1055_and_bioheart_n990/DL_random_model" \
raw_pval_extractor_meta.py --input-dir=gs://cpg-bioheart-test/str/associatr/tob_n1055_and_bioheart_n990/DL_random_model/meta_results \
--cell-types=CD4_TCM --chromosomes=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
analysis-runner --dataset "bioheart" --description "raw pval extractor" --access-level "full" \
--output-dir "str/associatr/snps_and_strs/tob_n1055_and_bioheart_n990" \
--memory="16G" --storage="20G" \
raw_pval_extractor_meta.py --input-dir=gs://cpg-bioheart-main-analysis/str/associatr/snps_and_strs/tob_n1055_and_bioheart_n990/meta_results \
--cell-types=B_memory,B_intermediate --chromosomes=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
analysis-runner --dataset "bioheart" --description "raw pval extractor" --access-level "full" \
--output-dir "str/associatr/common_variants_snps/tob_n1055_and_bioheart_n990" \
--memory="16G" --storage="20G" \
raw_pval_extractor_meta.py --input-dir=gs://cpg-bioheart-main-analysis/str/associatr/common_variants_snps/tob_n1055_and_bioheart_n990/meta_results \
--cell-types=CD4_TCM,B_intermediate --chromosomes=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
"""

Expand Down Expand Up @@ -37,7 +45,7 @@ def main(input_dir, cell_types, chromosomes):
Extracts the raw p-values from the results of associaTR into one text file per cell type.
"""
for cell_type in cell_types.split(','):
gcs_output = output_path(f'raw_pval_extractor/{cell_type}_gene_tests_raw_pvals.txt')
gcs_output = output_path(f'raw_pval_extractor/{cell_type}_gene_tests_raw_pvals.txt', 'analysis')
with to_path(gcs_output).open('w') as f:
for chromosome in chromosomes.split(','):
gene_files = list(to_path(f'{input_dir}/{cell_type}/chr{chromosome}').glob('*.tsv'))
Expand Down
12 changes: 7 additions & 5 deletions str/associatr/meta_analysis/run_gene_level_pvals_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def cct(gene_files: list[str], cell_type: str, chromosome: str, og_weights=None)
output_path(
f'gene_level_pvals/acat/{cell_type}/chr{chromosome}/{gene_name}_gene_level_pval.tsv',
'analysis',
)
),
)
if gcs_output.exists():
print(f'{gene_file} already processed. Skipping...')
Expand Down Expand Up @@ -199,10 +199,12 @@ def bonferroni_compute(gene_files, cell_type, chromosome):
pvals, gene_name, row_dict = process_single_file(gene_file)

# write to output
gcs_output = to_path(output_path(
f'gene_level_pvals/bonferroni/{cell_type}/chr{chromosome}/{gene_name}_gene_level_pval.tsv',
'analysis',
))
gcs_output = to_path(
output_path(
f'gene_level_pvals/bonferroni/{cell_type}/chr{chromosome}/{gene_name}_gene_level_pval.tsv',
'analysis',
),
)
if gcs_output.exists():
print(f'{gene_file} already processed. Skipping...')
continue
Expand Down

0 comments on commit 6c1c558

Please sign in to comment.