mod: node vs edge centrality based euklidian distance calculation
This commit is contained in:
+14
-14
@@ -38,18 +38,18 @@ def spatial_graph(adata):
|
||||
|
||||
def apply(g, seed, weight, convex_hull, ax, ax2, method):
|
||||
# calculate centrality values
|
||||
vp, ep = method(g, weight=weight)
|
||||
ep.a = np.nan_to_num(ep.a) # correct floating point values
|
||||
min_val, max_val = ep.a.min(), ep.a.max()
|
||||
ep.a = (ep.a - min_val) / (max_val - min_val)
|
||||
vp = method(g, weight=weight)
|
||||
vp.a = np.nan_to_num(vp.a) # correct floating point values
|
||||
min_val, max_val = vp.a.min(), vp.a.max()
|
||||
vp.a = (vp.a - min_val) / (max_val - min_val)
|
||||
|
||||
# euklidian distance
|
||||
quantification = plot.quantification_data(g, ep, convex_hull)
|
||||
quantification = plot.quantification_data(g, vp, convex_hull)
|
||||
plot.quantification_plot(ax, quantification, None, None, "Euklidian Distance", None)
|
||||
|
||||
# generate model based on convex hull and associated centrality values
|
||||
# path distance
|
||||
quantification = plot.quantification_data_path_distance(g, weight, ep, convex_hull)
|
||||
# path distance (node based centrality)
|
||||
quantification = plot.quantification_data_node_path_distance(g, weight, vp, convex_hull)
|
||||
plot.quantification_plot(ax2, quantification, None, None, "Shortest Path Distance", None)
|
||||
|
||||
|
||||
@@ -63,13 +63,13 @@ fig = plt.figure(figsize=(21, 5))
|
||||
ax1, ax2, ax3 = fig.subplots(1, 3)
|
||||
|
||||
# plot graph with convex_hull
|
||||
vp, ep = betweenness(g, weight=weight)
|
||||
ep.a = np.nan_to_num(ep.a) # correct floating point values
|
||||
min_val, max_val = ep.a.min(), ep.a.max()
|
||||
ep.a = (ep.a - min_val) / (max_val - min_val)
|
||||
vp = closeness(g, weight=weight)
|
||||
vp.a = np.nan_to_num(vp.a) # correct floating point values
|
||||
min_val, max_val = vp.a.min(), vp.a.max()
|
||||
vp.a = (vp.a - min_val) / (max_val - min_val)
|
||||
|
||||
plot.graph_plot(fig, ax1, g, ep, convex_hull, f"Pointcloud (seed: {seed})", True)
|
||||
plot.graph_plot(fig, ax1, g, vp, convex_hull, f"Pointcloud (seed: {seed})", False)
|
||||
|
||||
apply(g, seed, weight, convex_hull, ax2, ax3, betweenness)
|
||||
apply(g, seed, weight, convex_hull, ax2, ax3, closeness)
|
||||
|
||||
fig.savefig(f"Distance_5000_betweenness_edge_euklidian.svg", format='svg')
|
||||
fig.savefig(f"Distance_5000_node_closeness.svg", format='svg')
|
||||
|
||||
Reference in New Issue
Block a user