Skip to content

Conversation

srivarra
Copy link
Contributor

@srivarra srivarra commented Aug 30, 2023

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

What is the purpose of this PR?

Adds a notebook that demonstrates how to generate plots for a cohort.
Adds functionality to plot a continuous variable.

For cluster mask plots, adds the ability to erode the segmentation mask boundaries to improve the readability of cells.

How did you implement your changes

Added a notebook which allows the user to plot cluster masks and continuous variables for a cohort.

Remaining issues

May have accidentally ran a formatter in the plot_utils.py file.

This branch needs to be first merged into #1030. Then that will be merged into main.

Sample Plots

fov7_colored_mask

fov7_cluster_mask

@srivarra srivarra self-assigned this Aug 30, 2023
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@srivarra srivarra changed the base branch from main to masks/generation August 30, 2023 22:44
@srivarra srivarra requested a review from alex-l-kong August 30, 2023 23:27
@srivarra srivarra assigned camisowers and unassigned camisowers Aug 30, 2023
@srivarra srivarra requested a review from camisowers August 30, 2023 23:27
@srivarra srivarra marked this pull request as ready for review August 30, 2023 23:27
@srivarra srivarra marked this pull request as draft August 30, 2023 23:27
@srivarra
Copy link
Contributor Author

Not sure why the other checks (testing, building) are not being displayed. They are running here: https://github.com/angelolab/ark-analysis/actions/runs/6030848048?pr=1030

@srivarra srivarra added the enhancement New feature or request label Aug 30, 2023
@srivarra srivarra marked this pull request as ready for review August 30, 2023 23:29
Copy link
Contributor

@camisowers camisowers left a comment

Choose a reason for hiding this comment

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

Code looks good but a couple general comments.

  1. There seems to be some visualizations missing from the two LDA and the fiber segmentation notebooks.
  2. Also the multicolored borders on the example plot you posted can be removed by setting interpolation=None. (#967) I see it's included for the non-continuous plotting, but is it working when saving the images?

@srivarra
Copy link
Contributor Author

srivarra commented Aug 31, 2023

@camisowers

  1. There seems to be some visualizations missing from the two LDA and the fiber segmentation notebooks.

Yeah I see they got cut off.

  1. Also the multicolored borders on the example plot you posted can be removed by setting interpolation=None. (plot_neighborhood_cluster_result has multiple colors per cell #967) I see it's included for the non-continuous plotting, but is it working when saving the images?

Ah, it has to be the string "none" not the value None /:

alex-l-kong and others added 3 commits August 31, 2023 18:07
…xie (#1051)

* Drop cells without any SOM cluster expressions

* Add testing for dropping non-expressed cells
* Ensure mantis can read the image sub folder specified

* Test on example dataset

* Default img_sub_folder to None in create_mantis_dir (standard used elsewhere)

* Doc fix and updated example dataset

* Update segmentation labels again

* Clarify img_sub_folder (mostly for refreshing tests)

* Force .github/get_example_dataset.py to use updated revision

* Update the file names to look for
@srivarra srivarra requested a review from camisowers August 31, 2023 21:20
camisowers and others added 10 commits September 12, 2023 17:44
* pin to 0.19.3

* requirement less than 0.19.3
…o helper functions (#1058)

* Propagate overwrite functionality for pixel clustering

* Ensure re-normalization prevented on overwrite for pixel SOM re-assignment

* normalize_data should be the opposite of overwrite
* single mantis dir, no recopying

* post clustering mask suffix

* generic clustering adjustments

* mask prefix

* remove mask prefix
@srivarra srivarra requested a review from ngreenwald September 14, 2023 17:37
Copy link
Member

@ngreenwald ngreenwald 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!

@@ -246,7 +247,7 @@ def calculate_fiber_alignment(fiber_object_table, k=4, axis_thresh=2):
# find index for smallest distances, excluding itself
indy = fiber_dist_mat[indx, :].argsort()[1:1+k]
neighbor_angles = filtered_lengths.orientation[indy]
fiber_scores.append(1 / (np.sqrt(np.sum((neighbor_angles - angle) ** 2)) / k))
Copy link
Member

Choose a reason for hiding this comment

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

How come this was changed?

Copy link
Contributor Author

@srivarra srivarra Sep 14, 2023

Choose a reason for hiding this comment

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

In the function color_fibers_by_stat we take the inverse of the alignment score again in order to plot it. Cami suggested that we just remove the inversion entirely.

@@ -854,7 +854,7 @@
" xr_channel_names=None,\n",
Copy link
Member

@ngreenwald ngreenwald Sep 14, 2023

Choose a reason for hiding this comment

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

Line #11.        plot_utils.plot_pixel_cell_cluster(

You should check with Candace if she wants this to default to erode=True or False. I think the cell masks look better eroded.


Reply via ReviewNB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got Candace's approval for cell mask erosion in the Pixie Pipeline notebooks.

@review-notebook-app
Copy link

review-notebook-app bot commented Sep 14, 2023

View / edit / reply to this conversation on ReviewNB

ngreenwald commented on 2023-09-14T18:11:03Z
----------------------------------------------------------------

We should clear this output


@review-notebook-app
Copy link

review-notebook-app bot commented Sep 14, 2023

View / edit / reply to this conversation on ReviewNB

ngreenwald commented on 2023-09-14T18:11:06Z
----------------------------------------------------------------

Does the example dataset cell table have multiple different clustering columns? Or just one? If it has multiple, we should use the one that has broader cell type definitions, so there are fewer different clusters


srivarra commented on 2023-09-14T18:45:07Z
----------------------------------------------------------------

I believe there is only one metacluster column.

@review-notebook-app
Copy link

review-notebook-app bot commented Sep 14, 2023

View / edit / reply to this conversation on ReviewNB

ngreenwald commented on 2023-09-14T18:11:07Z
----------------------------------------------------------------

Looks great


Copy link
Contributor Author

I believe there is only one metacluster column.


View entire conversation on ReviewNB

@srivarra srivarra requested a review from ngreenwald September 15, 2023 23:56
@ngreenwald ngreenwald merged commit b3ebaa0 into masks/generation Sep 17, 2023
@ngreenwald ngreenwald deleted the masks/notebook branch September 17, 2023 20:50
ngreenwald pushed a commit that referenced this pull request Sep 18, 2023
* plot_cluster

Next Release v0.6.4 (#1012)

* 0.6.4

* updated environment.yml

* Update README.md

* updated windows setup docs

* added repo verison in git clone

* file fix

Deepcell upload loop cleaning (#1023)

* loop check for successful deepcell upload

* update test zip paths

* helper functions pls

* zip input, upload, and extract per batch

* cleaning

* docstring indent

* fov -> fovs file name

* remove overwrite warning

* new dir for each test call

* fix bad logic warning testing

* remove arg from docstring

* add helper function test

* batch_num start at 1

* add previously processed warning

* set timeouts and scrap retry

* correct timeout errors and update tests

* timeout 5 mins

* add to unprocessed list after loop closes

* continue loop after extraction

* break instead of continue

* skipped processing print fixes

* adjust print statements

* 3 seconds before second zip call

update

* updated readthedocs python version

* updated plot_utils docstring

* docstrings v2

* use GS [1,1] if cbar_visible is False, otherwise use GS [1, 2] for plot + colorbar

* added cbar_visible T/F for tests

* pycodestyle

* added numpy list to cmap / norm function

* Remove cells that don't have any pixel clusters expressed prior to Pixie (#1051)

* Drop cells without any SOM cluster expressions

* Add testing for dropping non-expressed cells

* Include `img_sub_folder` as parameter in Mantis calls (#1050)

* Ensure mantis can read the image sub folder specified

* Test on example dataset

* Default img_sub_folder to None in create_mantis_dir (standard used elsewhere)

* Doc fix and updated example dataset

* Update segmentation labels again

* Clarify img_sub_folder (mostly for refreshing tests)

* Force .github/get_example_dataset.py to use updated revision

* Update the file names to look for

* Update HuggingFace version (#1053)

* v0.1.10 (#1057)

* Pin to scikit-image to v0.19.3 (#1060)

* pin to 0.19.3

* requirement less than 0.19.3

* Make sure overwrite functionality for pixel clustering propagates into helper functions (#1058)

* Propagate overwrite functionality for pixel clustering

* Ensure re-normalization prevented on overwrite for pixel SOM re-assignment

* normalize_data should be the opposite of overwrite

* Single mantis directory (#1061)

* single mantis dir, no recopying

* post clustering mask suffix

* generic clustering adjustments

* mask prefix

* remove mask prefix

* Mass plotting notebook (#1052)

* added plotting notebook

* updated readmed

* git merge issues

* git merge fixes v2 - docs/landing.md

* type

* Remove cells that don't have any pixel clusters expressed prior to Pixie (#1051)

* Drop cells without any SOM cluster expressions

* Add testing for dropping non-expressed cells

* Include `img_sub_folder` as parameter in Mantis calls (#1050)

* Ensure mantis can read the image sub folder specified

* Test on example dataset

* Default img_sub_folder to None in create_mantis_dir (standard used elsewhere)

* Doc fix and updated example dataset

* Update segmentation labels again

* Clarify img_sub_folder (mostly for refreshing tests)

* Force .github/get_example_dataset.py to use updated revision

* Update the file names to look for

* fixed clipped plots in the notebooks.

* Update HuggingFace version (#1053)

* v0.1.10 (#1057)

* Added continuous variable segmentation plots

* Pin to scikit-image to v0.19.3 (#1060)

* pin to 0.19.3

* requirement less than 0.19.3

* Make sure overwrite functionality for pixel clustering propagates into helper functions (#1058)

* Propagate overwrite functionality for pixel clustering

* Ensure re-normalization prevented on overwrite for pixel SOM re-assignment

* normalize_data should be the opposite of overwrite

* Single mantis directory (#1061)

* single mantis dir, no recopying

* post clustering mask suffix

* generic clustering adjustments

* mask prefix

* remove mask prefix

* strange merge issue

* removed branch filters on CI, so if you branch off of a branch and run GHA, the CI workflow should work

* changed ci.yml, filter push on main branch only

* python 3.9 doesn't support | for Union type overloading

* added fovs parameter for continuous variable plots

* updated notebook to include plots

* updated cell clustering notebooks to add erosion (default to True), cleaned up some notebook outputs

* fixed style imports

* re-added test_generate_summary_stats. Was accidently deleted in a refactoring step.

* newline at eof fiber_segmentation_test.py

* seaborn-paper -> seaborn-v0_8-paper

* added cell to view all plotting styles i mask gen nb

* pycodestyle

---------

Co-authored-by: alex-l-kong <31424707+alex-l-kong@users.noreply.github.com>
Co-authored-by: camisowers <38049893+camisowers@users.noreply.github.com>

* default ero

* added erode=True for generate_cluster_mask

---------

Co-authored-by: alex-l-kong <31424707+alex-l-kong@users.noreply.github.com>
Co-authored-by: camisowers <38049893+camisowers@users.noreply.github.com>
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.

4 participants