Skip to content

Commit 7c2fe15

Browse files
authored
Merge pull request #156 from scijava/scijava-ops-image/saca
Add SACA framework Op and SACA use case
2 parents 8c95d5d + 33cd59e commit 7c2fe15

17 files changed

Lines changed: 1390 additions & 14 deletions

File tree

docs/ops/doc/examples/saca.rst

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
==========================================
2+
Spatially Adpative Colocalization Analysis
3+
==========================================
4+
5+
In this example we will use SciJava Ops and the Spatially Adaptive Colocalization Analysis (SACA) :sup:`1` framework on
6+
HeLa cells transfected with a dual fluorescent HIV-1 :sub:`NL4-3` construct to colocalize viral mRNAs with
7+
HIV-1 :sub:`NL4-3` Gag proteins. Two fluorescent fusion proteins are made when cells express the modified
8+
HIV-1 construct: Gag-mVenus and MS2-mCherry. The Gag-mVenus fusion protein tracks Gag protein, the primary structural component of the HIV-1 virion.
9+
The MS2-mCherry fusion protein binds to 24 copies of the MS2 bacteriophage RNA stem-loop :sup:`2` inserted into the HIV-1 construct, enabling
10+
fixed and live-cell imaging of viral mRNA dynamics. Taken together, this system tracks both Gag and viral mRNAs from the cell's cytoplasm
11+
to sites of viral particle assembly at the plasma membrane where they colocalize :sup:`3`. This example uses fixed cell data
12+
collected with a laser-scanning confocal microscope at 60x magnification (oil immersion).
13+
14+
The SACA framework produces three outputs: a *Z*-score heatmap, a p-valye heatmap and a significant pixel value mask. The *Z*-score heatmap
15+
indicates the relatively colocalization or anti-colocalization strength at a pixel-wise level. The p-value heatmap indicates the p-value
16+
of the colocalization strength at a pixel-wise level. Finally the significant pixel mask identifies which pixels are significantly colocalized. This
17+
example script takes advantage of this feature of the SACA framework and utilizes the significant pixel mask as a region of interest to compute
18+
Pearson's :sup:`4` and Li's :sup:`5` colocalization quotients.
19+
20+
You can download the colocalization dataset `here`_.
21+
22+
.. figure:: https://media.scijava.org/scijava-ops/1.0.0/saca_input.png
23+
24+
SciJava Ops via Fiji's scripting engine with `script parameters`_:
25+
26+
.. tabs::
27+
28+
.. code-tab:: scijava-groovy
29+
30+
#@ OpEnvironment ops
31+
#@ ConvertService cs
32+
#@ Img input
33+
#@output zscore
34+
#@output pvalue
35+
#@output sig_mask
36+
37+
import net.imglib2.type.logic.BitType
38+
import net.imglib2.roi.labeling.ImgLabeling
39+
import net.imglib2.roi.labeling.LabelRegions
40+
import net.imglib2.roi.Regions
41+
42+
// split input image into channels
43+
channels = []
44+
input.dimensionsAsLongArray()[2].times { i ->
45+
channels.add(ops.op("transform.hyperSliceView").input(input, 2, i).apply())
46+
}
47+
48+
// create SACA Z-score heatmap
49+
zscore = ops.op("coloc.saca.heatmapZScore").input(channels[0], channels[1]).apply()
50+
51+
// compute pixel-wise p-value
52+
pvalue = ops.op("stats.pnorm").input(zscore).apply()
53+
54+
// create SACA significant pixel mask
55+
sig_mask = ops.op("create.img").input(channels[0], new BitType()).apply()
56+
ops.op("coloc.saca.sigMask").input(zscore).output(sig_mask).compute()
57+
58+
// convert SACA sig mask into labeling and run
59+
// Pearson's and Li's colocalization quotients
60+
labeling = cs.convert(sig_mask, ImgLabeling)
61+
regs = new LabelRegions(labeling)
62+
coloc_region = regs.getLabelRegion(1)
63+
subsample_1 = Regions.sample(coloc_region, channels[0])
64+
subsample_2 = Regions.sample(coloc_region, channels[1])
65+
pearsons = ops.op("coloc.pearsons").input(subsample_1, subsample_2).apply()
66+
li = ops.op("coloc.icq").input(subsample_1, subsample_2).apply()
67+
68+
// print Pearson's and Li's results
69+
print("Pearson's: " + pearsons + "\nLi's: " + li)
70+
71+
.. code-tab:: python
72+
73+
#@ OpEnvironment ops
74+
#@ ConvertService cs
75+
#@ Img input
76+
#@output zscore
77+
#@output pvalue
78+
#@output sig_mask
79+
80+
from net.imglib2.type.logic import BitType
81+
from net.imglib2.roi.labeling import ImgLabeling, LabelRegions
82+
from net.imglib2.roi import Regions
83+
84+
# split input image into channels
85+
channels = []
86+
for i in range(input.dimensionsAsLongArray()[2]):
87+
channels.append(ops.op("transform.hyperSliceView").input(input, 2, i).apply())
88+
89+
# create SACA Z-score heatmap
90+
zscore = ops.op("coloc.saca.heatmapZScore").input(channels[0], channels[1]).apply()
91+
92+
# compute pixel-wise p-value
93+
pvalue = ops.op("stats.pnorm").input(zscore).apply()
94+
95+
# create SACA significant pixel mask
96+
sig_mask = ops.op("create.img").input(channels[0], BitType()).apply()
97+
ops.op("coloc.saca.sigMask").input(zscore).output(sig_mask).compute()
98+
99+
# convert SACA sig mask into labeling and run
100+
# Pearson's and Li's colocalization quotients
101+
labeling = cs.convert(sig_mask, ImgLabeling)
102+
regs = LabelRegions(labeling)
103+
coloc_region = regs.getLabelRegion(1)
104+
subsample_1 = Regions.sample(coloc_region, channels[0])
105+
subsample_2 = Regions.sample(coloc_region, channels[1])
106+
pearsons = ops.op("coloc.pearsons").input(subsample_1, subsample_2).apply()
107+
li = ops.op("coloc.icq").input(subsample_1, subsample_2).apply()
108+
109+
# print Pearson's and Li's results
110+
print("Pearson's: " + str(pearsons))
111+
print("Li's: " + str(li))
112+
113+
Once the script completes, three gray scale images will be displayed: ``zscore``, ``pvalue`` and ``sig_mask``.
114+
Additionally the console will print the Pearson's and Li's colocalization coefficients using the significant pixel
115+
mask created from SACA.
116+
117+
.. code-block:: text
118+
119+
Pearson's: 0.65593660643
120+
Li's: 0.211457241276
121+
122+
.. figure:: https://media.scijava.org/scijava-ops/1.0.0/saca_output_gray.png
123+
124+
To apply the ``phase`` LUT and a colorbar use the following script and select the input images.
125+
126+
.. tabs::
127+
128+
.. code-tab:: scijava-groovy
129+
130+
#@ ImagePlus zscore_imp (label="Z-score heatmap")
131+
#@ ImagePlus pvalue_imp (label="p-value heatmap")
132+
133+
import ij.IJ
134+
135+
// apply phase LUT to input images
136+
IJ.run(zscore_imp, "phase", "")
137+
IJ.run(pvalue_imp, "phase", "")
138+
139+
// apply color bar to images
140+
IJ.run(zscore_imp, "Calibration Bar...", "location=[Upper Right] fill=White label=Black number=5 decimal=2 font=12 zoom=1.3 overlay")
141+
IJ.run(pvalue_imp, "Calibration Bar...", "location=[Upper Right] fill=White label=Black number=5 decimal=2 font=12 zoom=1.3 overlay")
142+
143+
.. code-tab:: python
144+
145+
#@ ImagePlus zscore_imp (label="Z-score heatmap")
146+
#@ ImagePlus pvalue_imp (label="p-value heatmap")
147+
148+
from ij import IJ
149+
150+
# apply phase LUT to input images
151+
IJ.run(zscore_imp, "phase", "")
152+
IJ.run(pvalue_imp, "phase", "")
153+
154+
# apply color bar to images
155+
IJ.run(zscore_imp, "Calibration Bar...", "location=[Upper Right] fill=White label=Black number=5 decimal=2 font=12 zoom=1.3 overlay")
156+
IJ.run(pvalue_imp, "Calibration Bar...", "location=[Upper Right] fill=White label=Black number=5 decimal=2 font=12 zoom=1.3 overlay")
157+
158+
.. figure:: https://media.scijava.org/scijava-ops/1.0.0/saca_output_color.png
159+
160+
161+
| :sup:`1`: `Wang et. al, IEEE 2019`_
162+
| :sup:`2`: `Stockley et. al, Bacteriophage 2016`_
163+
| :sup:`3`: `Becker and Sherer, JVI 2017`_
164+
| :sup:`4`: `Manders et. al, J Microsc 1992`_
165+
| :sup:`5`: `Li et. al, J Neurosci 2004`_
166+
167+
.. _`Manders et. al, J Microsc 1992`: https://pubmed.ncbi.nlm.nih.gov/33930978/
168+
.. _`Li et. al, J Neurosci 2004`: https://pubmed.ncbi.nlm.nih.gov/15102922/
169+
.. _`Becker and Sherer, JVI 2017`: https://pubmed.ncbi.nlm.nih.gov/28053097/
170+
.. _`Wang et. al, IEEE 2019`: https://ieeexplore.ieee.org/abstract/document/8681436
171+
.. _`Stockley et. al, Bacteriophage 2016`: https://pubmed.ncbi.nlm.nih.gov/27144089/
172+
.. _`here`: https://media.imagej.net/scijava-ops/1.0.0/hela_hiv_gag_ms2_mcherry.tif
173+
.. _`script parameters`: https://imagej.net/scripting/parameters

docs/ops/doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The combination of these libraries allows declarative image analysis workflows,
3333
examples/flim_analysis
3434
examples/gaussian_subtraction
3535
examples/opencv_denoise
36+
examples/saca
3637
examples/scyjava
3738

3839
.. toctree::

scijava-ops-image/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,11 @@
325325
<artifactId>scijava-meta</artifactId>
326326
<version>${project.version}</version>
327327
</dependency>
328+
<dependency>
329+
<groupId>org.scijava</groupId>
330+
<artifactId>scijava-progress</artifactId>
331+
<version>${project.version}</version>
332+
</dependency>
328333
<dependency>
329334
<groupId>org.scijava</groupId>
330335
<artifactId>scijava-ops-api</artifactId>

scijava-ops-image/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
requires org.scijava.function;
4444
requires org.scijava.meta;
4545
requires org.scijava.ops.api;
46+
requires org.scijava.progress;
4647
requires org.scijava.ops.spi;
4748
requires org.scijava.priority;
4849
requires org.scijava.types;

0 commit comments

Comments
 (0)