10x Genomics Support/Xenium Ranger/Algorithms Overview/

Xenium Ranger Algorithms Overview

The relabel pipeline works by building a 1:1 map between the previously-used gene panel and the new gene panel. This map is used to correct the gene labels given to each of the discovered transcripts. After correcting the labels, all results are recomputed using the same methods employed by the Xenium Onboard Analysis pipeline.

The resegment pipeline uses the same nucleus segmentation model as the corresponding Xenium Onboard Analysis (XOA) version. For example, Xenium Ranger v1.6 uses the nucleus segmentation model included in the XOA v1.6 release.

See Xenium Onboard Analysis algorithm overview for details about the cell segmentation algorithm.

Xenium Ranger can import a variety of community-developed segmentation formats. The methods used to incorporate new segmentations fall under three scenarios:

  • Import nucleus and cell labeled segmentation masks (TIFF or NPY), where each pixel is an integer corresponding to the cell ID
  • Import nucleus and cell segmentation polygons (GeoJSON)
  • Import transcript-based segmentations

In scenario 1, if the user only imports a nuclear segmentation mask, then a new cell segmentation is generated by nuclear expansion. If both nuclei and cells are imported, then Xenium Ranger will inspect the masks for consistency. Given current restrictions on the relationship between nuclei and cells, Xenium Ranger expects each cell to have a nucleus and vice versa. In cases where there are cells without a nucleus, a nucleus will be generated with the same shape and size as the cell. Similarly, if a nucleus is found without a cell, a cell is generated with the same shape and size as the nucleus. In either of these cases, metrics are generated to provide the user knowledge of how many cells or nuclei were artificially generated. Warnings are produced if a large number of cells (or nuclei) are found without a nucleus (or cell). After the masks have been made consistent, all results are recomputed using the new segmentation results.

In scenario 2, Xenium Ranger first takes the input GeoJSON polygons and converts them into labeled masks. Given the flexibility of the GeoJSON format, it is possible the input polygons do not fit neatly into a mask. For example, two polygons could overlap one another. In the process of converting polygons into masks, Xenium Ranger detects polygons that overlap one another and marks the overlapping pixels as ambiguous. The ambiguous pixels are then resolved by assigning the pixel to the object with the most neighboring pixels. Metrics are generated to explain how many ambiguous pixels were found. After masks have been generated, the remaining method follows scenario 1.

Lastly, when importing a transcript-based segmentation, Xenium Ranger records the cell assignments for each of the transcripts. The user is required to supply visualization polygons for cells, which are also used to filter cells by minimum and maximum area thresholds. Subsequently, all results are recomputed using the imported transcript assignments. As mentioned above, there can potentially be issues in converting imported polygons into a mask. For the case of importing transcript assignments, Xenium Ranger will not try to convert the visualization polygons into a mask. Instead, it will generate an empty mask and leave the polygons untouched.

For every scenario, a unique random ID is assigned to each cell in the same string format used by the XOA pipeline.