この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
BUSCO の実行環境に Docker コンテナ + AWS ParallelCluster(クラウドHPC)を利用してみました。コンテナを利用した AWS ParallelCluster で実行方法の一例を紹介します。
- Docker on AWS ParallelCluster の構築
- クラスター環境で BUSCO を実行
これまで
初回はローカルPCで BUSCO コンテナの実行確認をしました。
AWS を利用して単体のサーバー(EC2インスタンス)を利用して BUSCO の実行を行いました。
今回は AWS ParallelCluster(クラウドHPC)を利用して BUSCO を実行します。
AWS ParallelCluseter の準備
ParallelCluster の実行環境は以下のリンクを参考にしてください。
ParallelCluster で Docker コンテナを実行できる環境を作成します。詳細は以下のリンクを参考にしてください。
本検証で利用するクラスターのコンフィグファイルはこちらです。環境依存のパラメーターは適時変更してください。
- ヘッドノードのセクション(
HeadNode
)- SubnetId:
subnet-035be95eeaa091603
- KeyName:
sandbox-key
- SubnetId:
- コンピュートノードのセクション(
SlurmQueues
)subnet-035be95eeaa091603
- Postinstall スクリプト保存先の S3 バケット名(
BucketName:
)hpc-dev-postinstall-files
- Postainstall スクリプトへのフルパス(
Script:
)s3://hpc-dev-postinstall-files/sample-ubuntu-docker/postinstall.sh
Region: ap-northeast-1
Image:
Os: ubuntu2004
Monitoring:
Logs:
CloudWatch:
Enabled: true
RetentionInDays: 30
DeletionPolicy: "Delete"
Dashboards:
CloudWatch:
Enabled: false
Tags:
- Key: Name
Value: DockerOnParallelcluster314
HeadNode:
InstanceType: t3.micro
Networking:
ElasticIp: false
SubnetId: subnet-035be95eeaa091603
Ssh:
KeyName: sandbox-key
LocalStorage:
RootVolume:
Size: 35
Encrypted: false
VolumeType: gp3
Iops: 3000
Throughput: 125
Iam:
S3Access:
- BucketName: hpc-dev-postinstall-files
EnableWriteAccess: False
AdditionalIamPolicies:
- Policy: arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
Scheduling:
Scheduler: slurm
SlurmSettings:
ScaledownIdletime: 5
SlurmQueues:
# --- 1 ---
- Name: debug
ComputeResources:
- Name: debug
InstanceType: t3.micro
MinCount: 0
MaxCount: 10
DisableSimultaneousMultithreading: false
ComputeSettings:
LocalStorage:
RootVolume:
Size: 35
Encrypted: false
VolumeType: gp3
Iops: 3000
Throughput: 125
CapacityType: SPOT
Networking:
SubnetIds:
- subnet-035be95eeaa091603
PlacementGroup:
Enabled: false
CustomActions:
OnNodeConfigured:
Script: s3://hpc-dev-postinstall-files/sample-ubuntu-docker/postinstall.sh
Iam:
S3Access:
- BucketName: hpc-dev-postinstall-files
EnableWriteAccess: False
AdditionalIamPolicies:
- Policy: arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
# --- 2 ---
- Name: c6ilarge
ComputeResources:
- Name: c6ilarge
InstanceType: c6i.large
MinCount: 0
MaxCount: 10
DisableSimultaneousMultithreading: true
ComputeSettings:
LocalStorage:
RootVolume:
Size: 35
Encrypted: false
VolumeType: gp3
Iops: 3000
Throughput: 125
CapacityType: SPOT
Networking:
SubnetIds:
- subnet-035be95eeaa091603
PlacementGroup:
Enabled: true
CustomActions:
OnNodeConfigured:
Script: s3://hpc-dev-postinstall-files/sample-ubuntu-docker/postinstall.sh
Iam:
S3Access:
- BucketName: hpc-dev-postinstall-files
EnableWriteAccess: False
AdditionalIamPolicies:
- Policy: arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
# --- 3 ---
- Name: c6i32xlarge
ComputeResources:
- Name: c6i32xlarge
InstanceType: c6i.32xlarge
MinCount: 0
MaxCount: 10
DisableSimultaneousMultithreading: true
Efa:
Enabled: true
ComputeSettings:
LocalStorage:
RootVolume:
Size: 35
Encrypted: false
VolumeType: gp3
Iops: 3000
Throughput: 125
CapacityType: SPOT
Networking:
SubnetIds:
- subnet-035be95eeaa091603
PlacementGroup:
Enabled: true
CustomActions:
OnNodeConfigured:
Script: s3://hpc-dev-postinstall-files/sample-ubuntu-docker/postinstall.sh
Iam:
S3Access:
- BucketName: hpc-dev-postinstall-files
EnableWriteAccess: False
AdditionalIamPolicies:
- Policy: arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore
Postinstall 処理でコンピュートノードに Docker をインストールするスクリプトを S3 バケットに保存してあります。
s3://hpc-dev-postinstall-files/sample-ubuntu-docker/postinstall.sh
#! /bin/bash
apt-get update
apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io -y
BUSCO 実行
ヘッドノードでインプットファイルの用意と、コンピュートノード上の BUSCO コンテナ内で解析処理実行するためのスクリプトを作成します。
解析するインプットファイルの準備
ヘッドノードのホームディレクトリはコンピュートノードへ共有されるため共有ストレージとして利用します。ホームディレクトリに作業用の work
ディレクトリを作成し、コンピュートノードで起動するコンテナにマウントして、コンテナからアクセス可能なストレージとして利用します。
BUSCO で解析するテストデータを事前にダウンロードして用意します。前回同様にショウジョウバエのリファレンスゲノムをテストデータとして用います。
busco.sh
mkdir -p $HOME/work
cd ~/work
wget https://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/000/001/215/GCF_000001215.4_Release_6_plus_ISO1_MT/GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna.gz
gunzip GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna.gz
ジョブの作成
計算処理には c6i.32xlarge のインスタンスを1台使います。128 vCPU のインスタンスタイプですが、Hyper-Threading を無効化するため物理 64 コアのマシンになります。また、スポットインスタンスを利用し計算リソースのコストを抑えます。今現在ですと67%割引きですね、お得。
BUSCO の解析処理のパラメータは真核生物(eukaryotes
)のデータセットを使いダウンロードしたテストデータ(ショウジョウバエのリファレンスゲノム)を確認する内容です。Slurm 、Docker の設定はスクリプト内のコメントで説明します。
コンピュートノードの Docker コンテナで BUSCO を実行する以下のスクリプトを作成しました。
#! /bin/bash
#SBATCH -p c6i32xlarge # Slurm パーティション名を指定
#SBATCH -N 1
#SBATCH -n 64 # コア数を指定
set -e
set -u
set -o pipefail
# Conteiner Settings
HOST_DIR=$HOME/work # 作成した作業用ディレクトリを指定
CON_WD=/host_mount
# BSUCO Parameters
CON_IMG=quay.io/biocontainers/busco:5.3.2--pyhdfd78af_0 # Busco のイメージ名・タグを指定
INPUT=GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna # 作業用ディレクトリに保存した解析対象のインプットファイル名を指定
MODE=genome
LINEAGE=eukaryota
NCPU=64 # コア数を指定(引数の都合)
OUTF=`basename ${INPUT}`_BUSCO5_${SLURM_JOB_ID} # 出力結果を保存するディレクトリ名を指定
RUN_CMD="busco -i ${INPUT} -l ${LINEAGE} -o ${OUTF} -m ${MODE} -c ${NCPU} -r" # 解析コマンドのパラメータを指定
CON_ID=`sudo docker run -dit --mount type=bind,src=$HOST_DIR,dst=$CON_WD --workdir $CON_WD $CON_IMG` # コンテナを起動
sudo docker exec -t ${CON_ID} ${RUN_CMD} # 起動したコンテナで解析コマンドを実行
sudo docker stop ${CON_ID} &> /dev/null
ジョブのサブミット
$ sbatch busco.sh
Submitted batch job 7
コンピュートノードが起動し作成したスクリプトが実行されます。
実行結果確認
ジョブの実行結果を確認します。まず Busco の Docker イメージを pull するところからはじまります。Busco コンテナが起動し指定した実行内容が走りました。約4分半(Total running time: 255 seconds
)で解析が終了しています。
slurm-7.out
Unable to find image 'quay.io/biocontainers/busco:5.3.2--pyhdfd78af_0' locally
5.3.2--pyhdfd78af_0: Pulling from biocontainers/busco
aa44502a478a: Pulling fs layer
bef3901422b5: Pulling fs layer
b6572cc046f2: Pulling fs layer
6dbbfe98ccd4: Pulling fs layer
4ca545ee6d5d: Pulling fs layer
d7cc672bfaf9: Pulling fs layer
6dbbfe98ccd4: Waiting
d7cc672bfaf9: Waiting
b6572cc046f2: Download complete
6dbbfe98ccd4: Verifying Checksum
6dbbfe98ccd4: Download complete
bef3901422b5: Verifying Checksum
bef3901422b5: Download complete
4ca545ee6d5d: Verifying Checksum
4ca545ee6d5d: Download complete
aa44502a478a: Verifying Checksum
aa44502a478a: Download complete
aa44502a478a: Pull complete
bef3901422b5: Pull complete
b6572cc046f2: Pull complete
6dbbfe98ccd4: Pull complete
4ca545ee6d5d: Pull complete
d7cc672bfaf9: Verifying Checksum
d7cc672bfaf9: Download complete
d7cc672bfaf9: Pull complete
Digest: sha256:900fc79245c3f6df7b2efe986d030c9a5f6fe21f1f000a4e6f09ff41da7def42
Status: Downloaded newer image for quay.io/biocontainers/busco:5.3.2--pyhdfd78af_0
2022-06-18 06:02:55 INFO: ***** Start a BUSCO v5.3.2 analysis, current time: 06/18/2022 06:02:55 *****
2022-06-18 06:02:55 INFO: Configuring BUSCO with local environment
2022-06-18 06:02:55 INFO: Mode is genome
2022-06-18 06:02:55 WARNING: Restart mode not available as directory /host_mount/GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna_BUSCO5_7 does not exist.
2022-06-18 06:02:55 INFO: Downloading information on latest versions of BUSCO data...
2022-06-18 06:02:57 INFO: Input file is /host_mount/GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna
2022-06-18 06:02:58 INFO: Running BUSCO using lineage dataset eukaryota_odb10 (eukaryota, 2020-09-10)
2022-06-18 06:02:58 INFO: Running 1 job(s) on metaeuk, starting at 06/18/2022 06:02:58
2022-06-18 06:05:11 INFO: [metaeuk] 1 of 1 task(s) completed
2022-06-18 06:05:12 INFO: ***** Run HMMER on gene sequences *****
2022-06-18 06:05:12 INFO: Running 255 job(s) on hmmsearch, starting at 06/18/2022 06:05:12
2022-06-18 06:05:13 INFO: [hmmsearch] 26 of 255 task(s) completed
2022-06-18 06:05:13 INFO: [hmmsearch] 51 of 255 task(s) completed
2022-06-18 06:05:13 INFO: [hmmsearch] 77 of 255 task(s) completed
2022-06-18 06:05:13 INFO: [hmmsearch] 77 of 255 task(s) completed
2022-06-18 06:05:13 INFO: [hmmsearch] 102 of 255 task(s) completed
2022-06-18 06:05:13 INFO: [hmmsearch] 102 of 255 task(s) completed
2022-06-18 06:05:13 INFO: [hmmsearch] 128 of 255 task(s) completed
2022-06-18 06:05:13 INFO: [hmmsearch] 128 of 255 task(s) completed
2022-06-18 06:05:14 INFO: [hmmsearch] 153 of 255 task(s) completed
2022-06-18 06:05:14 INFO: [hmmsearch] 153 of 255 task(s) completed
2022-06-18 06:05:14 INFO: [hmmsearch] 179 of 255 task(s) completed
2022-06-18 06:05:14 INFO: [hmmsearch] 204 of 255 task(s) completed
2022-06-18 06:05:14 INFO: [hmmsearch] 230 of 255 task(s) completed
2022-06-18 06:05:14 INFO: [hmmsearch] 230 of 255 task(s) completed
2022-06-18 06:05:14 INFO: [hmmsearch] 255 of 255 task(s) completed
2022-06-18 06:05:15 INFO: Extracting missing and fragmented buscos from the file refseq_db.faa...
2022-06-18 06:05:17 INFO: Running 1 job(s) on metaeuk, starting at 06/18/2022 06:05:17
2022-06-18 06:07:06 INFO: [metaeuk] 1 of 1 task(s) completed
2022-06-18 06:07:06 INFO: ***** Run HMMER on gene sequences *****
2022-06-18 06:07:06 INFO: Running 1 job(s) on hmmsearch, starting at 06/18/2022 06:07:06
2022-06-18 06:07:07 INFO: [hmmsearch] 1 of 1 task(s) completed
2022-06-18 06:07:08 INFO: Validating exons and removing overlapping matches
2022-06-18 06:07:08 INFO: Results: C:99.6%[S:99.6%,D:0.0%],F:0.4%,M:0.0%,n:255
2022-06-18 06:07:12 INFO:
--------------------------------------------------
|Results from dataset eukaryota_odb10 |
--------------------------------------------------
|C:99.6%[S:99.6%,D:0.0%],F:0.4%,M:0.0%,n:255 |
|254 Complete BUSCOs (C) |
|254 Complete and single-copy BUSCOs (S) |
|0 Complete and duplicated BUSCOs (D) |
|1 Fragmented BUSCOs (F) |
|0 Missing BUSCOs (M) |
|255 Total BUSCO groups searched |
--------------------------------------------------
2022-06-18 06:07:12 INFO: BUSCO analysis done with WARNING(s). Total running time: 255 seconds
***** Summary of warnings: *****
2022-06-18 06:02:55 WARNING:busco.BuscoConfig Restart mode not available as directory /host_mount/GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna_BUSCO5_7 does not exist.
2022-06-18 06:07:12 INFO: Results written in /host_mount/GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna_BUSCO5_7
2022-06-18 06:07:12 INFO: For assistance with interpreting the results, please consult the userguide: https://busco.ezlab.org/busco_userguide.html
2022-06-18 06:07:12 INFO: Visit this page https://gitlab.com/ezlab/busco#how-to-cite-busco to see how to cite BUSCO
解析した内容の出力先に指定したディレクトリを確認します。インプットファイル名 + BUSCO5 + ジョブID の命名のディレクトリが作成されています。
$ ls -l ~/work/
total 142252
-rw-rw-r-- 1 ubuntu ubuntu 145657746 Oct 31 2014 GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna
drwxr-xr-x 4 root root 4096 Jun 18 06:07 GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna_BUSCO5_7
drwxr-xr-x 3 root root 4096 Jun 18 03:30 busco_downloads
そのディレクトリの中からサマリファイルを確認します。テストデータにリファレンスゲノムを使っているため、精度の高い結果になって当然という理解でいます。
short_summary.specific.eukaryota_odb10.GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna_BUSCO5_7.txt
# BUSCO version is: 5.3.2
# The lineage dataset is: eukaryota_odb10 (Creation date: 2020-09-10, number of genomes: 70, number of BUSCOs: 255)
# Summarized benchmarking in BUSCO notation for file /host_mount/GCF_000001215.4_Release_6_plus_ISO1_MT_genomic.fna
# BUSCO was run in mode: genome
# Gene predictor used: metaeuk
***** Results: *****
C:99.6%[S:99.6%,D:0.0%],F:0.4%,M:0.0%,n:255
254 Complete BUSCOs (C)
254 Complete and single-copy BUSCOs (S)
0 Complete and duplicated BUSCOs (D)
1 Fragmented BUSCOs (F)
0 Missing BUSCOs (M)
255 Total BUSCO groups searched
Dependencies and versions:
hmmsearch: 3.1
metaeuk: 5.34c21f2
スパコンを作るところからはじめて簡単な解析の実行まで終わりました。手軽に強力なマシンを使いたいときに使いたい分だけ使えるのでクラウド HPC のご利用も検討してみてはいかがでしょうか?
おわりに
ここまで同じテストデータで実行環境を変えて BUSCO で解析処理を試してみました。計算時間を比較すると処理能力の違いが実行時間の短縮に貢献していることがわかります。今回 ParallelCluster でクラスター環境を構築しましたが1ノードでの実行でしたので並列実行で処理性能を稼いだわけではありませんでした。キューを備えた実行環境という意味では EC2 単体で計算を実行するよりは便利なので興味があれば試してみてください。
課題は AWS + Docker + HPC + ゲノムインフォマティクスの複合技なので学習コストの高さが導入障壁になる感じはします。悩んでいても進まないので小さくはじめてみましょう!
ゲノム科学研究に必要とされる事前知識 - Laboratory for Bioinformatics ResearchLaboratory for Bioinformatics Research