Reproducing figures and table in this document
In this section, we simplified a version of the code used to produce this document. Briefly, we load the required R libraries, construct a path to the image file (example image) and apply a typical workflow to calculate the co-localization measurements.
First, we start by loading the two libraries
imager
and
colocr
.
library(imager)
library(colocr)
The example image used throughout the document is from DU145 cell line stained for RKIP and LC3 in the first and second channel, respectively. The image is included in the package and can be accessed using system.file.
# get image path
fl <− system.file('extdata', 'Image0003_.jpg', package = 'colocr')
We load the image using
image_load
and show it along with the two channels (
).
# load images and channels
img <− image_load(fl)
img1 <− channel(img, 1)
img2 <− channel(img, 2)
# generate figure of images and channels
par(mfrow = c(1,3), mar = c(0, 0, 1, 0))
plot(img, axes = FALSE, main = 'Merge')
plot(img1, axes = FALSE, main = 'Channel One')
plot(img2, axes = FALSE, main = 'Channel Two')
Typically, one would use the
roi_select
to choose the regions of interest as a first step in the analysis workflow.
roi_show
highlights the selected regions (
).
# select regions of interest
par(mfrow = c(2,2), mar = c(0, 0, 1, 0))
img %>%
roi_select(threshold = 90,
shrink = 10,
fill = 5,
clean = 10,
n = 3) %>%
roi_show()
Next,
roi_check
shows the scatter and the density distribution of pixel intensities from the selected regions of interest (
).
# check pixel intensities
par(mfrow = c(1,2), mar = c(4, 4, 1, 1))
img %>%
roi_select(threshold = 90,
shrink = 10,
fill = 5,
clean = 10,
n = 3) %>%
roi_check()
Finally,
roi_test
calculates the co-localization measurements (
).
# calculate co−localization stats
img %>%
roi_select(threshold = 90,
shrink = 10,
fill = 5,
clean = 10,
n = 3) %>%
roi_test(type = 'both')