Plot graph of points with known inter distances

Click For Summary
SUMMARY

The discussion focuses on plotting clusters in a Cartesian system based on known Euclidean inter-distances between their centroids. The proposed solution involves positioning one centroid at the origin (0,0) and placing others along the x-axis according to their distances. To achieve the correct arrangement of centroids, the law of cosines is utilized to calculate the angles for their circular positioning. Matrix calculations may also be necessary to solve the equations derived from these distances.

PREREQUISITES
  • Understanding of Euclidean distance calculations
  • Familiarity with the law of cosines
  • Basic knowledge of matrix operations
  • Experience with spreadsheet software like Excel for formula implementation
NEXT STEPS
  • Research "law of cosines in triangle geometry" for distance calculations
  • Learn about "matrix transformations in coordinate systems" for centroid positioning
  • Explore "Excel formulas for distance calculations" to implement the solution in a spreadsheet
  • Investigate "graph plotting libraries in Python" for coding the visualization of clusters
USEFUL FOR

Biochemists, bioinformaticians, data scientists, and anyone involved in visualizing spatial relationships between clusters based on distance metrics.

noplacebos
Messages
2
Reaction score
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.
 
Last edited:
Physics news on Phys.org
If I may add a less abstract example, I see the whole problem as having a list of furniture that exist in a 2D room, and I am given all their respective inter distances,

eg I know how far away the couch lies from the armchair, the TV set, the lounge table, etc.,

then how far away the armchair is from the TV set and the lounge table,

and finally the distance between the TV set and the table.

What I need is to draw this room with all furniture correctly positioned (of course we don't care about room dimensions as this is just an example), i.e. their correct relative locations.

Thanks
 

Similar threads

Replies
3
Views
2K
  • · Replies 9 ·
Replies
9
Views
897
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
5
Views
2K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
20
Views
4K