macでインフォマティクス

macでインフォマティクス

HTS (NGS) 関連のインフォマティクス情報についてまとめています。

メタゲノムサンプルのクロスサンプル汚染をコントロールデータ無しで検出する CroCoDeEL

 

 メタゲノムシーケンスは微生物群集に関する知見を提供するが、サンプル間汚染などの技術的バイアスによってその精度が損なわれる可能性がある。この現象は、同時処理されたサンプル間で微生物成分が意図せず交換されることで発生し、微生物プロファイルを歪め、メタゲノムデータおよび下流解析の信頼性を損なう。既存の検出方法はネガティブコントロールに依存しているが、ネガティブコントロールは十分に活用されておらず、非コントロールサンプル内のクロスコンタミネーションを検出できない。一方、株レベルのバイオインフォマティクスアプローチは、汚染と自然な株の共有を区別できず、感度も低い。このギャップを埋めるため、サンプル間汚染の検出と定量化のための意思決定支援ツールであるCroCoDeELを導入する。CroCoDeELは、線形モデリングと事前学習済みの教師ありモデルを活用し、種存在量プロファイルにおける特定の汚染パターンを識別する。ネガティブコントロールやサンプル処理位置に関する事前知識は不要であり、精度と汎用性が向上する。 3つの公開データセットを用いたベンチマークテストにより、CroCoDeELは十分なシーケンス深度があれば、汚染率が低い場合(0.1%未満)でも、汚染サンプルを検出し、その汚染源を特定できることが実証された。また、既存の複数の研究にCroCoDeELを適用した結果、これまで検出されていなかった汚染が明らかになった。

 

レポジトリより

CroCoDeELは、ショットガンメタゲノムデータにおけるサンプル間汚染(ウェル間漏洩とも呼ばれる)を検出する。汚染されたサンプルを正確に特定するだけでなく、汚染源を特定し、汚染率を推定する。CroCoDeELは、種存在量テーブルのみに依存し、ネガティブコントロールや処理中のサンプル位置(プレートマップなど)を必要としない。

 

インストール

Github

mamba create --name crocodeel_env -c conda-forge -c bioconda crocodeel -y
conda activate crocodeel_env

#pipにも対応している(Python ≥ 3.12)
pip install crocodeel

> crocodeel -h

usage: crocodeel [-h] [-v] {easy_wf,search_conta,plot_conta,test_install,train_model} ...

 

CroCoDeEL is a tool that detects cross-sample contamination in shotgun metagenomic data

 

options:

  -h, --help            show this help message and exit

  -v, --version         show program's version number and exit

 

CroCoDeEL subcommands:

  {easy_wf,search_conta,plot_conta,test_install,train_model}

    easy_wf             Run search_conta and plot_conta in one command to detect cross-sample contamination and generate a PDF report

    search_conta        Search for cross-sample contamination

    plot_conta          Create a PDF report with scatterplots representing species abundance profiles for each contamination event

    test_install        Test if CroCoDeEL is correctly installed and generates the expected results

    train_model         Train the Random Forest model used by CroCoDeEL to classify sample pairs (for advanced users)

> crocodeel plot_conta -h

usage: crocodeel plot_conta [-h] -s SPECIES_ABUNDANCE_TABLE [-s2 SPECIES_ABUNDANCE_TABLE_2] [--filter-low-ab AB_THRESHOLD_FACTOR] -c CONTAMINATION_EVENTS_FILE -r PDF_REPORT_FILE [--nrow NROW]

                            [--ncol NCOL] [--no-conta-line] [--color-conta-species]

 

options:

  -h, --help            show this help message and exit

  -s SPECIES_ABUNDANCE_TABLE

                        Input TSV file corresponding to the species abundance table

  -s2 SPECIES_ABUNDANCE_TABLE_2

                        Optional input TSV file corresponding to another species abundance table. If provided, samples from this table will be considered as contamination targets while those from the

                        first table as contamination sources.

  --filter-low-ab AB_THRESHOLD_FACTOR

                        Filter out low-abundance species that may be inaccurately quantified. In each sample, set the abundance of species to zero if they are up to AB_THRESHOLD_FACTOR times more

                        abundant than the least abundant species. Recommended value for MetaPhlAn4: 20 (default: None)

  -c CONTAMINATION_EVENTS_FILE

                        Input TSV file listing all contaminations events.

  -r PDF_REPORT_FILE    Output PDF file with scatterplots for all contamination events

  --nrow NROW           Number of scatterplots to draw vertically on each page (default: 4)

  --ncol NCOL           Number of scatterplots to draw horizontally on each page (default: 4)

  --no-conta-line       Do not show contamination line in scatterplots

  --color-conta-species

                        Use a different color for species introduced by contamination

> crocodeel search_conta -h

usage: crocodeel search_conta [-h] -s SPECIES_ABUNDANCE_TABLE [-s2 SPECIES_ABUNDANCE_TABLE_2] [--filter-low-ab AB_THRESHOLD_FACTOR] [-m RF_MODEL_FILE] [--probability-cutoff PROBABILITY_CUTOFF]

                              [--rate-cutoff RATE_CUTOFF] -c CONTAMINATION_EVENTS_FILE [--nproc NPROC]

 

options:

  -h, --help            show this help message and exit

  -s SPECIES_ABUNDANCE_TABLE

                        Input TSV file corresponding to the species abundance table

  -s2 SPECIES_ABUNDANCE_TABLE_2

                        Optional input TSV file corresponding to another species abundance table. If provided, samples from this table will be considered as contamination targets while those from the

                        first table as contamination sources.

  --filter-low-ab AB_THRESHOLD_FACTOR

                        Filter out low-abundance species that may be inaccurately quantified. In each sample, set the abundance of species to zero if they are up to AB_THRESHOLD_FACTOR times more

                        abundant than the least abundant species. Recommended value for MetaPhlAn4: 20 (default: None)

  -m RF_MODEL_FILE      Joblib file containing the pre-trained Random Forest model used to detect contamination events (default: /home/kazu/miniforge3/envs/crocodeel_env/lib/python3.14/site-

                        packages/crocodeel/models/crocodeel_rf_Feb2026_2.joblib)

  --probability-cutoff PROBABILITY_CUTOFF

                        Only report contamination events with a probability greater than PROBABILITY_CUTOFF (default: 0.50)

  --rate-cutoff RATE_CUTOFF

                        Only report events with a contamination rate greater than RATE_CUTOFF (default: 0)

  -c CONTAMINATION_EVENTS_FILE

                        Output TSV file listing all contamination events

  --nproc NPROC         Number of parallel processes to search contaminations (default: 128)

> crocodeel easy_wf -h

usage: crocodeel easy_wf [-h] -s SPECIES_ABUNDANCE_TABLE [-s2 SPECIES_ABUNDANCE_TABLE_2] [--filter-low-ab AB_THRESHOLD_FACTOR] -c CONTAMINATION_EVENTS_FILE -r PDF_REPORT_FILE [--nproc NPROC]

 

options:

  -h, --help            show this help message and exit

  -s SPECIES_ABUNDANCE_TABLE

                        Input TSV file corresponding to the species abundance table

  -s2 SPECIES_ABUNDANCE_TABLE_2

                        Optional input TSV file corresponding to another species abundance table. If provided, samples from this table will be considered as contamination targets while those from the

                        first table as contamination sources.

  --filter-low-ab AB_THRESHOLD_FACTOR

                        Filter out low-abundance species that may be inaccurately quantified. In each sample, set the abundance of species to zero if they are up to AB_THRESHOLD_FACTOR times more

                        abundant than the least abundant species. Recommended value for MetaPhlAn4: 20 (default: None)

  -c CONTAMINATION_EVENTS_FILE

                        Output TSV file listing all contamination events

  -r PDF_REPORT_FILE    Output PDF file with scatterplots for all contamination events

  --nproc NPROC         Number of parallel processes to search contaminations (default: 128)

> crocodeel test_install #動作チエック

O.K !

 

実行方法

入力はTSV形式のspecies abundance table

1列目がspecies name
2列目以降が各サンプルのspecies abundance

species abundance tableの作成にはMeteor software suiteが強く推奨されている。MetaPhlAn4も利用可能だが、低レベル汚染の検出には失敗する可能性があるとされている。

 

テストラン

レポジトリのデータを使う

https://github.com/metagenopolis/CroCoDeEL/blob/main/crocodeel/test_data/mgs_profiles_test.tsv

 

1、汚染の検出

git clone https://github.com/metagenopolis/CroCoDeEL.git
crocodeel search_conta -s CroCoDeEL/crocodeel/test_data/mgs_profiles_test.tsv -c contamination_events.tsv
  • -s    Input TSV file corresponding to the species abundance table
  • -c    Output TSV file listing all contamination events

出力

head contamination_events.tsv

 

2、結果の可視化

crocodeel plot_conta -s species_abundance.tsv -c contamination_events.tsv -r contamination_events.pdf

出力

各パネルは1つの汚染候補を示す(全ペア間比較で汚染が疑われるもの)。

 

横軸が汚染源と推定されたサンプルで、縦軸が汚染されたと推定されたサンプル。各点は1つのspecies。灰色の線は、両サンプルで同じrelative abundanceを示す線。赤線は、推定された汚染率に基づくcontamination line。赤線上に多数のspeciesが並んでいるため、汚染が明瞭に見える。

タイトルのprobは汚染イベントの確率、rateは推定汚染率。この結果では、すべてのパネルでprob = 1.0となっており、CroCoDeELは強い汚染シグナルとして判定している。サンプルの取り違え、強いcross contamination、または処理過程での大きな混入が疑われる。

 

 easy_wfを使うと、一気に汚染検出から可視化まで実行できる。

crocodeel easy_wf -s species_abundance.tsv -c contamination_events.tsv -r contamination_events.pdf

 

その他

  • メタゲノムでも汚染が入ると、汚染源サンプルに多い菌が、汚染先サンプルに一定割合でまとめて薄まって現れる。そのため、species abundance tableだけから推定できる。
  • 汚染源に多いspeciesは、汚染先にも汚染率に応じた量でまとめて現れる。1種類の菌ではなく、多数のspeciesが同じ倍率で出ることを見るため、species abundance tableだけでも汚染パターンを推定できる。
  • log-scaleの散布図にすると、汚染由来のspeciesが1本の直線上に並ぶ。
  • サンプルAとサンプルBがもともとかなり似ている場合、汚染のパターンが出ることがありえるが、自然に似ているサンプルでは、共有speciesの存在量は近い値になりやすいため、点は灰色線付近に出やすくなる。一方、汚染では、汚染源のprofileが一定割合で薄まって入るので、点は灰色線ではなく赤線付近に並ぶため、区別できる。
  • ただし、近傍環境のサンプルで局所的な希釈があると片方がもう片方の薄めたようなプロファイルに見える可能性もありえる(結果は注意して解釈する)。
  • 上級者向けにRandom Forestモデルを自分のデータで再学習できる。学習に必要な入力は、species abundance tableと、汚染あり・汚染なしがラベル付けされたサンプルペア (レポジトリ参照)

引用

CroCoDeEL: accurate control-free detection of cross-sample contamination in metagenomic data

Lindsay Goulet, Florian Plaza Oñate, Alexandre Famechon, Benoît Quinquis, Eugeni Belda, Edi Prifti, Emmanuelle Le Chatelier & Guillaume Gautreau 

Nature Communications, Published: 09 May 2026

 

参考

 

関連