- #1
- 3
- 0
Greetings,
I am a biochemist/bioinformatician. I have a bunch of clusters, of which I have already calculated all their respective (euclidean) inter distances, from centroid to centroid.
I need to plot a graph with these clusters for visual inspection and publication.
My problem is how to calculate the coordinates of each clusters' centroid in a classic cartesian system, in order to properly display a "map" of cluster distances.
Each cluster's centroid should show as a single point on the graph - I will worry about representing each cluster's irregular shape later...
I am sure this is a trivial problem, but didn't have the chance to work with this before. So, by putting the problem down onto paper, I figured that one way to solve this (algorithmically) is by positioning the centroid of one cluster at the origin (0,0) and position all other centroids onto the x axis, each at its respective known distance from the first centroid at (0,0).
Then, all the centroids should make a circular move of angle phi around the origin, in order to adopt the position that satisfies all their known inter-distances.
In the end, we should obtain a cicle with radius equal to the most distant centroid from the one placed at the origin, and all the other centroids scattered within.
It appears to me that a huge set of equations of the form (law of cosines):
a^2 = b^2 + c^2 - 2bc*cosA
would need to be solved, in order to obtain all the correct angles that a specific centroid would need to "rotate" to assume its appropriate position.
In the above formula, "a" is the distance between centroids B and C, while b and c are the distances from the origin for B and C, respectively.
This looks to me like a job that includes some Matrix calculations, but couldn't find exactly what I am looking for, so far.
I would be grateful if you could point me at some direction so to continue my reading with regards to this problem.
Thank you very much in advance
PS. A way to achieve this with the use of some spreadsheet formula (eg excel) is desirable, although I would also like to understand the concept to the solution, in case I had to implement some kind of code.
I am a biochemist/bioinformatician. I have a bunch of clusters, of which I have already calculated all their respective (euclidean) inter distances, from centroid to centroid.
I need to plot a graph with these clusters for visual inspection and publication.
My problem is how to calculate the coordinates of each clusters' centroid in a classic cartesian system, in order to properly display a "map" of cluster distances.
Each cluster's centroid should show as a single point on the graph - I will worry about representing each cluster's irregular shape later...
I am sure this is a trivial problem, but didn't have the chance to work with this before. So, by putting the problem down onto paper, I figured that one way to solve this (algorithmically) is by positioning the centroid of one cluster at the origin (0,0) and position all other centroids onto the x axis, each at its respective known distance from the first centroid at (0,0).
Then, all the centroids should make a circular move of angle phi around the origin, in order to adopt the position that satisfies all their known inter-distances.
In the end, we should obtain a cicle with radius equal to the most distant centroid from the one placed at the origin, and all the other centroids scattered within.
It appears to me that a huge set of equations of the form (law of cosines):
a^2 = b^2 + c^2 - 2bc*cosA
would need to be solved, in order to obtain all the correct angles that a specific centroid would need to "rotate" to assume its appropriate position.
In the above formula, "a" is the distance between centroids B and C, while b and c are the distances from the origin for B and C, respectively.
This looks to me like a job that includes some Matrix calculations, but couldn't find exactly what I am looking for, so far.
I would be grateful if you could point me at some direction so to continue my reading with regards to this problem.
Thank you very much in advance
PS. A way to achieve this with the use of some spreadsheet formula (eg excel) is desirable, although I would also like to understand the concept to the solution, in case I had to implement some kind of code.
Last edited: