Closed lnelllwj closed 11 months ago
The second photo is this. I pushed same photos.
Hi, yes the code snippet was faulty. I revised it now and will push.
#Sample snippet to show centroid conncetions
import matplotlib.pyplot as plt
row_borders = np.array([3, 5, 7])
rowwise_peaks = np.array([3, 2, 3])
max_gap = 2
score = np.full((3,3, max_gap), np.inf)
connections = np.full((3,3, max_gap), -1)
centroids = np.array([10, 20, 30,
10.2, 20,
10, 30, 40])
centroid_tol = 0.5*1e5
from_idx, to_idx, score_median, score_std = connect_centroids(rowwise_peaks, row_borders, centroids, max_gap, centroid_tol)
scan_no = np.array([0, 0, 0,
1, 1,
2, 2, 2])
print(f'Centroid Connections from {from_idx} to {to_idx}')
plt.figure(figsize=(5,5))
colors = ['r','g','b']
for x,y in zip(centroids, scan_no):
plt.plot(x, y, '.', color=colors[y])
for i, _ in enumerate(from_idx):
from_ = _
to_ = to_idx[i]
plt.plot([centroids[from_], centroids[to_]], [scan_no[from_], scan_no[to_]], 'k:')
plt.ylabel('scan')
plt.xlabel('m/z')
plt.ylim(len(row_borders)+1.5, -1.5)
plt.title('Peak connections')
plt.show()
and should give this plot:
There is an sample below "convert_connections_to_array" on the "https://mannlabs.github.io/alphapept/feature_finding.html". The result of connections that is "centroids = np.array([10, 20, 30, 10.2, 20, 10, 30, 40])" is "from_idx=[0, 1, 2], to_idx=[3, 4, 6]" in your page. I think the right result is "from_idx=[0, 1, 2, 3], to_idx=[3, 4, 6, 5]". Is my inderstanding wrong?