# Differential Gene Expression

This modules enables users to run differential gene expression analysis.

## Command Form

The command form captures the information required to run the DGE analysis.

* Algorithm (*required*) - choice between `limma` (Microarray), `limma voom`, `DESeq2`, `EdgeR GLM` (bulk RNA-seq), `wilcoxon` (single-cell RNA-seq)
* Selection Type (*required*) - observation or data slice
  * If [`Observation`](#observation-based-group-selection)
    * Group By (*required*) - the observation used to separate the case and control groups (e.g.: disease)
    * Group (*required*) - value for the observation that represents the case (e.g.: lupus)
    * Reference (*required*) - value for the observation that represents the control (e.g.: healthy)
  * If [`Data Slice`](#data-slice-based-group-selection):
    * Case Group (*required*) - an existing data slice that represents the case group
    * Control Group (*required*) - an existing data slice that represents the control group
* p-value cufoff (*required*) - the adjusted p-value threshold to use for heatmap and volcano plotting
* Min abs log fold change (*required*) - the minimum absolute value fold fold change threshold for heatmap and volcano plotting
* Run GSEA with pre-ranked correlation - whether to chain a [GSEA](https://documentation.panomics.bio/documentation/analyses/analysis-workbench/gene-set-enrichment) command
* Gene Set Collections (*conditionally* *required*) - the gene set collections to use to perform GSEA (e.g.: KEGG, Reactome)

### Observation based group selection

When choosing the `Observation` selection type, the user needs to define the case and control groups using an observation field (Group By) and 2 values, one for the case (Group) and one for the control (Reference).&#x20;

Example:

* Group By: disease
* Group: lupus
* Reference: healthy

In Panomics, it's possible to submit multiple DGE computations with one form submission by using the `each` value. For single-cell RNA-seq analyses, the `Reference` field can also be set to `rest` , which results in a comparison between the case, usually a cluster, and all the other cells.

<div><figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2FDCtE46PhdtAuNN6rl8ao%2FScreenshot%202024-10-28%20at%2011.33.15.png?alt=media&#x26;token=f1966d49-8f85-4d13-bb33-04f7d0c01c66" alt="" width="345"><figcaption></figcaption></figure> <figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2FLxsF6LRbEw0z34KZwZzm%2FScreenshot%202024-10-28%20at%2009.32.01.png?alt=media&#x26;token=fc22c81e-be79-49e6-bc00-6f47a33fece1" alt="" width="344"><figcaption></figcaption></figure></div>

This form submission will result in "number of unique values of Predicted Cell Type observation" comparisons. Concretely, if there are 15 cell types, this will yield 15 comparison results.

### Data slice based group selection

When choosing the `Data Slice` selection type, the user needs to define the case and control groups by creating data slices. [Learn more about managing data slices here.](https://documentation.panomics.bio/documentation/analyses/data-slices)

<figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2FtjzXWxJopRgU7lZJB8Mb%2FScreenshot%202024-10-28%20at%2011.34.57.png?alt=media&#x26;token=767941ca-30dc-41a0-9d72-8988be7d688f" alt="" width="346"><figcaption></figcaption></figure>

## Results

Results can be displayed in either a [tile view](#tile-view) or a [grid view](#grid-view). Use the buttons next to the search bar to toggle the mode.

The quick search bar is visible only for [tile view](#tile-view) and it offers an easy way to get to any result. The name of the result is used for searching.

### Tile View

Each result in the tile view is a volcano plot that uses the command's p-value and logFC thresholds.

In the top left corner, we display the case N vs control N. In the top right corner, we display the number of up regulated and down regulated genes. To view a result, click on a tile.

<figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2F82cAYnVfRdOddCnihcID%2FScreenshot%202024-10-28%20at%2011.51.52.png?alt=media&#x26;token=7f98b566-3f24-44ee-b3fe-753ebd698a6d" alt=""><figcaption><p>Tile view</p></figcaption></figure>

### Grid View

Each row in the grid represents a result. To view a result, click on a row.

<figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2FMgGTBHbIZay6dcoQ5k6V%2FScreenshot%202024-10-28%20at%2011.57.14.png?alt=media&#x26;token=a9748528-437f-4409-a4b1-c69fc1bd6bb0" alt=""><figcaption><p>Grid view</p></figcaption></figure>

### Result Details View

The differential gene expression result page contains 5 tabs and includes an extra filtering option in the header.

By using the `Hide unannotated` switch control, the user can opt to remove LOC or Rik genes from the result.

#### Heatmap

<figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2FCvNmaoBRiwfUsTXTiLs1%2FScreenshot%202024-10-29%20at%2010.22.32.png?alt=media&#x26;token=4171bd34-8059-48ea-9453-2878567f6842" alt=""><figcaption><p>Heatmap</p></figcaption></figure>

The heatmap tab displays an interactive heatmap plot of the differentially expressed genes matching the desired adjusted p-value and log fold change thresholds. Users can quickly filter the plot by changing the thresholds or by inputing genes (manually or by selecting a gene list).

#### Volcano plot

<figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2FoTUwYLFp0M7CFH7RFX1x%2FScreenshot%202024-10-29%20at%2010.27.04.png?alt=media&#x26;token=9763d6f2-03f6-444a-9be1-be3528c96c25" alt=""><figcaption><p>Volcano plot</p></figcaption></figure>

The volcano plot tab displays an interactive volcano plot of the differentially expressed genes matching the desired adjusted p-value and log fold change thresholds. Users can quickly filter the plot by changing the thresholds or by inputing genes (manually or by selecting a gene list). Using the `Save Genes` button in the bottom left corner, users can create gene lists with the genes present in the viewport.

#### Violin plot

<figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2Ftg42Hboey4rw6QB1Ry5d%2FScreenshot%202024-10-29%20at%2010.26.50.png?alt=media&#x26;token=b45b467c-9d72-4469-abeb-4a33e382c5b0" alt=""><figcaption><p>Violin plots</p></figcaption></figure>

The violin plot tab enables the user to request the plotting of the desired genes. As these plots are generated on-demand, the plotting may take around 20-30 seconds to finish.

#### Data

<figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2F3op7TZLI6FTxERQspOQM%2FScreenshot%202024-10-29%20at%2010.27.42.png?alt=media&#x26;token=0f8eae53-3857-4a85-b31c-65ed107dec86" alt=""><figcaption></figcaption></figure>

The data tab displays the unfiltered differential gene expression result data. Users can use the filtering mechanisms offered by the grid to isolate genes based on p-value, log fold change or others. The `Save Genes` toolbar button enables users to quickly create gene lists.

#### Similarity

<figure><img src="https://3894776587-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUZMYHWMJyvkxhr9s6Lm5%2Fuploads%2FBTYi9OmFDhkpkh0Qkygt%2FScreenshot%202024-10-29%20at%2010.28.36.png?alt=media&#x26;token=fba668ba-62a7-4628-8a06-b047554ba900" alt=""><figcaption><p>Similarity</p></figcaption></figure>

The similarity tab displays the relationship of the current comparison, also known as a gene signature in Panomics, with respect to others in the data lake. [Learn more about gene signature similarity here.](https://documentation.panomics.bio/documentation/gene-signature-similarity)

## Video demonstration

TODO
