集団構造解析①PCA(主成分分析-PLINKの場合)

主成分分析のツールとして、下記記事でFlashPCA2をご紹介しましたが、WSL2のUbuntuでは動作しない場合があることがわかりました。そこで今回は、PLINKを使った方法をご紹介します。

1. ダウンロードとインストール

上記のダウンロードサイトにアクセスし、Linux 64-bit(WSL2 Ubuntuの場合)のdownloadボタンを右クリックし、リンクのURLをコピーします。

続いて、下記のコマンドを順に実行し、プログラム類をダウンロード、展開します。

mkdir plink
cd plink
wget https://s3.amazonaws.com/plink1-assets/plink_linux_x86_64_20220402.zip #上記で右クリックコピーしたURL
unzip plink_linux_x86_64_20220402.zip

展開後のディレクトリを見ると、5つのファイルが入っています。このうち、plinkというファイルが目的のプログラムです。

$ ls
LICENSE  plink   prettify   toy.map   toy.ped

なお、WSL2のUbuntuでは、デフォルトで同名の「Plink」というソフトウェアがインストールされており、厄介なことにパスが通っています。単純にplinkと打つと、下記のような画面が表示されてしまい、目的のPLINKを使うことができません。

$ plink
Plink: command-line connection utility
Release 0.70
Usage: plink [options] [user@]host [command]
       ("host" can also be a PuTTY saved session name)
Options:
  -V        print version information and exit
  -pgpfp    print PGP key fingerprints and exit
  -v        show verbose messages
  -load sessname  Load settings from saved session
  -ssh -telnet -rlogin -raw -serial
            force use of a particular protocol
  -P port   connect to specified port
  -l user   connect with specified username
  -batch    disable all interactive prompts
  -proxycmd command
            use 'command' as local proxy
  -sercfg configuration-string (e.g. 19200,8,n,1,X)
            Specify the serial configuration (serial only)
The following options only apply to SSH connections:
  -pw passw login with specified password
  -D [listen-IP:]listen-port
            Dynamic SOCKS-based port forwarding
  -L [listen-IP:]listen-port:host:port
            Forward local port to remote address
  -R [listen-IP:]listen-port:host:port
            Forward remote port to local address
  -X -x     enable / disable X11 forwarding
  -A -a     enable / disable agent forwarding
  -t -T     enable / disable pty allocation
  -1 -2     force use of particular protocol version
  -4 -6     force use of IPv4 or IPv6
  -C        enable compression
  -i key    private key file for user authentication
  -noagent  disable use of Pageant
  -agent    enable use of Pageant
  -hostkey aa:bb:cc:...
            manually specify a host key (may be repeated)
  -m file   read remote command(s) from file
  -s        remote command is an SSH subsystem (SSH-2 only)
  -N        don't start a shell/command (SSH-2 only)
  -nc host:port
            open tunnel in place of session (SSH-2 only)
  -sshlog file
  -sshrawlog file
            log protocol details to a file
  -shareexists
            test whether a connection-sharing upstream exists

そこで、下記の要領で目的のPLINKが優先的に起動されるよう、パスを通し直しましょう。

$ export PATH=/where/to/install/plink:$PATH

そうすると、plinkと打つだけで目的のPLINKが起動できるようになります。

$ plink
PLINK v1.90b6.16 64-bit (17 Feb 2020)          www.cog-genomics.org/plink/1.9/
(C) 2005-2020 Shaun Purcell, Christopher Chang   GNU General Public License v3

  plink <input flag(s)...> [command flag(s)...] [other flag(s)...]
  plink --help [flag name(s)...]

Commands include --make-bed, --recode, --flip-scan, --merge-list,
--write-snplist, --list-duplicate-vars, --freqx, --missing, --test-mishap,
--hardy, --mendel, --ibc, --impute-sex, --indep-pairphase, --r2, --show-tags,
--blocks, --distance, --genome, --homozyg, --make-rel, --make-grm-gz,
--rel-cutoff, --cluster, --pca, --neighbour, --ibs-test, --regress-distance,
--model, --bd, --gxe, --logistic, --dosage, --lasso, --test-missing,
--make-perm-pheno, --tdt, --qfam, --annotate, --clump, --gene-report,
--meta-analysis, --epistasis, --fast-epistasis, and --score.

"plink --help | more" describes all functions (warning: long).

2. PLINKを用いたPCA

まず、下の記事を参考に、VCFファイルのフィルタリングを行ってください。

準備できたVCFファイルはPLINK形式(ped & mapもしくはbed & bim & fam)に変換し、下記のコマンドによりPCAを行います。

$ plink --file filtered_filename --pca サンプル数 'tabs' 'header' --out お好きなファイル名

サンプル数は整数で入力します。サンプル数と同数の主成分が出力されます。’tabs’を入力することで結果ファイルがタブ区切りとなり、’header’を入力することで、結果ファイルにヘッダー行が出力されます。結果は–outオプションに指定したファイル名で出力され、.eigenvecに主成分が、.eigenvalに各主成分が占める分散(固有値)が出力されます。

Follow me!

コメント

PAGE TOP
タイトルとURLをコピーしました