macでインフォマティクス

macでインフォマティクス

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

複数ファイルのk-merをカウントし、共通/固有のk-merを抽出する Genome Tester4

 2020 12/29 タイトル修正 複数ファイルのk-merをカウントし、共通/固有のk-merを抽出できる Genome Tester4 =>複数ファイルのk-merをカウントし、共通/固有のk-merを抽出する Genome Tester4

 

GenomeTester4はk-merをカウントしたり、操作するためのパッケージ。 固有のk-merを調べたりもできる。

  

インストール

Github

https://github.com/bioinfo-ut/GenomeTester4

git clone https://github.com/bioinfo-ut/GenomeTester4.git
cd GenomeTester4/src/
make clean
make

#conda
mamba install -c bioconda genometester4 -y

> ./glistmaker -h

$ ./glistmaker -h

Usage: glistmaker <INPUTFILES> [OPTIONS]

Options:

    -v, --version           - print version information and exit

    -h, --help              - print this usage screen and exit

    -w, --wordlength NUMBER - specify index wordsize (1-32) (default 16)

    -c, --cutoff NUMBER     - specify frequency cut-off (default 1)

    -o, --outputname STRING - specify output name (default "out")

    --num_threads           - number of threads the program is run on (default MIN(8, num_input_files))

    --max_tables            - maximum number of temporary tables (default MAX(num_threads, 2))

    --table_size            - maximum size of the temporary table (default 500000000)

    -D                      - increase debug level

> ./glistquery -h

src]$ ./glistquery -h

Usage: glistquery <INPUTLIST> [OPTIONS]

Options:

    -v, --version             - print version information and exit

    -h, --help                - print this usage screen and exit

    -stat                     - print statistics of the list file and exit

    -median                   - print min/max/median/average and exit

    -distribution MAX         - print distribution up to MAX

    -gc                       - print average GC content of all words

    -q, --query               - single query word

    -f, --queryfile           - list of query words in a file

    -s, --seqfile             - FastA/FastQ file

    -l, --listfile            - list file made by glistmaker

    -mm, --mismatch NUMBER    - specify number of mismatches (default 0)

    -p, --perfectmatch NUMBER - specify number of 3' perfect matches (default 0)

    -min, --minfreq NUMBER    - minimum frequency of the printed words (default 0)

    -max, --maxfreq NUMBER    - maximum frequency of the printed words (default MAX_UINT)

    -all                      - in case of mismatches prints all found words

    -D                        - increase debug level

> ./glistcompare -h

$ ./glistcompare -h

Usage: glistcompare INPUTLIST1 [INPUTLIST2...] METHOD [OPTIONS]

Options:

    -v, --version            - print version information and exit

    -h, --help               - print this usage screen and exit

    -u, --union              - union of input lists

    -i, --intersection       - intersection of input lists

    -d, --difference         - difference of input lists

    -dd, --double_difference - double difference of input lists

    -du, --diff_union        - subtract first list from the second and finds difference

    -mm, --mismatch   NUMBER - specify number of mismatches (default 0, can be used with -diff and -ddiff)

    -c, --cutoff NUMBER      - specify frequency cut-off (default 1)

    -o, --outputname STRING  - specify output name (default "out")

    -r, --rule STRING        - specify rule how final frequencies are calculated (default, add, subtract, min, max, first, second, 1, 2)

                               NOTE: rules min, subtract, first and second can only be used with finding the intersection.

    -ss, --subset METHOD SIZE - make subset with given method (rand, rand_unique)

    --count_only             - output count of k-mers instead of k-mers themself

    --disable_scouts         - disable list read-ahead in background thread

    -D                       - increase debug level

 パスが通ったディレクトリに移動しておく。

 

実行方法

1、k-mer配列と頻度の出力

 k=16merで配列 (fasta/fastq) を分析。

glistmaker input.fasta -w 16 -o output
  • -w specify index wordsize (1-32) (default 16)
  • -c specify frequency cut-off (default 1)
  • -o specify output name (default "out")
  • --num_threads number of threads the program is run on (default MIN(8, num_input_files))

output_16.listというバイナリファイルができる。

 k-merの配列と出現回数を出力。

glistquery output_16.list > output

 > head outut

$ head output

AAAAAAAAAAAAAAAA 62

AAAAAAAAAAAAAAAC 12

AAAAAAAAAAAAAAAG 11

AAAAAAAAAAAAAAAT 3

AAAAAAAAAAAAAACA 11

AAAAAAAAAAAAAACC 4

AAAAAAAAAAAAAACT 1

AAAAAAAAAAAAAAGA 11

AAAAAAAAAAAAAAGC 1

AAAAAAAAAAAAAAGT 1

 

 

2、共通するk-mer配列、固有のk-mer配列の抽出

 glistcompareを使うと、複数のファイルを分析し、すべての合計、サンプル間で共通、サンプル間で共通しないk-merを抽出できる。

 

genomeAとgenomeBを分析する。それぞれのk-mer頻度は以下のようになっている。

$ head -n 5 A_k-mer B_k-mer 

==> A_k-mer <==

AAAAAAAAAAAAAAAA 62

AAAAAAAAAAAAAAAC 12

AAAAAAAAAAAAAAAG 11

AAAAAAAAAAAAAAAT 3

AAAAAAAAAAAAAACA 11

 

==> B_k-mer <==

AAAAAAAAAAAAAAAA 263

AAAAAAAAAAAAAAAC 19

AAAAAAAAAAAAAAAG 19

AAAAAAAAAAAAAAAT 26

AAAAAAAAAAAAAACA 8

 

上でやっているように、まずgenomeAとgenomeBを分析する。

glistmaker genomeA.fasta -w 16 -o outputA
glistmaker genomeB.fasta -w 16 -o outputB

outut1_16.listとoutut2_16.listができる。

 

AまたはB。

glistcompare outputA_16.list outputB_16.list --union -o union_list

#出力する
glistquery union_list_16_union.list > union_k-mer

 

$ head -n 5 union_k-mer 

AAAAAAAAAAAAAAAA 325

AAAAAAAAAAAAAAAC 31

AAAAAAAAAAAAAAAG 30

AAAAAAAAAAAAAAAT 29

AAAAAAAAAAAAAACA 19

 頻度はAとBの合計になる。

 

AとBで共通 (AかつB)。

glistcompare outputA_16.list outputB_16.list --intersection -o intersect_list

#出力
glistquery intersect_list_16_intrsec.list > intersect_k-mer

 

$ head -n 5 intersect_k-mer 

AAAAAAAAAAAAAAAA 62

AAAAAAAAAAAAAAAC 12

AAAAAAAAAAAAAAAG 11

AAAAAAAAAAAAAAAT 3

AAAAAAAAAAAAAACA 8

頻度は少ない方の数になる。

 

first file(下では左側のgenomeA)に固有。

glistcompare outputA_16.list outputB_16.list --difference -o difference_list

#出力
glistquery difference_list_16_0_diff1.list > difference_k-mer

$ head -n 5 difference_k-mer 

AAAAAAAAAAAAACTG 1

AAAAAAAAAAAAAGAC 2

AAAAAAAAAAAAAGGC 1

AAAAAAAAAAAAATAC 1

AAAAAAAAAAAACAAC 4

 3つ以上の配列も同じようにして解析できます。 

 

 

引用

GenomeTester4: a toolkit for performing basic set operations - union, intersection and complement on k-mer lists

Lauris Kaplinski, Maarja Lepamets, Maido Remm

GigaScience 2015 4:58

 

このツールを利用したゲノム解析のツールFastGTは別に紹介しています。