-
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
Distance table generation without segmentation masks #1159
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a file format question.
centroid_labels = [prop.label for prop in props] | ||
# get centroid and label info | ||
centroids = [(row[centroid_ids[0]], row[centroid_ids[1]]) for indx, row in fov_table.iterrows()] | ||
centroid_labels = list(fov_table[label_id]) | ||
|
||
# generate the distance matrix, then assign centroid_labels as coords | ||
dist_matrix = cdist(centroids, centroids).astype(np.float32) | ||
dist_mat_xarr = xr.DataArray(dist_matrix, coords=[centroid_labels, centroid_labels]) | ||
|
||
# save the distance matrix to save_path | ||
dist_mat_xarr.to_netcdf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know this was netcdf, do you want to keep it as that file format, or switch it to zarr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it for now, since storing the individual dist mats isn't necessary anyways once we switch to anndata for the spatial outputs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
If you haven't already, please read through our contributing guidelines before opening your PR
What is the purpose of this PR?
Closes #1154. Calculate the distance matrices for the spatial scripts using just the cell table as input.
How did you implement your changes
Pull the cell centroids from the cell table and feed them into
cdist()
.Remaining issues
N/A