Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kmeans clustering when using ClusterMapPlotter function #24

Open
Xinfeng-Yao opened this issue Mar 30, 2023 · 9 comments
Open

Kmeans clustering when using ClusterMapPlotter function #24

Xinfeng-Yao opened this issue Mar 30, 2023 · 9 comments

Comments

@Xinfeng-Yao
Copy link

Will the Pycomplexheatmap support Kmeans clustering when using ClusterMapPlotter function. I just mean that first use Kmeans to form different goups, then run hierarchical clustering within each group, finally hierarchically cluster different groups. The R package complexheatmap support the process.
Thanks!

@DingWB
Copy link
Owner

DingWB commented Mar 30, 2023

This is a good suggestion.
But unfortunately, it is not supported now. I will add it to PyComplexHeatmap soon.
As for now, you can perform K-means clustering using sklearn and then reorder the rows and columns according to the clusterings from K-means. Finally, when you call ClusterMapPlotter, turn off the row_cluster and col_cluster and set parameters row_split and col_split (optional).

@ftamiro
Copy link

ftamiro commented Sep 29, 2023

I am interested in this as well, in the R package I used cluster_columns= cluster_within_group(), it is great not only for grouping by kmeans or any other clustering annotation but also for clinical metadata such as maturation stage of the tumor, etc. Looking forward to seeing this implemented in PyComplexHeatmap.

@DingWB
Copy link
Owner

DingWB commented Sep 29, 2023

I am not quite sure what you mean, could you please make it more specific?

@ftamiro
Copy link

ftamiro commented Oct 2, 2023

Sure, here is an image where I used R ComplexHeatmap as an example in RNA-seq plus clinical metadata from a cancer dataset.

image

Here I used inside the main Heatmap() function, the cluster_columns= cluster_within_group(mat, groups), see the last bloc of features. In this analysis, 'groups' are the molecular groups assigned to patients from the original study, not something I calculated. This option allows me to consider these blocks and cluster them with hierarchical clustering. In other instances, I can use precalculated kmeans or any other clustering or feature I want to obtain a similar result.

I am building a cancer explorer web app and this option is crucial for my visualization

@DingWB
Copy link
Owner

DingWB commented Oct 2, 2023

I see. I will work on it when I have time.
For now, you can perform clustering yourself and pass the clustered order to PyComplexHeatmap as row_split_order or col_split_order.

@DingWB
Copy link
Owner

DingWB commented Oct 2, 2023

Would you like to contribute to this package by implementing this function? @ftamiro

@ftamiro
Copy link

ftamiro commented Oct 4, 2023

I am already trying to replicate this function in Python. This could require more skills than what I have now, but if I manage to get something useful, I would like to contribute

@DingWB
Copy link
Owner

DingWB commented Oct 4, 2023

Please let me know if you have any questions during the development.

@DingWB
Copy link
Owner

DingWB commented Oct 7, 2023

Hello Francesco, I have already implemented the cluster_between_groups (https://dingwb.github.io/PyComplexHeatmap/build/html/notebooks/advanced_usage.html#Cluster-between-groups) and moved this discussion to #53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants