Skip to content

Commit

Permalink
Write medoid to cluster metadata file (#369)
Browse files Browse the repository at this point in the history
It's often useful to know which medoid was used to generate a cluster.
Remarkably, we didn't think to output it earlier.
  • Loading branch information
jakobnissen authored Nov 18, 2024
1 parent 3828e3d commit 003735d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion vamb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ def cluster_and_write_files(

# Write the cluster metadata to file
with open(Path(base_clusters_name + "_metadata.tsv"), "w") as file:
print("name\tradius\tpeak valley ratio\tkind\tbp\tncontigs", file=file)
print("name\tradius\tpeak valley ratio\tkind\tbp\tncontigs\tmedoid", file=file)
for i, cluster in enumerate(clusters):
cluster_dict[str(i + 1)] = {
sequence_names[cast(int, i)] for i in cluster.members
Expand All @@ -1150,6 +1150,7 @@ def cluster_and_write_files(
cluster.kind_str,
sum(sequence_lens[i] for i in cluster.members),
len(cluster.members),
sequence_names[cluster.medoid],
file=file,
sep="\t",
)
Expand Down

0 comments on commit 003735d

Please sign in to comment.