Title: | Conduct Co-Localization Analysis of Fluorescence Microscopy Images |
---|---|
Description: | Automate the co-localization analysis of fluorescence microscopy images. Selecting regions of interest, extract pixel intensities from the image channels and calculate different co-localization statistics. The methods implemented in this package are based on Dunn et al. (2011) <doi:10.1152/ajpcell.00462.2010>. |
Authors: | Mahmoud Ahmed [aut, cre] |
Maintainer: | Mahmoud Ahmed <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2024-11-27 03:56:16 UTC |
Source: | https://github.com/ropensci/colocr |
Get the pixel intensities of certain image channels
.intensity_get(img, ind = c(1, 2))
.intensity_get(img, ind = c(1, 2))
img |
An object of class |
ind |
A |
A list
of three items. The first two items are the values of
the pixel intensities of the channels indicated by ind
. The third is
the labels of the individual regions of interest.
# load image fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose parameters int <- roi_select(img, threshold = 90) %>% .intensity_get()
# load image fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose parameters int <- roi_select(img, threshold = 90) %>% .intensity_get()
Add labels to regions of interest in an image
.labels_add(px, tolerance, n)
.labels_add(px, tolerance, n)
px |
An object of class |
tolerance |
A |
n |
A |
An object of class cimg
. The labels are coded
the values in the object starting from 1. The rest of the image is labeled 0.
Calculates the manders overlap coefficient between two numeric vectors
.manders(r, g)
.manders(r, g)
r |
A |
g |
A |
A numeric
of length one.
set.seed(123) r <- rnorm(10) set.seed(1234) g <- rnorm(10) .manders(r, g)
set.seed(123) r <- rnorm(10) set.seed(1234) g <- rnorm(10) .manders(r, g)
Calculates the Pearson's correlation coefficient between two numeric vectors
.pearson(r, g)
.pearson(r, g)
r |
A |
g |
A |
A numeric
of length one.
set.seed(123) r <- rnorm(10) set.seed(1234) g <- rnorm(10) .pearson(r, g)
set.seed(123) r <- rnorm(10) set.seed(1234) g <- rnorm(10) .pearson(r, g)
colocr
: Conduct Co-localization Analysis of Microscopy Images.Automate the co-localization analysis of fluorescence microscopy images. Selecting regions of interest, extract pixel intensities from the image channels and calculate different co-localization statistics.
colocr
functionsroi_select
roi_show
roi_check
roi_test
A wrap around image_read
and
magick2cimg
to load one or more images from files.
image_load(image_file)
image_load(image_file)
image_file |
A |
A cimg
object or a list
of cimg
objects when
multiple files are passed to image_file
.
# load image fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl)
# load image fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl)
Show the pixel intensities of certain image channels
roi_check(img, ind = c(1, 2))
roi_check(img, ind = c(1, 2))
img |
A |
ind |
A |
Calling this function returns two plots. The first is a scatter plot of the pixel intensities from two channels. The second is the density distribution of the intensities from the two channels.
# load images fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose ROI and show the pixel intensities oldpar <- par() par(mfrow = c(1, 2)) roi_select(img, threshold = 90) %>% roi_check() par(oldpar)
# load images fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose ROI and show the pixel intensities oldpar <- par() par(mfrow = c(1, 2)) roi_select(img, threshold = 90) %>% roi_check() par(oldpar)
Select regions of interest in an image using different morphological operations
roi_select(img, threshold, shrink = 5, grow = 5, fill = 5, clean = 5, tolerance = 0.1, n = 1)
roi_select(img, threshold, shrink = 5, grow = 5, fill = 5, clean = 5, tolerance = 0.1, n = 1)
img |
|
threshold |
A |
shrink |
A |
grow |
A |
fill |
A |
clean |
A |
tolerance |
A |
n |
A |
The function applies several imager
morphological
manipulations to select the regions of interest. These include
threshold
which sets all values below certain cut to
0; shrink
/grow
for pixel set
dilation and erosion; fill
/clean
for removing isolated regions and holes. When n
is provided, the
individual regions (connected components) are selected where tolerance
is used to determine if two pixels belong to the same region.
A cimg
. The original input img
with an
additional attribute label
. label
is a vector
of
integer
s. The labels for the selected regions of interests starts
from 1 and 0 is ignored. When img
is a list, a list
is
returned.
# load images fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose ROI newimg <- roi_select(img, threshold = 90) # check the ROI labels unique(attr(newimg, 'label'))
# load images fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose ROI newimg <- roi_select(img, threshold = 90) # check the ROI labels unique(attr(newimg, 'label'))
Show/highlight the selected regions of interest on different image channels
roi_show(img, ind = c(1, 2))
roi_show(img, ind = c(1, 2))
img |
A |
ind |
A |
calling this function with img
object which is returned from
roi_select
returns four different plots. The original image, a
low resolution representation of the selected regions of interest and the
two channels indicated through ind
highlighted.
# load images fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose and show ROI oldpar <- par() par(mfrow=c(2,2)) roi_select(img, threshold = 90) %>% roi_show() par(oldpar)
# load images fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose and show ROI oldpar <- par() par(mfrow=c(2,2)) roi_select(img, threshold = 90) %>% roi_show() par(oldpar)
Perform co-localization test statistics.
roi_test(img, ind = c(1, 2), type = "pcc")
roi_test(img, ind = c(1, 2), type = "pcc")
img |
A |
ind |
A |
type |
A |
The co-localization stats requested in type
is returned as
a column for each. When different labels are provided, the stats are
calculated for each label individually. When is img
is a list
a list
of such data.frame
s is returned
A data.frame
or a list
of data.frame
s.
# load images fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose roi and test colocalization roi_select(img, threshold = 90) %>% roi_test()
# load images fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr') img <- image_load(fl) # choose roi and test colocalization roi_select(img, threshold = 90) %>% roi_test()