# Immune Infiltration Analysis Module

## Purpose

This module is based on IOBR and other R packages to perform tumor microenvironment (TME) immune infiltration analysis from bulk RNA-Seq data, supporting multiple mainstream immune infiltration algorithms, and outputting standardized result tables and visualization charts.

Supported immune infiltration and stromal scoring algorithms:

* **CIBERSORT**: Immune cell infiltration analysis based on linear support vector regression
* **EPIC**: Immune cell infiltration analysis based on constrained least squares method
* **MCPcounter**: Immune cell infiltration analysis based on gene set enrichment analysis
* **xCell**: Immune cell infiltration analysis based on gene set variation analysis
* **TIMER**: Immune cell infiltration analysis based on deconvolution algorithm
* **quanTIseq**: Quantitative immune cell infiltration analysis
* **ESTIMATE**: Tumor purity assessment based on gene expression profiles

## Input File Examples

* `expression` Expression matrix file: Each row represents a gene name, each column represents a sample name, values are corresponding expression levels, tab-separated

| GeneID | Sample1 | Sample2 | Sample3 |
| ------ | ------- | ------- | ------- |
| GENE1  | 1.234   | 2.345   | 3.456   |
| GENE2  | 4.567   | 5.678   | 6.789   |

* `clinical` Clinical information file: Each row represents a sample name, each column represents a clinical feature, tab-separated

| SampleID | tissue\_type.samples | age | gender |
| -------- | -------------------- | --- | ------ |
| Sample1  | Tumor                | 45  | Male   |
| Sample2  | Normal               | 50  | Female |
| Sample3  | Tumor                | 55  | Male   |

## Running Method

```bash
SDAS bulkValidate ​immuneScore --expression fpkm.txt --clinical clinical.txt --group_col tissue_type.samples --group_type discrete --output result_dir
```

## Input Parameter Description

| Parameter        | Required | Default  | Description                                                                                                                                 |
| ---------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **--expression** | **Yes**  |          | Expression matrix file path. Tab-separated, rows: gene IDs, columns: sample IDs, values: FPKM/TPM etc., cannot be raw counts, cannot be log |
| **--clinical**   | **Yes**  |          | Clinical information file path. Tab-separated, rows: sample IDs, columns: clinical features                                                 |
| **--group\_col** | **Yes**  |          | Grouping column name (must exist in clinical information file)                                                                              |
| **--output**     | **Yes**  |          | Output directory path                                                                                                                       |
| --group\_type    | No       | discrete | Grouping type: discrete/continuous, default discrete                                                                                        |

* `--group_type` **Grouping Type Description**

  * Discrete grouping (discrete): Directly use categorical variables in clinical information for grouping, e.g.: Tumor vs Normal, Stage I vs Stage II vs Stage III
  * Continuous grouping (continuous): Divide continuous variables into three groups by quantiles: Low, Medium, High

  ```
  Quantiles: 0%, 30%, 70%, 100%
  ```

## Output Results Display

| Result File                        | Description                                                  |
| ---------------------------------- | ------------------------------------------------------------ |
| `tme_combine.txt`                  | Combined results of all immune infiltration methods          |
| `tme_heatmap.png/pdf`              | TME immune infiltration heatmap                              |
| `StromaScore_heatmap.png/pdf`      | Stromal score heatmap                                        |
| `<method>_stacked_bar.png/pdf`     | Stacked bar chart of immune cell proportions for each method |
| `<method>_grouped_boxplot.png/pdf` | Grouped boxplot for each method                              |

* **Immune infiltration combined result table:** `tme_combine.txt` Each row represents one sample, each column represents infiltration scores of different immune cell types. In addition to different immune cell infiltration scores, there is also stromal score information. StromalScore\_estimate is the total amount of stromal cells, ImmuneScore\_estimate is the total amount of immune cells, ESTIMATEScore\_estimate is the non-tumor component, i.e., the total amount of stromal cells and immune cells. If these three columns have negative scores, it means there is almost no component of this type. The TumorPurity\_estimate column is the proportion of tumor cells, distributed from 0 to 1.

  | SampleID | Macrophages\_M2\_CIBERSORT | CD8\_T\_Cells\_EPIC | ... |
  | -------- | -------------------------- | ------------------- | --- |
  | Sample1  | 0.123                      | 0.456               | ... |
  | Sample2  | 0.234                      | 0.567               | ... |
* **Immune infiltration heatmap:** `tme_heatmap.png/pdf` Shows immune infiltration score heatmap of all samples, color indicates score level. Group is the grouping type set by --group\_col. The figure shows comparison between cancer area and non-cancer area. Methods are results of 6 immune infiltration methods in this module. Through this figure, you can see which methods distinguish target cells or similar cell types, and also see if there are overall differences between cancer area and normal tissue.

<figure><img src="https://3345087311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCggbEDCoTSjskIWVTMeM%2Fuploads%2Fgit-blob-625b721eee754c3387219309529500074c0b28e5%2Fp1.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

* **Stromal score heatmap:** `StromaScore_heatmap.png/pdf` Shows stromal score heatmap of samples. Stromal scores are used to quantify the degree of stromal cell and immune cell infiltration in tumor microenvironment (TME) and tumor purity.

<figure><img src="https://3345087311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCggbEDCoTSjskIWVTMeM%2Fuploads%2Fgit-blob-544fc0e52f71ab10381dd0e9862b4012df3906c9%2Fp2.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

* **Immune infiltration method visualization diagrams** (immune\_plots directory)

1. Stacked bar chart `<method>_stacked_bar.png/pdf`: Proportions of various immune cell types in different samples/groups.

<figure><img src="https://3345087311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCggbEDCoTSjskIWVTMeM%2Fuploads%2Fgit-blob-42e44dc55c1d46c4b836e51d873b4020271781a7%2Fp3.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

2. Grouped boxplot `<method>_grouped_boxplot.png/pdf`: Distribution of various immune cell types in different groups.

<figure><img src="https://3345087311-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCggbEDCoTSjskIWVTMeM%2Fuploads%2Fgit-blob-788c85f103843aeda25b62fd7b1ab12969da7533%2Fp4.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>

##
