There are a ton of ways to define cellular niches, and I haven't found a good fit with the tools out there. Currently, you either need to leverage the seuratObj@images ... slot? layer? (which is an efficient way to store images, but difficult to encode post-hoc) or accept louvain/leiden clustering as your cellular niche.
This approach leverages transcriptomic information provided in via a metadata field reflecting either cell types or clusters, then performs DBSCAN to isolate cellular substructures. I have had a tough time dealing with non-uniform cellular density between the inside and outside of B cell follicles, so this method segments the images into a "target cell type(s)" layer, performs spatial clustering on those cells, and then classifies all of the cells relative to those substructures via a convex hull around each substructure.
Here is an example of automatically defining a B cell follicle. The top image shows simplified cell type metadata, while the bottom left image shows indexed follicles (zero is always a "null" cluster, indicating it isn't identified as a structure). The bottom right shows a gross inclusion of cells into any of the current substructure.
One could nest different substructures by calling the function multiple times, so I'm not fully certain where to leave the verbosity of the output. Currently, this will yield at least one metadata column per FOV and one extra column per substructure within the FOV.
TODO before pull request:
~implement test using mixture of gaussians.~
~Move "BCF-centric defaults" to an example.~
On second thought, I think we can keep the defaults. BCFs are one of the easiest to understand "cellular substructures" in the grand scheme of how this function works and why you'd want to include cells of multiple cell types within the structure (e.g. follicular helper/dendritic cells).
~improve "Within_Local..." verbiage during summarization.~
I think supplying the name of the substructure works here. FOV specific substructures will look like: "fovIndex_SubstructureName_SubstructureIndex" and then the overall summarization columns are "Local_SubstructureName" indicating which substructure the cell is in and "Within_Local_SubstructureName" offering a boolean for substructure membership.
~Sanitize inputs or force correct typing on FOV/cell type metadata columns.~
Hi all,
There are a ton of ways to define cellular niches, and I haven't found a good fit with the tools out there. Currently, you either need to leverage the seuratObj@images ... slot? layer? (which is an efficient way to store images, but difficult to encode post-hoc) or accept louvain/leiden clustering as your cellular niche.
This approach leverages transcriptomic information provided in via a metadata field reflecting either cell types or clusters, then performs DBSCAN to isolate cellular substructures. I have had a tough time dealing with non-uniform cellular density between the inside and outside of B cell follicles, so this method segments the images into a "target cell type(s)" layer, performs spatial clustering on those cells, and then classifies all of the cells relative to those substructures via a convex hull around each substructure.
Here is an example of automatically defining a B cell follicle. The top image shows simplified cell type metadata, while the bottom left image shows indexed follicles (zero is always a "null" cluster, indicating it isn't identified as a structure). The bottom right shows a gross inclusion of cells into any of the current substructure.
One could nest different substructures by calling the function multiple times, so I'm not fully certain where to leave the verbosity of the output. Currently, this will yield at least one metadata column per FOV and one extra column per substructure within the FOV.
TODO before pull request: