> For the complete documentation index, see [llms.txt](https://mysite.gitbook.io/sdas_manual_eng/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mysite.gitbook.io/sdas_manual_eng/readme/03_quickstart.md).

# Quick Start

## 0. Test Information

### Test Data:

```
./Test_data
```

### Test Scripts:

```
./Scripts/quick_start
```

## 1. Obtain Files Output by SAW

Method 1: Directly download the h5ad file output by `SAW count`

Method 2: Convert gef to h5ad: `saw convert gef2h5ad --gef=sample.tissue.gef --bin-size=100 --h5ad=sample.h5ad`

Method 3: Directly download the h5mu file output by `SAW aggr(alpha ver.)`

## 2. Cell Type Annotation

**cell2locationMakeRef: Build single-cell reference data**

```bash
SDAS cellAnnotation cell2locationMakeRef --reference ../Test_data/single_slice/sample_ref.h5ad -o ../output/cellAnnotation_cell2location_ref --label_key annotation2 --filter_rare_cell 0 --cell_percentage_cutoff2 0.05 --nonz_mean_cutoff 1.45 --gpu_id 0
```

**cell2location**

```bash
SDAS cellAnnotation cell2location -i ../Test_data/single_slice/sample.h5ad -o ../output/cell2location --reference_csv ../output/cellAnnotation_cell2location_ref/sample_ref_inf_aver.csv --input_gene_symbol_key _index --bin_size 100 --gpu_id 0
```

**RCTD**

```bash
SDAS cellAnnotation rctd -i ../Test_data/single_slice/sample.h5ad -o ../output/cellAnnotation_rctd --reference ../Test_data/single_slice/sample_ref.h5ad --label_key annotation2 --input_gene_symbol_key _index --filter_rare_cell 0 --bin_size 100
```

## 3. Spatial Domain Identification

**graphST**

```bash
SDAS spatialDomain graphst -i ../Test_data/single_slice/sample.h5ad -o ../output/spatialDomain_graphST --gpu_id 0 --tool mclust --n_clusters 10 --n_hvg 3000 --bin_size 100
```

## 4. Cellular Neighborhood Analysis

```bash
SDAS cellularNeighborhood singleCelltype -i ../output/cellAnnotation_rctd/sample_anno_rctd.h5ad -o ../output/cellularNeighborhood_singleCelltype --bin_size 100 --label_key anno_rctd
```

## 5. CNV Analysis

**Use the h5ad after cell annotation, prepare the rds file:**

```bash
SDAS dataProcess h5ad2rds -i ../output/cellAnnotation_rctd/sample_anno_rctd.h5ad -o ../output/cellAnnotation_rctd
```

**Run inferCNV**

```bash
SDAS infercnv -i ../output/cellAnnotation_rctd/sample_anno_rctd.rds --h5ad ../output/cellAnnotation_rctd/sample_anno_rctd.h5ad -o ../output/infercnv --bin_size 100 --label_key anno_rctd --gene_symbol_key _index --species human --cutoff 0.02 --ref_group_names Mac_SPP1,Monocyte_S100A8,Plasma_IgG,CD8_Tem
```

## 6. Spatial Gene Co-expression Analysis

**hdWGCNA**

```bash
SDAS coexpress hdwgcna -i ../Test_data/single_slice/sample.h5ad -o ../output/coexpress_hdwgcna --bin_size 100 --selected_genes top5000
```

## 7. Differential Gene Analysis

**wilcoxon**

```bash
SDAS DEG -i ../output/spatialDomain_graphST/sample_domain_graphst.h5ad -o ../output/DEG_wilcoxon --de_method wilcoxon --group_key domain_graphst --ident1 3 --ident2 8
```

## 8. Gene Set Enrichment Analysis

**GSEA**

```bash
SDAS geneSetEnrichment gsea -i ../output/spatialDomain_graphST/sample_domain_graphst.h5ad -o ../output/geneSetEnrichment_gsea --species human --group_key domain_graphst --ident1 3 --ident2 8 --gmt sdas_deg_enrichment/lib/GSEADB/h.all.v2024.1.Hs.symbols.gmt
```

**Enrichr**

```bash
SDAS geneSetEnrichment enrichr -i ../output/DEG_wilcoxon/de_wilcoxon.domain_graphst.3-vs-8.sig_filtered.csv -o ../output/geneSetEnrichment_enrichr --species human --cut_off 0.05
```

## 9. Protein-Protein Interaction

```bash
SDAS PPI -i ../Test_data/PPI/gene_300.txt -o ../output/PPI --species human --cluster GN
```

## 10. Cell Communication Analysis

**cellchat**

```bash
SDAS CCI cellchat -i ../output/cellAnnotation_rctd/sample_anno_rctd.h5ad -o ../output/CCI_cellchat_nospatial --label_key anno_rctd --gene_symbol_key _index --species human --type truncatedMean
```

## 11. Trajectory Analysis

**Use the h5ad after annotation, prepare the rds file:**

```bash
SDAS dataProcess h5ad2rds -i ../output/cellAnnotation_rctd/sample_anno_rctd.h5ad -o ../output/cellAnnotation_rctd
```

**Run monocle3:**

```bash
SDAS trajectory monocle3 -i ../output/cellAnnotation_rctd/sample_anno_rctd.rds -o ../output/trajectory_monocle3 --gene_symbol_key _index --root_key anno_rctd --root CAF_CXCL14
```

## 12. Transcription Factor Analysis

```bash
SDAS TF -i ../output/cellAnnotation_rctd/sample_anno_rctd.h5ad -o ../output/TF --label_key anno_rctd --gene_symbol_key _index --species human
```

## 13. Spatial Relationship Analysis

**squidpy**

```bash
SDAS spatialRelate squidpy -i ../output/cellAnnotation_rctd/sample_anno_rctd.h5ad -o ../output/spatialRelate_squidpy --label_key anno_rctd --bin_size 100 --min_cells_per_type 3 --coord_type grid 
```

## 14. Public Data Validation

**immuneScore**

```bash
SDAS bulkValidate immuneScore --expression ../Test_data/bulkValidate/fpkm.txt --clinical ../Test_data/bulkValidate/clinical.txt -o ../output/bulkValidate_immuneScore --group_col tissue_type.samples --group_type discrete
```

**survivalKM**

```bash
SDAS bulkValidate survivalKM --input ../output/bulkValidate_immuneScore/tme_combine.txt --clinical ../Test_data/bulkValidate/clinical.txt -o ../output/bulkValidate_survivalKM --signature Macrophages_M2_CIBERSORT --project_name survival --time OS.time --status OS.status --time_type day
```
