Skip to content
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

Merged
merged 4 commits into from
Oct 4, 2024

Conversation

camisowers
Copy link
Contributor

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

@camisowers camisowers added the enhancement New feature or request label Sep 30, 2024
@camisowers camisowers self-assigned this Sep 30, 2024
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link
Contributor

@srivarra srivarra left a 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(
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

Copy link
Contributor

@alex-l-kong alex-l-kong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@camisowers camisowers added this pull request to the merge queue Oct 4, 2024
Merged via the queue into main with commit cb8ccdb Oct 4, 2024
17 of 18 checks passed
@camisowers camisowers deleted the dist_mats_from_table branch October 4, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use cell table as input for calc_dist_matrix()
3 participants