-
Notifications
You must be signed in to change notification settings - Fork 68
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
2) ISS spot finding refactor #1518
Merged
Merged
Changes from all commits
Commits
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
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
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
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
45 changes: 45 additions & 0 deletions
45
starfish/core/spots/DecodeSpots/per_round_max_channel_decoder.py
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from starfish.core.codebook.codebook import Codebook | ||
from starfish.core.intensity_table.decoded_intensity_table import DecodedIntensityTable | ||
from starfish.core.intensity_table.intensity_table_coordinates import \ | ||
transfer_physical_coords_to_intensity_table | ||
from starfish.core.spots.DecodeSpots.trace_builders import build_spot_traces_exact_match | ||
from starfish.core.types import SpotFindingResults | ||
from ._base import DecodeSpotsAlgorithm | ||
|
||
|
||
class PerRoundMaxChannel(DecodeSpotsAlgorithm): | ||
""" | ||
Decode spots by selecting the max-valued channel in each sequencing round. | ||
|
||
Note that this assumes that the codebook contains only one "on" channel per sequencing round, | ||
a common pattern in experiments that assign one fluorophore to each DNA nucleotide and | ||
read DNA sequentially. It is also a characteristic of single-molecule FISH and RNAscope | ||
codebooks. | ||
|
||
Parameters | ||
---------- | ||
codebook : Codebook | ||
Contains codes to decode IntensityTable | ||
|
||
""" | ||
|
||
def __init__(self, codebook: Codebook): | ||
self.codebook = codebook | ||
|
||
def run(self, spots: SpotFindingResults, *args) -> DecodedIntensityTable: | ||
"""Decode spots by selecting the max-valued channel in each sequencing round | ||
|
||
Parameters | ||
---------- | ||
spots: SpotFindingResults | ||
A Dict of tile indices and their corresponding measured spots | ||
|
||
Returns | ||
------- | ||
DecodedIntensityTable : | ||
IntensityTable decoded and appended with Features.TARGET and Features.QUALITY values. | ||
|
||
""" | ||
intensities = build_spot_traces_exact_match(spots) | ||
transfer_physical_coords_to_intensity_table(intensity_table=intensities, spots=spots) | ||
return self.codebook.decode_per_round_max(intensities) | ||
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from starfish.core.intensity_table.intensity_table import IntensityTable | ||
from starfish.core.types import Axes, Features, SpotFindingResults | ||
|
||
|
||
def build_spot_traces_exact_match(spot_results: SpotFindingResults) -> IntensityTable: | ||
""" | ||
Combines spots found in matching x/y positions across rounds and channels of | ||
an ImageStack into traces represented as an IntensityTable. | ||
|
||
Parameters | ||
----------- | ||
spot_results: SpotFindingResults | ||
Spots found accrss rounds/channels of an ImageStack | ||
""" | ||
# create IntensityTable with same x/y/z info accross all r/ch | ||
spot_attributes = list(spot_results.values())[0] | ||
intensity_table = IntensityTable.zeros( | ||
spot_attributes=spot_attributes, | ||
round_labels=spot_results.round_labels, | ||
ch_labels=spot_results.ch_labels, | ||
) | ||
for r, c in spot_results.keys(): | ||
value = spot_results[{Axes.ROUND: r, Axes.CH: c}].data[Features.INTENSITY] | ||
# if no exact match set value to 0 | ||
value = 0 if value.empty else value | ||
intensity_table.loc[dict(c=c, r=r)] = value | ||
return intensity_table |
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
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
Oops, something went wrong.
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.
out of scope: I think
Codebook.decode_per_round_max
should be brought over to this module. thoughts?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.
Yea that's actually something I've been thinking during this refactor. Especially since any new decoding method shouldn't have to add code to the Codebook class, I can make that PR