Single Cell Type Mode
Purpose
singleCelltype
uses the annotation results of single cell type to identify and characterize microenvironments with specific cell compositions and spatial distribution patterns within tissues.
Usage
SDAS cellularNeighborhood singleCelltype -i st.h5ad --bin_size 100 -o outdir --label_key anno_cell2location \
--window_method fixed_radius
Input Parameter Description
-i / --input
Yes
Stereo-seq h5ad, containing cell type annotation results
-o / --output
Yes
Output folder
--bin_size
Yes
Bin size, used to control the size of points in the plot, not used for calculation, e.g., 20, 50, 100, cellbin (equivalent to 20)
--label_key
Yes
Column name in h5ad.obs representing cell type annotation, used to calculate the cell composition of the window and neighborhood enrichment analysis for each CN
--slice_key
No
Column name in h5ad.obs representing slice ID, used for window statistics and plotting in multi-slice analysis
--cluster_method
No
Kmeans
Clustering method, only Kmeans is available for singleCelltype;multiCelltypeScore can choose leiden or Kmeans
--resolution
No
0.4
Resolution for leiden clustering when cluster_method is leiden; for bin20 or cellbin data, recommend resolution <0.1
--n_clusters
No
8
Number of clusters for Kmeans when cluster_method is Kmeans
--seed
No
42
Random seed
--target_celltype
No
Analyze CN for specified cell type(s), input cell type names, separated by commas if multiple
--window_method
No
fixed_radius
Windowing method, fixed nearest neighbors or fixed radius
--n_neighbors
No
10
Number of neighbors to use by default for :meth:kneighbors queries
--radius
No
100
Range of parameter space to use by default for :meth:radius_neighbors queries,
radius is coordinate distance, can be converted to physical distance according to data resolution, e.g., for stereo-seq data, radius 100 is 50um
Output Results Display
<input_name>_CN.h5ad
h5ad file containing cellular neighborhood analysis results, storing CN cluster labels and cell composition information
For whole-slice analysis, CN info is in adata.obs['cell_neighbor']
For target_celltype analysis, CN info for target_celltype is in adata.obs['target_CN']
Neighbor cell info is in adata.obs['neighbor_regions']
Classification info for target_celltype and neighbor cells is in adata.obs['target_CN_neighbor']
<input_name>_celltype_percent_of_CN.csv
Composition ratio of cell types in each cellular neighborhood
<input_name>_CN_percent_of_samples.csv
Composition ratio of cellular neighborhoods in each sample for multi-sample analysis
<input_name>_celltype_percent_of_CN.png/pdf
Stacked bar plot of cell type composition in each cellular neighborhood
<input_name>_CN_percent_of_samples.png/pdf
Stacked bar plot of cellular neighborhood composition in each sample for multi-sample analysis
<input_name>_CN_umap.png/pdf
UMAP plot of cellular neighborhoods (output when cluster_method is leiden)
<input_name>_CN_enrichment.png/pdf
Heatmap of neighborhood enrichment, showing the enrichment of cell types in different cellular neighborhoods
<input_name>_CN_spatial.png/pdf
Spatial distribution plot of cellular neighborhoods, one plot per slice for multi-slice analysis
<input_name>_target_CN_neighbor_spatial.png/pdf
Spatial distribution plot of target cell and its neighbor cells (generated in singleCelltype mode and when target_celltype is specified), one plot per slice for multi-slice analysis
<input_name>_CN_spatial_split.png/pdf
Split spatial distribution plot of each cellular neighborhood, one plot per slice for multi-slice analysis
<input_name>_CN_celltype_neighborhood_enrichment.png/pdf
Neighborhood enrichment analysis plot of cell types in each cellular neighborhood
Stacked bar plot of cell type composition in each cellular neighborhood:
<input_name>_celltype_percent_of_CN.png/pdf
shows the composition ratio of different cell types in each cellular neighborhood. The x-axis is the CN index, the y-axis is the percentage of cell types, different colors represent different cell types, and the height of the bar represents the proportion of each cell type in the corresponding CN.

Stacked bar plot of cellular neighborhood composition in each sample for multi-sample analysis:
<input_name>_CN_percent_of_samples.png/pdf
shows the composition ratio of cellular neighborhoods in each sample for multi-sample analysis. The x-axis is the sample name, the y-axis is the percentage of CN, different colors represent different CNs, and the height of the bar represents the proportion of each CN in the corresponding sample.

Cellular neighborhood UMAP plot:
<input_name>_CN_umap.png/pdf
shows the clustering distribution of cellular neighborhoods in UMAP 2D space (output when cluster_method is leiden). Each point represents a cell, color indicates its CN, and cells with similar composition cluster together in UMAP space.

Neighborhood enrichment heatmap:
<input_name>_CN_enrichment.png/pdf
shows the enrichment of cell types in different CNs. The x-axis is cell type, the y-axis is CN, color depth indicates enrichment degree, red indicates enrichment, blue indicates depletion.

Spatial distribution plot of cellular neighborhoods:
<input_name>_CN_spatial.png/pdf
shows the spatial distribution of CNs on tissue sections, one plot per slice for multi-slice analysis. Each point represents a cell, color indicates its CN, and cells with the same color cluster together to form specific CN regions in space.

Split spatial distribution plot of each cellular neighborhood:
<input_name>_CN_spatial_split.png/pdf
shows the spatial distribution of each CN on tissue sections, one plot per slice for multi-slice analysis. Each subplot shows the spatial distribution of one CN, colored points represent cells belonging to that CN, gray points represent other CNs, facilitating observation of spatial features of each CN.

Spatial distribution plot of target cell and its neighbor cells:
<input_name>_target_CN_neighbor_spatial.png/pdf
shows the spatial distribution of target cell and its neighbor cells on tissue sections, one plot per slice for multi-slice analysis. Each point represents a cell, color indicates its CN, and cells with the same color cluster together to form specific CN regions in space.


Neighborhood enrichment analysis plot of cell types in each CN:
<input_name>_CN_celltype_neighborhood_enrichment.png/pdf
shows the neighborhood enrichment analysis results of cell types in each CN, with both axes as cell types, color depth indicates enrichment significance.

Parameter Tuning Suggestions
window_method
parameter:fixed nearest neighbors: For each cell as center, select its n nearest neighbor cells in space to form a local window. Suitable for uneven cell distribution, ensures each window contains the same number of cells.
fixed radius: For each cell as center, select all cells within a certain coordinate distance (radius) to form a local window. Suitable for scenarios with clear physical meaning of spatial scale, the number of cells in the window can vary.
In short, fixed nearest neighbors focuses on "same number of neighbors", fixed radius focuses on "same spatial distance".
resolution
parameter: When cluster_method is leiden, for bin20 or cellbin data, recommend resolution <0.1, otherwise the number of clusters will be large.
Last updated