Skip to content

add pyDeseq2 variant of analysis - #15

Draft
enryH wants to merge 5 commits into
mainfrom
add_pyDeseq2
Draft

enryH wants to merge 5 commits into
mainfrom
add_pyDeseq2

Conversation

@enryH

@enryH enryH commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator
  • used Claude to translate Rmarkdown to Notebook
  • made small adaptions, but the equality of the results has to be still tested

Concepts form R seem to be translated to Python.

  • add Python to dockerimage with dependencies
  • ensure equality of results

- used Claude to translate Rmarkdown to Notebook
- made small adaptions, but the equality of the results has to be still tested

@enryH enryH left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Python/pyDESeq2-based differential expression analysis workflow alongside the existing R DESeq2 report, aiming to reproduce the treatment vs control contrast in a Jupyter-friendly format.

Changes:

  • Introduces a Jupytext-compatible Python notebook script implementing DE analysis with pyDESeq2 (including shrinkage, plots, and result export).
  • Loads nf-core merged gene counts + sample metadata, constructs a pyDESeq2 dataset, and runs the treatment vs control contrast.
  • Writes full and significant results tables and optionally compares overlap with existing R outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +39
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from pydeseq2.dds import DeseqDataSet
from pydeseq2.ds import DeseqStats
from scipy.stats import zscore
Comment on lines +26 to +29
# If needed, uncomment and run:
# conda create -n pydeseq2 python pip
# conda activate pydeseq2
# # %pip install pydeseq2 pandas numpy matplotlib seaborn scipy ipykernel
"## 1. Setup\n",
"Install dependencies if needed, then import libraries.\n",
"\n",
"Using conda (microforge recommended) and pip, you can install the required packages with the following commands:\n",

@sebschulz1 sebschulz1 Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful for some users to add a link to the microforge site to get installation instructions immediately (if they don't have conda installed yet)

@sebschulz1

Copy link
Copy Markdown
Collaborator

Testing procedure for comparison of pydeseq2 and R-DESeq2 results
I have pushed an analysis script and results to this PR. Results from the R and the Jupyter notebooks (both deposited in this branch) were compared by calculating difference and ratio of log2FC and padj values. Additionally, scatter plots were generated to compare original log2FC and padj values visually.
I compared the results of all genes and the ones from only significant genes.

Main findings
In general, the agreement between both packages seems to be good. However, additional in-depth analysis could be performed.
I noted that certain genes are in output tables from pyDESeq2 but not in those from R-DESeq2 (missing values for such genes were replaced by zeros to be able to plot them). This observation was discussed with @Juassis and it likely stems from a pre-filtering step in the R scripts to delete low-count reads. However, this needs to be verified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants