Package 'colocr'

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-10-28 06:23:10 UTC
Source: https://github.com/ropensci/colocr

Help Index


Get pixel intensities

Description

Get the pixel intensities of certain image channels

Usage

.intensity_get(img, ind = c(1, 2))

Arguments

img

An object of class cimg

ind

A numeric of length two for channel indexes

Value

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.

Examples

# load image
fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr')
img <- image_load(fl)

# choose parameters
int <- roi_select(img, threshold = 90) %>%
  .intensity_get()

Label regions of interest

Description

Add labels to regions of interest in an image

Usage

.labels_add(px, tolerance, n)

Arguments

px

An object of class pixset

tolerance

A numeric to be passed to label

n

A numeric, the number of desired regions of interest

Value

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.


Calculate Marnders Overlap Coefficient

Description

Calculates the manders overlap coefficient between two numeric vectors

Usage

.manders(r, g)

Arguments

r

A numeric vector

g

A numeric vector

Value

A numeric of length one.

Examples

set.seed(123)
r <- rnorm(10)

set.seed(1234)
g <- rnorm(10)

.manders(r, g)

Calculate Pearson's Correlation Coefficient

Description

Calculates the Pearson's correlation coefficient between two numeric vectors

Usage

.pearson(r, g)

Arguments

r

A numeric vector

g

A numeric vector

Value

A numeric of length one.

Examples

set.seed(123)
r <- rnorm(10)

set.seed(1234)
g <- rnorm(10)

.pearson(r, g)

colocr: Conduct Co-localization Analysis of 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.

colocr functions

roi_select roi_show roi_check roi_test


Run the shiny App

Description

Run the shiny App

Usage

colocr_app()

Load images from files

Description

A wrap around image_read and magick2cimg to load one or more images from files.

Usage

image_load(image_file)

Arguments

image_file

A character vector of one or more paths to image files

Value

A cimg object or a list of cimg objects when multiple files are passed to image_file.

Examples

# load image
fl <- system.file('extdata', 'Image0001_.jpg', package = 'colocr')
img <- image_load(fl)

Show pixel intensities

Description

Show the pixel intensities of certain image channels

Usage

roi_check(img, ind = c(1, 2))

Arguments

img

A cimg object or a list of multiple images such as the one returned from roi_select

ind

A numeric object of length two. For the channel indexes. or a list of similar vectors for each of img items.

Details

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.

Examples

# 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

Description

Select regions of interest in an image using different morphological operations

Usage

roi_select(img, threshold, shrink = 5, grow = 5, fill = 5,
  clean = 5, tolerance = 0.1, n = 1)

Arguments

img

An object of class cimg or a list of multiple cimg items

threshold

A numeric to be passed to threshold or a vector of values for each image in img

shrink

A numeric to be passed to shrink or a vector of values for each image in img

grow

A numeric to be passed to grow or a vector of values for each image in img

fill

A numeric to be passed to fill or a vector of values for each image in img

clean

A numeric to be passed to clean or a vector of values for each image in img

tolerance

A numeric to be passed to label or a vector of values for each image in img

n

A numeric of the number of regions of interest or a vector of values for each image in img

Details

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.

Value

A cimg. The original input img with an additional attribute label. label is a vector of integers. The labels for the selected regions of interests starts from 1 and 0 is ignored. When img is a list, a list is returned.

Examples

# 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 the selected regions of interest

Description

Show/highlight the selected regions of interest on different image channels

Usage

roi_show(img, ind = c(1, 2))

Arguments

img

A cimg object or a list of multiple images such as the one returned from roi_select

ind

A numeric object of length two. For the channel indexes. or a list of similar vectors for each of img items.

Details

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.

Examples

# 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)

Test Co-localization

Description

Perform co-localization test statistics.

Usage

roi_test(img, ind = c(1, 2), type = "pcc")

Arguments

img

A cimg object or a list of multiple images such as the one returned from roi_select

ind

A numeric object of length two. For the channel indexes. or a list of similar vectors for each of img items.

type

A character vector of the desired co-localization statistics. Default is 'pcc', other inputs are 'moc' or 'both'.

Details

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.frames is returned

Value

A data.frame or a list of data.frames.

Examples

# 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()