| Title: | A package to perform simple cell segmentation |
|---|---|
| Description: | Image segmentation is the process of identifying the borders of individual objects (in this case cells) within an image. This allows for the features of cells such as marker expression and morphology to be extracted, stored and analysed. simpleSeg provides functionality for user friendly, watershed based segmentation on multiplexed cellular images in R based on the intensity of user specified protein marker channels. simpleSeg can also be used for the normalization of single cell data obtained from multiple images. |
| Authors: | Nicolas Canete [aut], Alexander Nicholls [aut], Ellis Patrick [aut, cre] |
| Maintainer: | Ellis Patrick <[email protected]> |
| License: | GPL-3 |
| Version: | 1.15.2 |
| Built: | 2026-10-14 13:53:36 UTC |
| Source: | https://github.com/bioc/simpleSeg |
Normalizes and transforms cell data in preparation for clustering (accepts dataframe, SingleCellExperiment and SpatialExperiment).
normalizeCells( cells, markers = NULL, assayIn = NULL, assayOut = "norm", imageID = "imageID", transformation = NULL, method = NULL, cores = 1 )normalizeCells( cells, markers = NULL, assayIn = NULL, assayOut = "norm", imageID = "imageID", transformation = NULL, method = NULL, cores = 1 )
cells |
A Dataframe of SingleCellExperiment or SpatialExperiment containing cells and features to be normalized/transformed |
markers |
A list containing the names of cell markers which will be normalized and/or transformed. |
assayIn |
If input is a SingleCellExperiment or SpatialExperiment with multiple assays, specify the assay to be normalized and/or transformed. |
assayOut |
If input is a SingleCellExperiment or SpatialExperiment, the new of the normalized data. |
imageID |
If input is a SingleCellExperiment or SpatialExperiment, this is the name of the image ID variable in order to stratify. cells correctly |
transformation |
The transformation/s to be performed, default is NULL, accepted values: 'asinh' and 'sqrt'. |
method |
The normalization method/s to be performed, default is NULL, accepted values: 'mean', 'minMax', 'trim99', 'PC1'. |
cores |
The number or cores for parallel processing. |
returns a dataframe with individual cells as rows and features as columns.
library(cytomapper) data("pancreasSCE") cells.normalized <- normalizeCells( cells = pancreasSCE, markers = c("CD99", "PIN", "CD8a", "CDH"), assayIn = "counts", assayOut = "normCounts", imageID = "ImageNb", transformation = "asinh", method = "trim99" )library(cytomapper) data("pancreasSCE") cells.normalized <- normalizeCells( cells = pancreasSCE, markers = c("CD99", "PIN", "CD8a", "CDH"), assayIn = "counts", assayOut = "normCounts", imageID = "ImageNb", transformation = "asinh", method = "trim99" )
Perform simple segmentation of multiplexed cellular images
simpleSeg( image, nucleus, cellBody = "dilate", sizeSelection = 10, smooth = 1, transform = NULL, watershed = "intensity", tolerance = NULL, ext = 1, discSize = 3, tissue = NULL, pca = FALSE, cores = 1, output = NULL, maskDir = NULL, tileSize = 4096, overlap = 64 )simpleSeg( image, nucleus, cellBody = "dilate", sizeSelection = 10, smooth = 1, transform = NULL, watershed = "intensity", tolerance = NULL, ext = 1, discSize = 3, tissue = NULL, pca = FALSE, cores = 1, output = NULL, maskDir = NULL, tileSize = 4096, overlap = 64 )
image |
An image, a list of images or a CytoImageList; or paths to image files or folders (see Details). |
nucleus |
The marker or list of markers corresponding to the nuclei. |
cellBody |
Method of cytoplasm identification. Can be 'none', dilate', 'discModel' or the name of a dedicated cytoplasm marker |
sizeSelection |
Minimum pixels for an object to be recognized as a cell and not noise. |
smooth |
The amount of Gaussian smoothing to be applied to the image/s |
transform |
A transformation or list of transformations and normalizations to be performed prior to nuclei or cytoplasm identification. Accepted vales: "sqrt", "asinh", "norm99", "maxThresh" and "tissueMask". Tissue mask may be used when the sample does not take up the entirety of the image (typically a circular sample inside the image. When tissue mask is specified the background noise present outside the sample area is removed). |
watershed |
Method used to perform watersheding. Accepted values: "intensity", "distance" or "combine". |
tolerance |
The minimum height of the object in the units of image intensity between its highest point (seed) and the point where it contacts another object (checked for every contact pixel). If the height is smaller than the tolerance, the object will be combined with one of its neighbors, which is the highest. Tolerance should be chosen according to the range of x. Default value is 1, which is a reasonable value if x comes from distmap. |
ext |
Radius of the neighborhood in pixels for the detection of neighboring objects. Higher value smooths out small objects. |
discSize |
The size of dilation around nuclei to create cell disc or capture cytoplasm |
tissue |
Channels to be used to create the tissue mask if specified in transforms. |
pca |
Whether to run PCA on aggregated nucleus markers in order to detect the cellular nucclei. |
cores |
The number or cores for parallel processing or a BPPARAM object |
output |
What to return: "masks" (a CytoImageList of cell masks), "cells" (a SpatialExperiment of the cells, see Value) or "none" (only write the masks to 'maskDir'). Defaults to "masks" for images and "cells" for paths. |
maskDir |
Optional folder in which to save each image's mask as a TIFF file named after the image. |
tileSize |
Images read from files that are wider or taller than 'tileSize' pixels are segmented in tiles of this size, without reading the whole image into memory. |
overlap |
Pixels added on each side of a tile. It should be larger than the largest cell. |
'image' may be given as paths: * a multi-channel image file (OME-TIFF, QPTIFF, or a TIFF with one page or band per channel) is one image; channel names are read from the OME-XML or QPTIFF metadata; * a folder of single-channel TIFF files is one image split by marker, with the file names (without extension) as channel names; if the files have more than three channels each, each file is instead treated as an image; * a folder of such folders holds one image per folder.
Images that fit within 'tileSize' are read into memory and segmented as images in R are. Larger images are segmented tile by tile: the threshold, transformation constants and watershed tolerance are first calculated over the whole image, each tile is segmented with 'overlap' pixels around it, and each cell belongs to the tile containing its centroid. Without 'pca' or a cell body model ("discModel" or markers), the cells are those found when segmenting the whole image. The PCA is fitted on up to 100,000 pixels and the cell body model on about 1,000,000 pixels sampled across the whole image, so their cells differ slightly from a segmentation of the whole image in memory. "norm99" needs integer pixel values.
Before the watershed, pixels of equal height are separated by a tiny amount (a millionth of the tolerance) that depends on their position, so that ties are resolved the same way however the image is processed.
With output = "masks", a CytoImageList of masks. With output = "cells", a SpatialExperiment with one column per cell: the mean intensity of each channel (assay "counts"), the image (‘imageID'), the cell’s label in its mask ('object_id') and its area in pixels ('s.area') in the colData, and its centroid ('m.cx', 'm.cy', in pixels) as spatialCoords. With output = "none", the paths of the mask files, invisibly.
library(cytomapper) data("pancreasImages") masks <- simpleSeg(pancreasImages, nucleus = "H3", cellBody = "discModel", sizeSelection = 8, smooth = 1.2, transform = "sqrt", watershed = "combine", tolerance = 1, ext = 1, discSize = 3, cores = 1 ) # images stored as one folder of single-channel files per image path <- system.file("extdata", package = "simpleSeg") cells <- simpleSeg(path, nucleus = "HH3", transform = "sqrt")library(cytomapper) data("pancreasImages") masks <- simpleSeg(pancreasImages, nucleus = "H3", cellBody = "discModel", sizeSelection = 8, smooth = 1.2, transform = "sqrt", watershed = "combine", tolerance = 1, ext = 1, discSize = 3, cores = 1 ) # images stored as one folder of single-channel files per image path <- system.file("extdata", package = "simpleSeg") cells <- simpleSeg(path, nucleus = "HH3", transform = "sqrt")