lazappi / clustree

Visualise Clusterings at Different Resolutions
https://lazappi.github.io/clustree/
GNU General Public License v3.0
215 stars 15 forks source link

Adding node specific labels #91

Closed gomeznick86 closed 1 year ago

gomeznick86 commented 1 year ago

Hi @lazappi!

I'm trying to plot a specific label and wondering if it is even possible. I've calculated a specific score, let's call it a participation score, its simply a metric describing the prevalence of that specific cluster in the dataset. This participation score is specific for each cluster and changes as the clustering resolutions also change. I have a list in which the elements of the list are data.frames with the cluster number and participation score for each cluster resolution. Is it possible to map these scores back as labels on the clustree? I'm stumped because the labels are not an aggregate of a metadata column but rather computed independently.

lazappi commented 1 year ago

Unfortunately, I don't think this is possible using the functions as they are currently implemented because your labels would need to be added as node (rather than sample) attributes which currently isn't possible.

I think the closest thing you can do at the moment would be to use clustree(x, ..., return="graph"/"layout"). This would give you either a tbl_graph object or a {ggraph} layout object which you should be able to add the node attributes to relatively easily. The tricky part then would be plotting, which would need to be done manually because there is no separate plotting function (copy/pasting from the clustree() function should mostly work though).

There is a long-fabled update to {clustree} to change the interface and make this kind of thing easier but I don't have the time to finish developing it at the moment.

gomeznick86 commented 1 year ago

Thanks for the answer. I thought it was a bit of a long shot but wanted to be sure. This has been a super helpful package. Thanks for sharing it!