8000 RFC: Base calling filter for in situ sequencing by kevinyamauchi · Pull Request #1281 · spacetx/starfish · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

RFC: Base calling filter for in situ sequencing #1281

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

Merged
merged 6 commits into from
May 11, 2019

Conversation

kevinyamauchi
Copy link
Collaborator

Overview

As discussed in #1263, this filter component performs base calling for in situ sequencing. The filter determines which base (if any) is represented in each X, Y location in a (round, z plane) slice (i.e., in a (channel, x, y) image). Each pixel value in the resulting image is the base quality score for a given base call.

Currently, the base quality score is calculated as the intensity of the called base divided by the L2 norm of the intensities in all 4 channels (this is how it is done in the original BaristaSeq paper). However, I think it could be useful to add the capability for the user to provide their own custom functions. However, this will likely present challenges for provenance logging. Thoughts, @ambrosejcarr and @dganguli?

Usage

import numpy as np

from starfish import ImageStack
from starfish.image import Filter

# Make the test image
test = np.ones((1, 4, 1, 2, 2), dtype='uint16') * 0.5

x = [0, 0, 1, 1]
y = [0, 1, 0, 1]

for i in range(4):
    test[0, i, 0, x[i], y[i]] = 1
test[0, 0, 0, 0, 0] = 0.75

# Make the ImageStack
test_stack = ImageStack.from_numpy(test)

# Filter
bc = Filter.CallBases(intensity_threshold=0.8)
base_call = bc.run(test_stack, in_place=False)

base_call.xarray.values

In the example above, the test image has intensities as shown below. The field over view is 2 pixels x 2 pixels. Base for channel 0 is "on" in the upper left corner (intensity=0.75), the base for channel 1 is "on" in the upper right hand corner (intensity=1), the base for channel 2 is "on" in lower left-hand corner (intensity=1), and the base for channel 3 is "on" in the lower right hand corner (intensity=1). The background intensity is uniformly 0.5 for all channels.

array([[[[[0.75, 0.5 ],
          [0.5 , 0.5 ]]],

        [[[0.5 , 1.  ],
          [0.5 , 0.5 ]]],

        [[[0.5 , 0.5 ],
          [1.  , 0.5 ]]],

        [[[0.5 , 0.5 ],
          [0.5 , 1.  ]]]]], dtype=float32)

After filtering, we obtain the following. Note that the base 0 intensity in the upper left hand corner was 0.75, so no base was called due to the intensity threshold we set for the filter (intensity_threshold=0.8). The base quality for all other bases is 1 / (1^2 + 0.5^2 + 0.5^2 + 0.5^2)^0.5 = 0.755929.

array([[[[[0.      , 0.      ],
          [0.      , 0.      ]]],

        [[[0.      , 0.755929],
          [0.      , 0.      ]]],

        [[[0.      , 0.      ],
          [0.755929, 0.      ]]],

        [[[0.      , 0.      ],
          [0.      , 0.755929]]]]], dtype=float32)

Testing

I added tests for the base calling and filtering in starfish/core/image/_filter/test/test_call_bases.py

@codecov-io
Copy link
codecov-io commented Apr 26, 2019

Codecov Report

Merging #1281 into master will increase coverage by 0.33%.
The diff coverage is 97.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1281      +/-   ##
==========================================
+ Coverage   88.84%   89.18%   +0.33%     
==========================================
  Files         146      147       +1     
  Lines        5246     5409     +163     
==========================================
+ Hits         4661     4824     +163     
  Misses        585      585
Impacted Files Coverage Δ
starfish/core/image/_filter/call_bases.py 97.29% <97.29%> (ø)
starfish/__init__.py 91.66% <0%> (-8.34%) ⬇️
...ots/_detect_spots/trackpy_local_max_peak_finder.py 90.27% <0%> (-1.39%) ⬇️
starfish/core/pipeline/algorithmbase.py 96.66% <0%> (-1.07%) ⬇️
...ore/intensity_table/intensity_table_coordinates.py 100% <0%> (ø) ⬆️
starfish/core/intensity_table/intensity_table.py 96.92% <0%> (+0.49%) ⬆️
starfish/core/codebook/codebook.py 97.26% <0%> (+0.6%) ⬆️
starfish/core/spots/_decode/metric_decoder.py 87.5% <0%> (+25%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a35a623...d252056. Read the comment docs.

Copy link
Member
@ambrosejcarr 8000 ambrosejcarr left a comment

Choose a reason for hiding this comment

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

Kevin, this is amazing. I have some comments that I hope are really simple. Sorry for the delay on reviewing this.

@kevinyamauchi
Copy link
Collaborator Author

@ambrosejcarr , thanks for the comments! I've addressed them. Would you mind re-reviewing?

@kevinyamauchi kevinyamauchi merged commit f977425 into master May 11, 2019
@kevinyamauchi kevinyamauchi deleted the ky-base-call-filter branch May 11, 2019 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0