diff options
author | Frederick Muriuki Muriithi | 2022-09-29 04:22:29 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2022-09-29 04:22:29 +0300 |
commit | 495e02be4e3264c07e4ae89ccd2bc747bf2b6b59 (patch) | |
tree | c48b9a845fe2df07786aceec51535fe77f28f991 /wqflask | |
parent | ec36837e51b33ce771f50ab8937d0fc3d189d556 (diff) | |
download | genenetwork2-495e02be4e3264c07e4ae89ccd2bc747bf2b6b59.tar.gz |
Remove empty rows, and conversion for output
Remove any rows that do not have values since they are not useful to
the computations and only lead to errors.
Remove the conversion to output format here: only convert the values
for output at the point of output, and not earlier.
Diffstat (limited to 'wqflask')
-rw-r--r-- | wqflask/wqflask/correlation/rust_correlation.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/wqflask/wqflask/correlation/rust_correlation.py b/wqflask/wqflask/correlation/rust_correlation.py index d9193459..8d32aaba 100644 --- a/wqflask/wqflask/correlation/rust_correlation.py +++ b/wqflask/wqflask/correlation/rust_correlation.py @@ -250,11 +250,15 @@ def __compute_sample_corr__( target_dataset.get_trait_data(list(sample_data.keys())) - target_data = [] - for (key, val) in target_dataset.trait_data.items(): - lts = [key] + [str(x) for x in val if x is not None] - r = ",".join(lts) - target_data.append(r) + + def __merge_key_and_values__(rows, current): + wo_nones = [value for value in current[1] if value is not None] + if len(wo_nones) > 0: + return rows + [[current[0]] + wo_nones] + return rows + + target_data = reduce( + __merge_key_and_values__, target_dataset.trait_data.items(), []) if len(target_data) == 0: return {} |