-
Notifications
You must be signed in to change notification settings - Fork 25
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
Update distance matrix to xarray type #200
Conversation
…ype of distance matrix to xarray
Not liking having to specify a dict of coordinates for calc_dist_matrix to work properly, that'll be the biggest point to look at for the upcoming code review. |
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.
Good first pass. Mostly suggesting some optimizations.
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.
Awesome work. I think we can completely remove the dict of coords passed in; let me know if I missed something.
Remaining coverage issues due to lack of plot_utils and segmentation_utils testing. Also, @ngreenwald just saw your comment about changing the underlying FOVs of data to be strings, that'll be addressed on my next push. |
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 really good! Just one doc-string fix
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.
Awesome stuff, minor tweaks
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 very good to me, good job!
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.
Everything looks good! Is there any reason we need to keep the old version of the expression matrix and segmentation labels in the master branch?
I'll remove those and re-request. |
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.
Awesome
* Fix randomization error in synthetic spatial gen and begin updating type of distance matrix to xarray * Update notebooks and spatial_analysis_utils functions to handle xarray data type for distance matrices * Forgot to change spatial analysis script outside of Docker * Further integration * Fix closenum tests * Address minor changes (aka other than dict passing) * Fix centroid labelling with prop.label, which makes life hella easier * Change Erin's data and adjust accordingly * Pycodestyle and xarray import crap * Last fixes * Update expression matrix, calc_dist_matrix, and notebook to reflect string-only fov indexing * Forgot to add new segmentation labels * Change list to .values for indexing purposes * Break up logic and update comments * Fix summing error in closenum random * Remove old data files
* Fix randomization error in synthetic spatial gen and begin updating type of distance matrix to xarray * Update notebooks and spatial_analysis_utils functions to handle xarray data type for distance matrices * Forgot to change spatial analysis script outside of Docker * Further integration * Fix closenum tests * Address minor changes (aka other than dict passing) * Fix centroid labelling with prop.label, which makes life hella easier * Change Erin's data and adjust accordingly * Pycodestyle and xarray import crap * Last fixes * Update expression matrix, calc_dist_matrix, and notebook to reflect string-only fov indexing * Forgot to add new segmentation labels * Change list to .values for indexing purposes * Break up logic and update comments * Fix summing error in closenum random * Remove old data files
What is the purpose of this PR?
Addresses and closes #191. The problem with our current distance matrix implementation is that it's not flexible. In other words, we have to assume that indices correspond to their respective cell labels. This is a limitation of numpy arrays for distance matrices. Using xarrays, we can assign more flexible indices.
How did you implement your changes
The bulk of the changes involve updating calc_dist_matrix and the indexing into distance matrices elsewhere in the spatial analysis code. We change the return type of calc_dist_matrix to xarray and add an indices argument to allow the passage of a set of indices for each fov which correspond to the cell labels. In this way, we do not have to worry about misordering of a distance matrix nor do we have to spend time to reindex the numpy array.
Indexing into a dist_matrix in xarray format will now use the .loc format.
Remaining issues
Specifically, the biggest issue is making sure our indexing is correct. There are many places where we use numpy functions on distance matrices and these might need to be updated for xarray usage/reindexing.