aboutsummaryrefslogtreecommitdiff
path: root/gn3/computations
diff options
context:
space:
mode:
authorMuriithi Frederick Muriuki2021-08-31 10:45:11 +0300
committerMuriithi Frederick Muriuki2021-08-31 10:45:11 +0300
commit64ce38b45839b6305b009f6e28b0f852409e9bda (patch)
tree9b645ae004289b963704cd6503255f4f0c3ac06d /gn3/computations
parent750eff22f33fc8c78d529702369446e3acbdcae6 (diff)
downloadgenenetwork3-64ce38b45839b6305b009f6e28b0f852409e9bda.tar.gz
Parse QTLReaper outputs
Issue: https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi * gn3/computations/qtlreaper.py: pass output files * tests/unit/computations/data/qtlreaper/main_output_sample.txt: sample test data * tests/unit/computations/data/qtlreaper/permu_output_sample.txt: sample test data * tests/unit/computations/test_qtlreaper.py: add tests Add code to parse the QTLReaper output data files.
Diffstat (limited to 'gn3/computations')
-rw-r--r--gn3/computations/qtlreaper.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/gn3/computations/qtlreaper.py b/gn3/computations/qtlreaper.py
index c058e14..3b8e4db 100644
--- a/gn3/computations/qtlreaper.py
+++ b/gn3/computations/qtlreaper.py
@@ -90,3 +90,21 @@ def run_reaper(
subprocess.run(command_list, check=True)
return (output_filename, permu_output_filename)
+
+
+def parse_reaper_main_results(results_file):
+ with open(results_file, "r") as infile:
+ lines = infile.readlines()
+
+ def __parse_line(line):
+ items = line.strip().split("\t")
+ return items[0:2] + [float(item) for item in items[2:]]
+
+ header = lines[0].strip().split("\t")
+ return [dict(zip(header, __parse_line(line))) for line in lines[1:]]
+
+def parse_reaper_permutation_results(results_file):
+ with open(results_file, "r") as infile:
+ lines = infile.readlines()
+
+ return [float(line.strip()) for line in lines]