Skip to content

Commit 85f5c1d

Browse files
Remove print_consensus_summary from consensus module
Deleted the print_consensus_summary function from consensus.py and removed its import and export from __init__.py. This streamlines the API by eliminating a function primarily used for printing summaries, likely in favor of other reporting or logging mechanisms.
1 parent 335d414 commit 85f5c1d

2 files changed

Lines changed: 0 additions & 103 deletions

File tree

python/mllmcelltype/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from .consensus import (
55
check_consensus,
66
interactive_consensus_annotation,
7-
print_consensus_summary,
87
process_controversial_clusters,
98
)
109
from .functions import get_provider
@@ -58,7 +57,6 @@
5857
"check_consensus",
5958
"process_controversial_clusters",
6059
"interactive_consensus_annotation",
61-
"print_consensus_summary",
6260
# URL utilities
6361
"resolve_provider_base_url",
6462
"get_default_api_url",

python/mllmcelltype/consensus.py

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,104 +1207,3 @@ def interactive_consensus_annotation(
12071207
"max_discussion_rounds": max_discussion_rounds,
12081208
},
12091209
}
1210-
1211-
1212-
def print_consensus_summary(result: dict[str, Any]) -> None:
1213-
"""Print a summary of consensus annotation results.
1214-
1215-
Args:
1216-
result: Dictionary containing consensus results from interactive_consensus_annotation
1217-
1218-
"""
1219-
if "error" in result:
1220-
print(f"Error: {result['error']}")
1221-
return
1222-
1223-
print("\n=== CONSENSUS ANNOTATION SUMMARY ===\n")
1224-
1225-
# Print metadata
1226-
metadata = result.get("metadata", {})
1227-
print(f"Timestamp: {metadata.get('timestamp', 'Unknown')}")
1228-
print(f"Species: {metadata.get('species', 'Unknown')}")
1229-
if metadata.get("tissue"):
1230-
print(f"Tissue: {metadata['tissue']}")
1231-
models_list = metadata.get("models", [])
1232-
model_names = []
1233-
for model in models_list:
1234-
if isinstance(model, dict):
1235-
model_names.append(model.get("model", "Unknown"))
1236-
else:
1237-
model_names.append(str(model))
1238-
print(f"Models used: {', '.join(model_names)}")
1239-
print(f"Consensus threshold: {metadata.get('consensus_threshold', 0.6)}")
1240-
print()
1241-
1242-
# Print controversial clusters
1243-
controversial = result.get("controversial_clusters", [])
1244-
if controversial:
1245-
print(f"Controversial clusters: {len(controversial)} - {', '.join(controversial)}")
1246-
else:
1247-
print("No controversial clusters found.")
1248-
print()
1249-
1250-
# Print consensus annotations with consensus proportion and entropy
1251-
consensus = result.get("consensus", {})
1252-
consensus_proportion = result.get("consensus_proportion", {})
1253-
entropy = result.get("entropy", {})
1254-
resolved = result.get("resolved", {})
1255-
1256-
print("Cluster annotations:")
1257-
for cluster, annotation in sorted(consensus.items(), key=lambda x: x[0]):
1258-
stored_cp = consensus_proportion.get(cluster, 0)
1259-
stored_entropy = entropy.get(cluster, 0)
1260-
if cluster in resolved:
1261-
# For resolved clusters, show CP and H if available in the discussion logs
1262-
discussion_logs = result.get("discussion_logs", {})
1263-
cp_value = "N/A"
1264-
h_value = "N/A"
1265-
1266-
# Try to extract CP and H from discussion logs
1267-
if cluster in discussion_logs:
1268-
logs = discussion_logs[cluster]
1269-
# Check if logs is a list or string
1270-
# Convert logs to string if it's a list, otherwise use directly
1271-
logs_text = "\n".join(logs) if isinstance(logs, list) else logs
1272-
1273-
# Look for CP and H in the last round
1274-
for line in reversed(logs_text.split("\n")):
1275-
if "Consensus Proportion (CP):" in line:
1276-
cp_parts = line.split("Consensus Proportion (CP):")[1].strip().split()
1277-
if cp_parts:
1278-
cp_value = cp_parts[0]
1279-
if "Shannon Entropy (H):" in line:
1280-
h_parts = line.split("Shannon Entropy (H):")[1].strip().split()
1281-
if h_parts:
1282-
h_value = h_parts[0]
1283-
1284-
print(f" Cluster {cluster}: {annotation} [Resolved, CP: {cp_value}, H: {h_value}]")
1285-
else:
1286-
# For non-resolved clusters, use the calculated CP and entropy values
1287-
cp_value = stored_cp
1288-
h_value = stored_entropy
1289-
1290-
# Display different messages based on agreement level
1291-
# Use the already calculated entropy value
1292-
print(f" Cluster {cluster}: {annotation} [CP: {cp_value:.2f}, H: {h_value:.2f}]")
1293-
print()
1294-
1295-
# Print model annotations comparison for controversial clusters
1296-
if controversial:
1297-
print("\nModel annotations for controversial clusters:")
1298-
model_annotations = result.get("model_annotations", {})
1299-
models = list(model_annotations.keys())
1300-
1301-
for cluster in controversial:
1302-
print(f"\nCluster {cluster}:")
1303-
for model in models:
1304-
if cluster in model_annotations.get(model, {}):
1305-
print(f" {model}: {model_annotations[model].get(cluster, 'Unknown')}")
1306-
if cluster in resolved:
1307-
print(f" RESOLVED: {resolved[cluster]}")
1308-
print()
1309-
1310-

0 commit comments

Comments
 (0)