Skip to content

Commit fc4b856

Browse files
Fix cluster matching in format_results utility
Updated the format_results function to extract numeric IDs from cluster names for more robust matching. This ensures clusters like 'Cluster_0' and '0' are matched correctly in the results.
1 parent 40df4f6 commit fc4b856

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

python/mllmcelltype/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,14 @@ def format_results(results: list[str], clusters: list[str]) -> dict[str, str]:
318318
for cluster in clusters:
319319
cluster_str = str(cluster)
320320

321+
# Extract numeric ID from cluster name (e.g., "Cluster_0" -> "0", "0" -> "0")
322+
cluster_id_match = re.search(r"(\d+)", cluster_str)
323+
cluster_id = cluster_id_match.group(1) if cluster_id_match else cluster_str
324+
321325
# Look for exact matches (e.g., "Cluster 0: T cells")
322326
for line in clean_results:
323327
match = re.match(cluster_pattern, line)
324-
if match and match.group(1) == cluster_str:
328+
if match and match.group(1) == cluster_id:
325329
result[cluster_str] = match.group(2).strip()
326330
break
327331

0 commit comments

Comments
 (0)