angelolab / ark-analysis

Integrated pipeline for multiplexed image analysis
https://ark-analysis.readthedocs.io/en/latest/
MIT License
70 stars 25 forks source link

Fix cell cluster visualization in Mantis #1083

Closed camisowers closed 8 months ago

camisowers commented 9 months ago

If you haven't already, please read through our contributing guidelines before opening your PR

What is the purpose of this PR?

  1. Closes #1075. Make minor tweaks to Pixie notebooks regarding plotting output.

  2. Closes #1082. Ensure that the correct integer IDs are mapped to each cell cluster name in Mantis viewer.

How did you implement your changes

  1. The erode parameter in plot_utils.plot_pixel_cell_cluster() is defaulted to True. Since it is also explicitly set to True in both the pixie cell clustering and generic cell clustering notebooks, we can just set the default to False to remove it from the pixel clustering output.

  2. Adjust the data_utils.generate_and_save_cell_cluster_masks() function to update the cell_meta_cluster_mapping.csv at the same time it generates new integer IDs for the cell cluster masks. The new 'cluster_id' column is then read into plot_utils.create_mantis_dir() instead of the outdated 'cell_meta_cluster' values; this allows an accurate cell cluster mapping file to be generated and uploaded into mantis viewer.

Remaining issues

None. This bug had no effect on the cell table, since only the cluster name (not the integer ID) is stored there. Post-clustering is also not an issue, since a custom integer mapping is created in the create_mantis_project() function.

review-notebook-app[bot] commented 9 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

camisowers commented 9 months ago

3x3 looks fine on my end, but will you try 4x4 and see if that's better? Could be a windows thing, but if it helps we can just change it.

Screenshot 2023-11-30 at 6 55 23 PM

I agree we can just get rid of the cluster_type arg from create_mantis_project() (I think it was just a copy over from create_mantis_dir()) and is unnecessary.

The small_table is needed because new clusters can be create in the post clustering notebook, and the original mapping from the cell clustering gui no longer is accurate for these masks when making the mantis directory. We need to create a new mapping and this subsetted cell table is also just easier to pass into ClusterMaskData than the whole cell table.

camisowers commented 8 months ago

@cliu72 5x5 with dpi=150 looks great on my end! Once you approve I can merge it in.