diff options
author | zsloan | 2021-07-26 20:47:37 +0000 |
---|---|---|
committer | zsloan | 2022-03-22 19:07:59 +0000 |
commit | 9a8ab0ea1bbfc82c79cb8183c37200a09ab27d9c (patch) | |
tree | a51437ea4678c7495aa49376370d0dec7ff4e0b2 /gn3 | |
parent | acfea0fc8793372723be0e64316002ed9bc2403b (diff) | |
download | genenetwork3-9a8ab0ea1bbfc82c79cb8183c37200a09ab27d9c.tar.gz |
Added pairscan boolean kwarg and process_rqtl_pairscan function for reading in pairscan results + renamed process_rqtl_output to process_rqtl_mapping to distinguish between that and pairscan
Diffstat (limited to 'gn3')
-rw-r--r-- | gn3/api/rqtl.py | 8 | ||||
-rw-r--r-- | gn3/computations/rqtl.py | 17 |
2 files changed, 21 insertions, 4 deletions
diff --git a/gn3/api/rqtl.py b/gn3/api/rqtl.py index b5627c5..ed01a97 100644 --- a/gn3/api/rqtl.py +++ b/gn3/api/rqtl.py @@ -25,7 +25,7 @@ run the rqtl_wrapper script and return the results as JSON # Split kwargs by those with values and boolean ones that just convert to True/False kwargs = ["covarstruct", "model", "method", "nperm", "scale", "control_marker"] - boolean_kwargs = ["addcovar", "interval", "pstrata"] + boolean_kwargs = ["addcovar", "interval", "pstrata", "pairscan"] all_kwargs = kwargs + boolean_kwargs rqtl_kwargs = {"geno": genofile, "pheno": phenofile} @@ -48,9 +48,11 @@ run the rqtl_wrapper script and return the results as JSON "output", rqtl_cmd.get('output_file'))): os.system(rqtl_cmd.get('rqtl_cmd')) - rqtl_output['results'] = process_rqtl_output(rqtl_cmd.get('output_file')) + if "pairscan" in boolean_kwargs: + rqtl_output['results'] = process_rqtl_pairscan(rqtl_cmd.get('output_file')) + else: + rqtl_output['results'] = process_rqtl_mapping(rqtl_cmd.get('output_file')) - rqtl_output['results'] = process_rqtl_output(rqtl_cmd.get('output_file')) if int(rqtl_kwargs['nperm']) > 0: rqtl_output['perm_results'], rqtl_output['suggestive'], rqtl_output['significant'] = \ process_perm_output(rqtl_cmd.get('output_file')) diff --git a/gn3/computations/rqtl.py b/gn3/computations/rqtl.py index b3539a9..b9e715a 100644 --- a/gn3/computations/rqtl.py +++ b/gn3/computations/rqtl.py @@ -47,7 +47,7 @@ output filename generated from a hash of the genotype and phenotype files } -def process_rqtl_output(file_name: str) -> List: +def process_rqtl_mapping(file_name: str) -> List: """Given an output file name, read in R/qtl results and return a List of marker objects @@ -80,6 +80,21 @@ def process_rqtl_output(file_name: str) -> List: return marker_obs +def process_rqtl_pairscan(file_name: str) -> List: + """Given an output file name, read in R/qtl pair-scan results and return + a List of Lists representing the matrix of results + + """ + results = [] + with open(os.path.join(current_app.config.get("TMPDIR", "/tmp"), + "output", file_name), "r") as the_file: + for i, line in enumerate(the_file): + if i == 0: # Skip first line + continue + line_items = line.split(",") + results.append(line_items[1:]) # Append all but first item in line + + return results def process_perm_output(file_name: str): """Given base filename, read in R/qtl permutation output and calculate |