From 78ee2e3a5e2d426ad49a8fae2380671b067aad73 Mon Sep 17 00:00:00 2001 From: Nick Croucher Date: Mon, 9 Dec 2024 18:54:17 +0000 Subject: [PATCH] Add incomplete epi info to microreact --- PopPUNK/plot.py | 15 +++++++-------- test/batch123_info.csv | 5 +++++ test/run_test.py | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 test/batch123_info.csv diff --git a/PopPUNK/plot.py b/PopPUNK/plot.py index c8e5dd6b..bc6006fd 100644 --- a/PopPUNK/plot.py +++ b/PopPUNK/plot.py @@ -730,14 +730,13 @@ def writeClusterCsv(outfile, nodeNames, nodeLabels, clustering, d['Status'].append("Reference") if epiCsv is not None: if label in epiData.index: - if label in epiData.index: - for col, value in zip(epiData.columns.values, epiData.loc[[label]].iloc[0].values): - if col not in columns_to_be_omitted: - d[col].append(str(value)) - else: - for col in epiData.columns.values: - if col not in columns_to_be_omitted: - d[col].append('nan') + for col, value in zip(epiData.columns.values, epiData.loc[[label]].iloc[0].values): + if col not in columns_to_be_omitted: + d[col].append(str(value)) + else: + for col in epiData.columns.values: + if col not in columns_to_be_omitted: + d[col].append('') else: sys.stderr.write("Cannot find " + name + " in clustering\n") diff --git a/test/batch123_info.csv b/test/batch123_info.csv new file mode 100644 index 00000000..eae6495a --- /dev/null +++ b/test/batch123_info.csv @@ -0,0 +1,5 @@ +id,Location +19183_4#55,CountryX +19183_4#48,CountryY +12754_4#89,CountryZ +12754_5#16,CountryZ diff --git a/test/run_test.py b/test/run_test.py index 8dad304d..2b8eb42c 100755 --- a/test/run_test.py +++ b/test/run_test.py @@ -134,7 +134,7 @@ subprocess.run(python_cmd + " ../poppunk-runner.py --fit-model dbscan --ref-db batch12 --output batch12 --overwrite", shell=True, check=True) subprocess.run(python_cmd + " ../poppunk-runner.py --fit-model refine --ref-db batch12 --output batch12 --overwrite", shell=True, check=True) subprocess.run(python_cmd + " ../poppunk_assign-runner.py --db batch12 --query rfile3.txt --output batch3 --external-clustering batch12_external_clusters.csv --save-partial-query-graph --overwrite", shell=True, check=True) -subprocess.run(python_cmd + " ../poppunk_visualise-runner.py --ref-db batch12 --query-db batch3 --output batch123_viz --external-clustering batch12_external_clusters.csv --previous-query-clustering batch3/batch3_external_clusters.csv --cytoscape --rapidnj rapidnj --use-partial-query-graph ./batch3/batch3_query.subset --recalculate-distances --extend-query-graph --overwrite", shell=True, check=True) +subprocess.run(python_cmd + " ../poppunk_visualise-runner.py --ref-db batch12 --query-db batch3 --output batch123_viz --external-clustering batch12_external_clusters.csv --previous-query-clustering batch3/batch3_external_clusters.csv --cytoscape --rapidnj rapidnj --use-partial-query-graph ./batch3/batch3_query.subset --recalculate-distances --extend-query-graph --info-csv batch123_info.csv --microreact --overwrite", shell=True, check=True) # citations sys.stderr.write("Printing citations\n")