> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mantlebio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Differential gene expression from bulk RNAseq using Scanpy on Mantle

A bulk RNAseq gene expression matrix is a gene by sample matrix containing the raw or normalized counts of reads that were aligned to each gene in each sample. Once you have obtained a gene expression matrix (e.g. by processing a set of FASTQ files from different samples through the [Mantle `bulk-rnaseq` pipeline](/workflows/bulk_rnaseq_processing)), there a variety of tools that can be used to perform differential gene expression analysis, including the [Scanpy](https://scanpy.readthedocs.io/en/stable/) package in Python.

Gene expression matrices, also known as count matrices, can be stored in your Mantle Database using the `count_matrix` data type.

In this notebook, we analyze the gene level raw counts matrix obtained using STAR and Salmon through the `bulk-rnaseq` pipeline. The FASTQ data were originally from:

> Wu, A. C. K., Patel, H., Chia, M., Moretto, F., Frith, D., Snijders, A.
> P., & van Werven, F. J. (2018). Repression of divergent noncoding
> transcription by a sequence-specific transcription factor. Molecular
> Cell, 72(6), 942-954.e7. [https://doi.org/10.1016/j.molcel.2018.10.018](https://doi.org/10.1016/j.molcel.2018.10.018)

Using Scanpy, we load the count matrix into AnnData format, then normalize and transform the count matrix and perform principal component analysis.

<Frame>
  <img src="https://mintcdn.com/mantlebio/mJz8BnqgDQJVjlq8/workflows/assets/scanpy_pca.png?fit=max&auto=format&n=mJz8BnqgDQJVjlq8&q=85&s=c5e97d4e631348c8b59e1071b5481e73" width="771" height="431" data-path="workflows/assets/scanpy_pca.png" />
</Frame>

We use the PCA embedding to calculate sample-to-sample Euclidean distances.

<Frame>
  <img src="https://mintcdn.com/mantlebio/LUzPTXQRsMt8_AfM/workflows/assets/scanpy_euclidean_distance.png?fit=max&auto=format&n=LUzPTXQRsMt8_AfM&q=85&s=65a9c747d6138f6a5d9cf0abebc45484" width="950" height="872" data-path="workflows/assets/scanpy_euclidean_distance.png" />
</Frame>

We then use Scanpy to look at the top genes by mean expression for each condition.

<Frame>
  <img src="https://mintcdn.com/mantlebio/LUzPTXQRsMt8_AfM/workflows/assets/scanpy_dotplot.png?fit=max&auto=format&n=LUzPTXQRsMt8_AfM&q=85&s=cdd3255fa11d9acf24786b0651ed6f8c" width="1513" height="399" data-path="workflows/assets/scanpy_dotplot.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/mantlebio/mJz8BnqgDQJVjlq8/workflows/assets/scanpy_heatmap.png?fit=max&auto=format&n=mJz8BnqgDQJVjlq8&q=85&s=0e85730da1d6e47bbe94beb432433e79" width="1253" height="740" data-path="workflows/assets/scanpy_heatmap.png" />
</Frame>

Additionally, we use Scanpy to look at the top genes by log fold-change for each condition.

<Frame>
  <img src="https://mintcdn.com/mantlebio/mJz8BnqgDQJVjlq8/workflows/assets/scanpy_logfc_dotplot.png?fit=max&auto=format&n=mJz8BnqgDQJVjlq8&q=85&s=48f0a31e441a5ff5f655a535f87fa61b" width="1504" height="401" data-path="workflows/assets/scanpy_logfc_dotplot.png" />
</Frame>

Finally, we use the log fold-change to make volcano plots of differential gene expression for different conditions.

<Frame>
  <img src="https://mintcdn.com/mantlebio/mJz8BnqgDQJVjlq8/workflows/assets/scanpy_volcano_plot.png?fit=max&auto=format&n=mJz8BnqgDQJVjlq8&q=85&s=85c873155dbf10a8869b2ff187814510" width="855" height="547" data-path="workflows/assets/scanpy_volcano_plot.png" />
</Frame>
