RAD-seqやMIG-seqの解析をする際に必要なSNP検出ソフト、Stacksのインストール方法について説明します。初心者向けの超基礎的な内容です。
ここでは、MacOSの場合で説明します。
2021年8月5日:内容変更
Homebrewやbiocondaで提供されているStacksは最新版ではないので、公式HPからダウンロードする方法を追記。現状ではこの方法が一番いいです。
Stacksのインストール(公式HPからの場合)
以降の作業はターミナルで行います。
まず、アプリケーションなど、適当なディレクトリに移動します。
公式ホームページからcurl
コマンドを使って最新版をダウンロードします(Linuxの人はwget
)。
ダウンロードしたフォルダを解凍して、中に入ります。
cd /Applications #適当なディレクトリに移動
curl -O http://catchenlab.life.illinois.edu/stacks/source/stacks-2.68.tar.gz #公式サイトからインストール。Stacksのバージョンは最新版に変えてください。
tar xfvz stacks-2.59.tar.gz #フォルダの解凍
cd stacks-2.68
普通にコンパイルしてみます。
./configure
make -j 16 #スレッド数を指定
sudo make install
この時、以下のような警告が出ている場合があります(エラーではないので、コンパイルはできる)。
configure: WARNING: Unable to locate OpenMP library, you should probably specify '--disable-openmp'.
OpenMPライブラリを参照できないと、解析が並列処理できずに時間が掛かってしまいます。この場合は、gccをconfigureのオプションで指定してやるとうまく行く場合があります。
gccのインストールはHomebrewを使うと簡単にできます(brew install gcc
)。Homebrewでインストールされているgccのバージョンはbrew info gcc
やls /opt/homebrew/bin/gcc-*
で確認できます。
./configure CXX=g++-15 CC=gcc-15
# gccのバージョンは自分の環境に合わせる
make -j 16 #スレッド数を指定
sudo make install
M1やM2チップなどのAppleシリコン搭載Macの方は、ターミナルをRosettaを利用して開いてください。
OpenMP関連の警告やエラーが出る場合はコンパイル時にOpenMPを指定するオプションを付けるとうまくいく場合があります → ./configure CC=gcc-15 CXX=g++-15 CFLAGS="-fopenmp" CXXFLAGS="-fopenmp"
Stacksのインストール(Homebrewを使う場合)
事前にMac用のパッケージマネージャであるHomebrewをインストールしておきます。
インストールは公式サイトにあるスクリプトをターミナルにコピペして実行するだけです。
Homebrewがインストールできたら、Stacksをインストールします。
まず、バイオインフォマティクス系のパッケージをbrew tap brewsci/bio
でHomebrewのリストに加えます。
準備ができたら、Stacksをbrew install stacks
でインストールします。
注意
Homebrewでの導入は楽ですが、Stacksの最新版が提供されていないので、公式HPからダウンロードする方法を推奨します。
Stacksを使ってみよう
とりあえず起動してみる。
既にパスが通っているはずなので、いちいちプログラムのあるディレクトリを指定する必要はありません。
ustacksのバージョン確認
$ ustacks -v
ustacks 2.68
sstacksのヘルプ表示
% denovo_map.pl -h #denovo_map.plのオプションの一覧を表示
denovo_map.pl 2.68
denovo_map.pl --samples dir --popmap path --out-path dir [--paired [--rm-pcr-duplicates]] (assembly options) (filtering options) [-X prog:"opts" ...]
Input/Output files:
--samples: path to the directory containing the reads files for each sample.
--popmap: path to a population map file (format is "<name> TAB <pop>", one sample per line).
-o,--out-path: path to an output directory.
General options:
-X: additional options for specific pipeline components, e.g. -X "populations: --min-maf 0.05".
-T, --threads: the number of threads/CPUs to use (default: 1).
--dry-run: dry run. Do not actually execute anything, just print the commands that would be executed.
--resume: resume executing the pipeline from a previous run.
Stack assembly options:
-M: number of mismatches allowed between stacks within individuals (for ustacks).
-n: number of mismatches allowed between stacks between individuals (for cstacks; default: set to ustacks -M).
SNP model options:
--var-alpha: significance level at which to call variant sites (for gstacks; default: 0.05).
--gt-alpha: significance level at which to call genotypes (for gstacks; default: 0.05).
Paired-end options:
--paired: after assembling RAD loci, assemble mini-contigs with paired-end reads.
--rm-pcr-duplicates: remove all but one set of read pairs of the same sample that have
the same insert length.
Population filtering options:
-r,--min-samples-per-pop: minimum percentage of individuals in a population required to process a locus for that population (for populations; default: 0)
-p,--min-populations: minimum number of populations a locus must be present in to process a locus (for populations; default: 1)
For large datasets:
--catalog-popmap: path to a second population map file containing a subset of samples for use only in building the catalog.
Miscellaneous:
--time-components (for benchmarking)
ちゃんとインストールできてます。
トラブル
エラーで突然Stacksが動かなくなることが時々あります。
基本的にはStacksやCommand Line Toolsを再インストールしたり(xcode-select --install
を実行)、gccを更新したりすることで治ります(brew upgrade gcc
を実行)。
もっと楽な解決方法があるかもしれません。
% ustacks -v
dyld[92290]: Library not loaded: '/usr/local/opt/gcc/lib/gcc/11/libgomp.1.dylib'
Referenced from: '/usr/local/bin/ustacks'
Reason: tried: '/usr/local/opt/gcc/lib/gcc/11/libgomp.1.dylib' (no such file), '/usr/local/lib/libgomp.1.dylib' (no such file), '/usr/lib/libgomp.1.dylib' (no such file)
zsh: abort ustacks -v
下流の解析
引用文献
Rochette, N., A. Rivera‐Colón, and J. Catchen. 2019. Stacks 2: Analytical methods for paired‐end sequencing improve RADseq‐based population genomics. Molecular Ecology 28: 4737-4754. https://doi.org/10.1111/mec.15253
※本ページの一部のコーディングやトラブルシューティングにはChatGPTの助けを借りています。