Assumes a GPU is available for the segmentation, and that the cpsam model fro cellprofiler4 is present at: ~/.cellpose/models/cpsam
The cpsam model can be downloaded from: https://huggingface.co/mouseland/cellpose-sam/resolve/main/cpsam?download=true)
The following packages are used, see requirements.txt:
sopa
spatialdata_plot
spatialdata
matplotlib
scanpy
numpy
Tested on Python 3.11.2
- Load the COMET image.
- Set the chanenl names.
- Segment the tissue on a lower resolution pyramid level, to identify the areas to perform cell segmentation on.
- Divide the tissue in patches, to perform the segmentation on.
- Plots: DAPI Image, tissue to be segmented, and segmentation patches to check the areas that will be segmented
This step needs to be performed on a GPU node.
Assumes that the cpsam model fro cellprofiler4 is present at: ~/.cellpose/models/cpsam
The cpsam model can be downloaded from: https://huggingface.co/mouseland/cellpose-sam/resolve/main/cpsam?download=true)
- Cellpose segmentation with the cpsam model
- Make ann AnnData object with the mean pixel value of each marker in each cell
If the preprocessing and segmentation have been performed with the nf-core version of sopa, the SpatialData out folder in zarr format can be opened and the analysis started from here.
- Produces an expression table withou DAPI for the UMAP plotting
- Generate a NN neighbour grap and the UMAP embeddings
- Assign the cells to specific celltypes using manual thresholds
- Plots:
- UMAPs
- Violinplot
- Dotplot
- Heatmap
Extract the bounding boxes of the 3 largest pieces of tissue:
- Calculate the scaling factor between the pyramid level used for tissue segmentation and the full resolution
- Get the bounding boxes from the regions_of_interest ROIs polygons we obtained from the tissue segmentation
- Scale the bounding boxes to match the full resolution image
- Calculate the area to find the 3 kargest bounding boxes
- Use the bounding boxes to crop the spatialdata object
- Write out zarrs for visualization with napari
The output consists of separate spatialdat objects, one for each sample. The spatialdata objects contain:
- Image
- Cell plygons
- Annotated expression table
These objects can be visualized with napari using the napari-spatialdata plugin