Skip to content

Conversation

camisowers
Copy link
Contributor

@camisowers camisowers commented Nov 7, 2023

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

What is the purpose of this PR?

  1. Closes Erosion and size of plot_pixel_cell_cluster output #1075.
    Make minor tweaks to Pixie notebooks regarding plotting output.

  2. Closes Incorrect cell cluster mapping in mantis #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.

@camisowers camisowers added the bug Something isn't working label Nov 7, 2023
@camisowers camisowers self-assigned this Nov 7, 2023
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.

Looks good to me!

@alex-l-kong alex-l-kong self-requested a review November 22, 2023 21:47
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 requested a review from cliu72 November 27, 2023 18:14
Copy link
Contributor

@cliu72 cliu72 left a comment

Choose a reason for hiding this comment

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

Just a few small things:

  • The size of the actual plots look much better, but the font is now weirdly big. Are you seeing this on your machine too?
    image
  • Maybe this doesn't belong here (and could be it's own issue), but I noticed it while I was reviewing this. post_cluster_utils.create_mantis_project isn't ever used for pixel clustering (seems like it's only used in 4_Post_Clustering.ipynb to look at cell clusters). I think it's confusing to have cluster_type as a parameter (since it will never be set to pixel). Actually, I don't think it would work if cluster_type were ever set to pixel, because "pop_vals" would be changed to cluster_id (line 159), which is not the right nomenclature for the pixel clustering table. I think it'd be better to just remove cluster_type at all and assume this function will only be used for cells. Also in the create_mantis_project function, I don't understand why small_table is needed (line 119), since it's going to be fed into ClusterMaskData, which is able to be created directly from the cell table.

@camisowers
Copy link
Contributor Author

camisowers commented Dec 1, 2023

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.

Copy link
Contributor

@cliu72 cliu72 left a comment

Choose a reason for hiding this comment

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

Changes look good to me! I was actually using a Linux machine to look at the image before, but I just tried on my windows machine and it also looks weird. I wonder if it's a screen resolution thing.

Can you try if dpi=150 and figsize=(5,5) looks okay on your machine? If it looks like not too crazy, maybe we can set that as the default. That looks good for both Linux and Windows for me.

Also, I think it would be good to add dpi as a parameter in the notebook so people easily know they change it, and also add text telling them to change these values if it looks weird. So like to the pixel clustering notebook, after "Load a subset of the pixel cluster masks that you would like to preview." add "If the dimensions or text size of the plot need to be adjusted for optimal viewing, change the dpi and figsize parameters." And same thing to the cell clustering notebook.

@camisowers camisowers requested a review from cliu72 December 11, 2023 19:11
@camisowers
Copy link
Contributor Author

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

Copy link
Contributor

@cliu72 cliu72 left a comment

Choose a reason for hiding this comment

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

Looks great!

@camisowers camisowers added this pull request to the merge queue Dec 12, 2023
Merged via the queue into main with commit e0906eb Dec 12, 2023
@camisowers camisowers deleted the cell_mask_mantis_id branch December 12, 2023 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect cell cluster mapping in mantis Erosion and size of plot_pixel_cell_cluster output
4 participants