rapids_singlecell.gr.neighbors.GraphBuilder#
- class rapids_singlecell.gr.neighbors.GraphBuilder[CoordT, GraphMatrixT](transform=None, set_diag=False, percentile=None, postprocessors=())[source]#
Base class for spatial graph construction strategies.
Implement
build_graph()anduns_params();build()applies the postprocessors in order. Overridecombine()to support libraries.- Parameters:
- transform
str|None(default:None) Transform setting stored on the builder:
None,"spectral", or"cosine". Subclasses or postprocessors implement its effect.- set_diag
bool(default:False) Diagonal setting stored on the builder for use by subclasses.
- percentile
float|None(default:None) Distance percentile setting stored on the builder for use by subclasses or postprocessors.
Nonedisables percentile pruning.- postprocessors
Sequence[Callable[[GraphMatrixT,GraphMatrixT],tuple[GraphMatrixT,GraphMatrixT]]] (default:()) Ordered callables taking connectivity and distance matrices and returning the processed pair. Custom builders control which steps are applied.
- transform
Methods table#
build(coords)Construct a graph and apply its postprocessors.
build_graph(coords)Construct raw adjacency and distance matrices.
combine(mats, ixs)Combine per-library graphs in original observation order.
Return processing steps for the raw adjacency and distances.
Return graph parameters to store in
adata.uns.Methods#
- build(coords)[source]#
Construct a graph and apply its postprocessors.
- Parameters:
- coords
CoordT Spatial coordinates accepted by the builder. CSR builders accept a dense array of shape
(n_obs, n_dims), converted to finite float32.
- coords
- Return type:
tuple[GraphMatrixT,GraphMatrixT]- Returns:
connectivities, distances Graph matrices in observation order; CSR builders return CuPy CSR.
- abstractmethod build_graph(coords)[source]#
Construct raw adjacency and distance matrices.
- Parameters:
- coords
CoordT Coordinates in the format supported by this builder.
- coords
- Return type:
tuple[GraphMatrixT,GraphMatrixT]- Returns:
connectivities, distances Raw graph matrices before postprocessing.
- combine(mats, ixs)[source]#
Combine per-library graphs in original observation order.
- Parameters:
- Return type:
tuple[GraphMatrixT,GraphMatrixT]- Returns:
connectivities, distances Combined matrices reordered to match the input observations.