diff options
| author | Alexander_Kabui | 2025-01-24 16:57:42 +0300 |
|---|---|---|
| committer | BonfaceKilz | 2025-02-06 12:43:15 +0300 |
| commit | 878b516b932594c608e9d1b91d78a624f41a5e25 (patch) | |
| tree | 8e336fdad2410332ef5c588380bf1288deb36d97 /gn3/computations/rqtl2.py | |
| parent | 94180a6a9264ad12991575a7077046498058b7d0 (diff) | |
| download | genenetwork3-878b516b932594c608e9d1b91d78a624f41a5e25.tar.gz | |
feat: Add function to process permutation results.
Diffstat (limited to 'gn3/computations/rqtl2.py')
| -rw-r--r-- | gn3/computations/rqtl2.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gn3/computations/rqtl2.py b/gn3/computations/rqtl2.py index 7b435ab..e8a5b0f 100644 --- a/gn3/computations/rqtl2.py +++ b/gn3/computations/rqtl2.py @@ -119,6 +119,33 @@ def read_output_file(output_path: str) -> dict: return results +def process_permutation(data): + """ This function processses output data from the output results. + input: data object extracted from the output_file + returns: + dict: A dict containing + * phenotypes array + * permutations as dict with keys as permutation_id + * significance_results with keys as threshold values + """ + + perm_file = data.get("permutation_file") + perm_results = {} + with open(perm_file, "r", encoding="utf-8") as file_handler: + reader = csv.reader(file_handler) + phenotypes = next(reader)[1:] + for line in reader: + permutation_id, *permutation_values = line + perm_results[permutation_id] = permutation_values + + _, significance = fetch_significance_results(data.get("significance_file")) + return { + "phenotypes": phenotypes, + "perm_results": perm_results, + "significance": significance, + } + + def fetch_significance_results(file_path: str): """ Processes the 'significance_file' from the given data object to extract |
