-
Notifications
You must be signed in to change notification settings - Fork 0
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
Spatial transcriptomics #52
Open
aunoyp
wants to merge
8
commits into
master
Choose a base branch
from
spatial_transcriptomics
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e6f92c4
Update documentation and add necessary libraries
aunoyp f035a57
Prompt user for ROI dilation
aunoyp aeb1e47
Iterate through ROIs, enlarge, and crop to remove overlap
aunoyp 01ca92b
Iterate fully over all ROIs to avoid off by one error
aunoyp 47489c6
Add boolean to subtractROI to remove rectangular fit and crop clean
aunoyp 7bb3e7c
Change dilation prompt from overall pixel increase to specific distan…
aunoyp 618f6cf
Correct code chunk missing from its conditional
aunoyp 0f3bea9
Finalize review changes requested
aunoyp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,8 @@ | |
AR Dec 2021 | ||
AR Feb 2022 Edited output to keep track of distance between cells and | ||
protein/transcript expression within each cell | ||
AP May 2022 Add ROI expansion and puncta quantification for spatial | ||
transcriptomic data. | ||
''' | ||
|
||
######################################################################## | ||
|
@@ -104,6 +106,12 @@ | |
# Initialize a duplicator object | ||
duplicator = Duplicator() | ||
|
||
# Import ROI Enlarger so we can dilate nuclei segmentation | ||
from ij.plugin import RoiEnlarger | ||
|
||
# Iniitalize a roi enlarger object | ||
roienlarger = RoiEnlarger() | ||
|
||
# Import izip so we can iterate across multiple lists | ||
from itertools import izip | ||
|
||
|
@@ -333,6 +341,47 @@ | |
# Compute the area of the field of view we quantified from | ||
[field_area,field_length_units] = ROITools.getROIArea(fieldBoundROI,editedNucSeg) | ||
|
||
######################################################################## | ||
######### EXPAND ROI IF SPATIAL TRANSCRIPTOMIC DATA #################### | ||
######################################################################## | ||
|
||
# Calculate the pixel area of the image | ||
nucImpCalibration = nucImp.getCalibration() | ||
nucPixelHeight = nucImpCalibration.pixelHeight | ||
nucPixelWidth = nucImpCalibration.pixelWidth | ||
nucPixelArea = nucPixelHeight * nucPixelWidth | ||
|
||
# Round the pixel area for display | ||
roundedPixelArea = round(nucPixelArea, 4) | ||
|
||
# Prompt the user to get amount of enlargement / dilation | ||
unitIncrease = int(UIs.textFieldsUI('Specify the amount of enlargement you would like to be applied to your nuclear segmented regions of interest.', ["Pixel size in your image is {} mm sq".format(roundedPixelArea)], ["0"])[0]) | ||
|
||
# Iterate through nucROIs and dilate them by unitIncrease defined by user | ||
if(unitIncrease != 0): | ||
psgROIs = nucROIs | ||
nucROIs = [roienlarger.enlarge(nucROI,unitIncrease) for nucROI in psgROIs] | ||
|
||
# Remove resulting overlap between newly expanded ROI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For lines 365+, needs to be under if statement at 361 |
||
for i in range(len(nucROIs)): | ||
# Grab the current ROI to compare to rest of ROIs | ||
nucROI = nucROIs[i] | ||
# Get the other ROIs using a lambda filter function | ||
others = [nucROIs[j] for j in range(len(nucROIs)) if j != i] | ||
# Merge the others | ||
other = ROITools.combineROIs(others) | ||
# Get the intersection of ROIs using the intersecting function | ||
AND = ROITools.getIntersectingROI([nucROI, other]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename AND to intersection |
||
# If there is overlap, then proceed to remove it | ||
if AND.getLength() > 0: | ||
# subtract AND from nucROI | ||
croppedROI = subtractROI(nucROI, AND, fit = False) | ||
# Combine resulting ROI with original nuclear segmentation | ||
nucROIs[i] = ROITools.combineROIs([croppedROI, psgROIs[i]]) | ||
|
||
del psgROIs, croppedROI | ||
del AND, other, others, nucROI | ||
|
||
######################################################################## | ||
####################### LABEL CELLS BY CELL TYPE ####################### | ||
######################################################################## | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add description of change