-
Notifications
You must be signed in to change notification settings - Fork 26
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
Matrix distance to scatter plot #20
Comments
Hi Judith! Let me try to help :) Could you attach some example code and give more details about what you are trying to plot? From my understanding, you have some conformers (for the same/different molecules?) and have clustered them into two clusters and want to visualise the poses. What are the axes of the scatter plot you are trying to do? Are they just PCA axes or something like that? |
Hello, I have a portein on which I have docked a ligand with Autodock Vina. Vina has generated several possible ligand poses (my different conformers). I have drawn a distance matrix between each conformation. I would then like to group them in a cluster via a kmeans. I succeeded in making the kmeans and I see the scatter plot of my ligands. Yes I want to visualize the positions with the names on the dots. But as I can't add the name. Therefore I don't know which is which on the figure I send you :
(KEEEP you need to change .txt by .sdf For the script .txt by .ipybd Thanks, |
The easiest way to add the 'names' of the molecules would be to to add the pose index as a column in the import plotly.express as px
table['pose_index'] = [f'Molecule Index: {index}' for index in table.index]
table['cluster'] = kmeans.labels_
table['cluster'] = table['cluster'].astype(str)
px.scatter(table,
x="1",
y="2",
color='cluster',
hover_name='pose_index',
width=1000,
height=800) which would look something like this: I have also modified the molplotly code a bit to show the actual 3D coordinates as well, but I'm not sure how helpful that would be: Let me know if that would be helpful and I can merge it into the package :) |
Dear William, Thank you very much, that's it ! But is there an option to add the centroid of clusters ? Best ! |
Yes, the 3D option is also interesting ! The last but not least, do you know increase the size of the dots, when I try "size", I don't see de arguments format, size=10 or size=10:10:20 don't work Best ! |
So so sorry for not replying, I had totally missed your follow-up questions! In any case, here are some answers:
This can be done by adding
This can be done via import plotly.graph_objects as go
rmsd_df['pose_index'] = range(1, len(renamed_poses)+1)
rmsd_df['cluster'] = kmeans.labels_
rmsd_df['cluster'] = rmsd_df['cluster'].astype(str)
scatter_fig = px.scatter(rmsd_df,
x="1",
y="2",
color='cluster',
hover_name='pose_index',
width=1000,
height=800,
title='Clustering of ligand poses',
labels={'1':'RMSD to pose 1',
'2':'RMSD to pose 2',}
)
scatter_fig.add_trace(
go.Scatter(
x = kmeans.cluster_centers_[:,0],
y = kmeans.cluster_centers_[:,1],
mode='markers',
marker=dict(color="red",
symbol='x',
size=10),
showlegend=False,))
scatter_fig.update_traces(marker=dict(size=12)) |
On another note, would you mind if I use your code/data as an example for showing the plotting of 3D coordinates with |
Hello everyone,
My name is Judith and for my PhD studies, I would like to use your beautiful scripts.
I get a distance matrix by rmsd between each pose but I don't see how to pass it to a scatter plot of 2 clusters, I tried with pandas but I'm really blocked, I can't select the lines and the columns to generate the scatter plot
Best Regards,
Judith
The text was updated successfully, but these errors were encountered: