0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【ChIP-seq解析環境構築】Bioconda・MACS2・Python地獄を乗り越えてDockerで写経準備完了した話

Posted at

Jupyter NotebookでChIP-seq実行環境を作りたい (2025年7月現在)

はじめに

バイオインフォマティクス初学者の私は次世代シーケンサー解析をまず実行しながら手順を確認したい。
ローカルの仮想環境を用意して、遊べるようにしておこう。
困ったら生成AIに聞けばサクッとできるでしょう、というノリで実行したらなかなかにハマりました。

この記事で得られるもの

  • ChIP-seq解析をローカルで写経しながら学びたい人向けの、最小構成Docker環境の作り方
  • Bioconda依存地獄・pip install失敗・Pythonバージョン問題など、2025年時点の最新トラブル対応策
  • Jupyter NotebookでChIP-seqを再現可能な環境の作り方

目的と背景

  • ChIP-seq・RNA-seq・ATAC-seqなどのNGS解析をローカルで写経して学びたい!
  • でも「FastQCとかMACS2とか何入れたらいいの?依存関係ムズすぎ!」と毎回詰む💥
  • 今回は、Docker + Conda + Jupyter構成で、ChIP-seq用に必要最小限だけを詰め込んだ環境を作るのがゴール。

💥 詰んだ履歴(時系列)

1. Docker + Conda + Bioconda で一括インストール →

RUN conda install -y fastqc cutadapt samtools bedtools bowtie2 macs2 deeptools \
    jupyterlab ipykernel pandas matplotlib seaborn && conda clean -afy

condaの依存関係が地獄。macs2deeptoolsが壊滅的に衝突。

2. RとPython全部のせでBioconda依存性+Rパッケージバージョン整合性問題にハマる → 💣

r-base=4.2が入らない。bioconductorと衝突。Rは別Dockerに分離すべきと痛感。

3. mambaで解決しよう! → 💣

RUN conda install -y -c conda-forge mamba && \
    mamba install -y fastqc cutadapt ...

mambaは爆速だけど、やっぱりmacs2で死ぬ。

4. macs2pip installで入れよう! → 💣

RUN pip install MACS2

gccがなくてビルド失敗。

5. gcc入れてリトライ! → 💣

RUN apt-get update && apt-get install -y gcc make

→ 今度は Python 3.13MACS2 の C拡張ビルドが壊れる。

6. Python 3.13 がまだ MACS2 に正式対応していないと判明 → Python 3.10 にダウングレードして回避


最終的に成功したDockerfile(2025年版、完全動作確認済)

FROM continuumio/miniconda3

WORKDIR /workspace

# Pythonバージョン固定
RUN conda install -y python=3.10 && conda clean -afy

# Cビルド用パッケージ
RUN apt-get update && apt-get install -y gcc make

# チャネルとmamba
RUN conda config --add channels defaults && \
    conda config --add channels conda-forge && \
    conda config --add channels bioconda && \
    conda install -y -c conda-forge mamba && conda clean -afy

# NGSツール
RUN mamba install -y fastqc bowtie2 samtools && conda clean -afy

# Python周り
RUN mamba install -y jupyterlab ipykernel pandas matplotlib seaborn pip && conda clean -afy

# MACS2(pipで)
RUN pip install MACS2

EXPOSE 8888

CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--allow-root", "--no-browser"]

確認できたバージョン(全て動作確認済)

Python      3.10.13
FastQC      v0.12.1
Bowtie2     2.5.4
Samtools    1.22
MACS2       2.2.9.1

※次回はMACS3を使いたい


次にやること

  • GEOからSRRデータを取得して、写経用NotebookでChIP-seq再現
  • deeptools(bamCoverageなど)を後から追加してbigWig可視化
  • environment.yml化してGitHubに環境公開

まとめ

  • NGS系ツールは依存地獄の塊。焦らず分割インストール&バージョン固定がカギ
  • macs2はcondaじゃなくpip + Python 3.10がベスト
  • RとPythonは無理に一緒にしない。Rは別コンテナで管理!
  • 「動くDockerfile」は資産。写経前にまず環境作りを

反省:無双環境を目指すより、必要になってから入れたほうが無難🧬

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?