Open mschilli87 opened 7 years ago
Hi Marcel,
Thanks for bringing up this issue! It seems like extracting the dendrogram and / or the cluster assignments is likely a general feature that would be useful to include in the package with a dedicated method.
In the meantime, a simpler (but still hacky!) solution for your example:
plots(hm)[["Row<br>Clusters"]]@data
will return what you're looking for.
Currently there is a get_data
method that is not exported (only available using iheatmapr:::get_data, although using ::: isn't really better than using @
), that would help with not having to use @
. I think it may be a good idea to export that method, although I think an additional method specifically for pulling out cluster information would also be a useful addition to the package, as I imagine that is the type of data that one would be most interested in pulling out of the object. I will hopefully get a chance to add such a method in the next few days.
Cheers, Alicia
Thanks a lot for your fast feedback.
Another main concern with any solution so far is the need to know the name/label of the row cluster colorbar ("Row<br>Clusters"
in this case).
An ideal solution would also work when name = "gene cluster"
was passed to add_row_clustering
.
Dear Alicia,
First of all, thanks for this nice package.
I have a question on how to extract cluster assignment from an
Iheatmap-class
object.Lets consider the following example:
Printing
hm
, I get a nice interactive heatmap with the rows clustered into three groups.My question is how can I extract the information which row (car is this case) belongs to which cluster.
The best I came up with so far ist the following:
This way,
clusters
is assigned an integer vector with the cluster assignment named by the corresponding row labels.However, I see two issues with this approach:
cutree
.@
tells me there ~must~ should be a better way to achieve what I want.The first point could be resolved by recovering the number of row clusters from the
Iheatmap-class
object itself.The best way to do so I found is the following:
Unfortunately, this emphasizes the second point I made above by seaming even more 'hacky'.
I would highly appreciate any feedback feedback on how to get from
hm
toclusters
without an ugly wrapper function based on the above hacks.Best regards, Marcel