macでインフォマティクス

macでインフォマティクス

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

配列をクラスタリングする CD-HIT

2018 12/12 追記6/18 インストール追記、7/24 help追加、9/25 タイトル修正、11/28 ユーザーズガイドリンク追記

2024/01/31 追記

 

 

似た塩基配列アミノ酸配列をクラスタリングできるツール。例えば、de novo transcriptome解析でアセンブルを行った後、95%以上似た配列をまとめてlongestのものだけ残しunigeneにする、というような作業を行うことができる。

 

f:id:kazumaxneo:20180409192838j:plain

cd-hit-user-guideより転載。

 

ただしde nobo transcritomeに使うなら、クラスタリングすることで定量に影響が出ないかどうかが問題になる。つまり、統合することで非常によく似たコピー遺伝子やパラログが失われ、かえって網羅性が失われる恐れがある。興味がある人は以下の論文を見てください。


 公式サイト

CD-HIT Official Website

 webサーバー

http://weizhong-lab.ucsd.edu/cdhit_suite/cgi-bin/index.cgi

CD-HIT User's Guide

http://weizhongli-lab.org/lab-wiki/doku.php?id=cd-hit-user-guide

 

インストール

brewかcondaを使う。

#bioconda (link)
mamba install -c bioconda -y cd-hit

#homebrew
brew
install cd-hit

 Github

git clone https://github.com/weizhongli/cdhit.git
cd cdhit/

#長い配列も扱えるようにビルド
make MAX_SEQ=1000000

cd-hit

$ cd-hit

====== CD-HIT version 4.7 (built on Jul 13 2018) ======

 

Usage: cd-hit [Options] 

 

Options

 

   -i input filename in fasta format, required

   -o output filename, required

   -c sequence identity threshold, default 0.9

  this is the default cd-hit's "global sequence identity" calculated as:

  number of identical amino acids in alignment

  divided by the full length of the shorter sequence

   -G use global sequence identity, default 1

  if set to 0, then use local sequence identity, calculated as :

  number of identical amino acids in alignment

  divided by the length of the alignment

  NOTE!!! don't use -G 0 unless you use alignment coverage controls

  see options -aL, -AL, -aS, -AS

   -b band_width of alignment, default 20

   -M memory limit (in MB) for the program, default 800; 0 for unlimitted;

   -T number of threads, default 1; with 0, all CPUs will be used

   -n word_length, default 5, see user's guide for choosing it

   -l length of throw_away_sequences, default 10

   -t tolerance for redundance, default 2

   -d length of description in .clstr file, default 20

  if set to 0, it takes the fasta defline and stops at first space

   -s length difference cutoff, default 0.0

  if set to 0.9, the shorter sequences need to be

  at least 90% length of the representative of the cluster

   -S length difference cutoff in amino acid, default 999999

  if set to 60, the length difference between the shorter sequences

  and the representative of the cluster can not be bigger than 60

   -aL alignment coverage for the longer sequence, default 0.0

  if set to 0.9, the alignment must covers 90% of the sequence

   -AL alignment coverage control for the longer sequence, default 99999999

  if set to 60, and the length of the sequence is 400,

  then the alignment must be >= 340 (400-60) residues

   -aS alignment coverage for the shorter sequence, default 0.0

  if set to 0.9, the alignment must covers 90% of the sequence

   -AS alignment coverage control for the shorter sequence, default 99999999

  if set to 60, and the length of the sequence is 400,

  then the alignment must be >= 340 (400-60) residues

   -A minimal alignment coverage control for the both sequences, default 0

  alignment must cover >= this value for both sequences 

   -uL maximum unmatched percentage for the longer sequence, default 1.0

  if set to 0.1, the unmatched region (excluding leading and tailing gaps)

  must not be more than 10% of the sequence

   -uS maximum unmatched percentage for the shorter sequence, default 1.0

  if set to 0.1, the unmatched region (excluding leading and tailing gaps)

  must not be more than 10% of the sequence

   -U maximum unmatched length, default 99999999

  if set to 10, the unmatched region (excluding leading and tailing gaps)

  must not be more than 10 bases

   -B 1 or 0, default 0, by default, sequences are stored in RAM

  if set to 1, sequence are stored on hard drive

  !! No longer supported !!

   -p 1 or 0, default 0

  if set to 1, print alignment overlap in .clstr file

   -g 1 or 0, default 0

  by cd-hit's default algorithm, a sequence is clustered to the first 

  cluster that meet the threshold (fast cluster). If set to 1, the program

  will cluster it into the most similar cluster that meet the threshold

  (accurate but slow mode)

  but either 1 or 0 won't change the representatives of final clusters

   -sc sort clusters by size (number of sequences), default 0, output clusters by decreasing length

  if set to 1, output clusters by decreasing size

   -sf sort fasta/fastq by cluster size (number of sequences), default 0, no sorting

  if set to 1, output sequences by decreasing cluster size

   -bak write backup cluster file (1 or 0, default 0)

   -h print this help

 

   Questions, bugs, contact Limin Fu at l2fu@ucsd.edu, or Weizhong Li at liwz@sdsc.edu

   For updated versions and information, please visit: http://cd-hit.org

 

   cd-hit web server is also available from http://cd-hit.org

 

   If you find cd-hit useful, please kindly cite:

 

   "CD-HIT: a fast program for clustering and comparing large sets of protein or nucleotide sequences", Weizhong Li & Adam Godzik. Bioinformatics, (2006) 22:1658-1659

   "CD-HIT: accelerated for clustering the next generation sequencing data", Limin Fu, Beifang Niu, Zhengwei Zhu, Sitao Wu & Weizhong Li. Bioinformatics, (2012) 28:3150-3152

 

 

 

 

 ラン

 DNAのクラスタリング

cd-hit-est -i input.fasta -c 0.95 -T 8 -M 4000 -o output.fasta 
  • -c sequence identity threshold, default 0.9
  • -i input filename in fasta format, required
  • -o output filename, required
  • -T number of threads, default 1; with 0, all CPUs will be used
  • -M memory limit (in MB) for the program, default 800; 0 for unlimitted;

他にも多くのオプションがある。

この場合だと95%以上似た配列が折り畳まれ、1つの代表配列になる。どれくらいの数値を使うかだが、例えばdeno vo transcriptome解析のペーパーでunigeneを絞り込むのに使う場合、95~98%などの閾値が使われている(数値の根拠は不明)。

 

.clstrを開くと、どのcontigがクラスターになったか分かる。例えば下に載せたクラスターは3つのcontigがクラスターになっている。最長だったNODE_21だけが出力され、他の2contigは排除されていることを意味する。

>Cluster 20

0       2181nt, >NODE_21_length_2181... *

1       128nt, >NODE_20700_length_1... at -/97.66%

2       72nt, >NODE_21261_length_7... at -/97.22%

 

 

 アミノ酸配列のクラスタリング

cd-hit -i input.faa -o output.faa -c 0.95 -T 8 -M 4000

注;fastaのヘッダー名が複雑だとエラーが起きる可能性がある。その場合はリネームしてから使う。

 

追記

cd-hit、cd-hit-estの他にも、duplicationがあるシーケンスリードクラスター化するCD-HIT-DUP、オーバーラップがあるリードをクラスター化するCD-HIT-LAP、二つの配列群を比較してクラスター化するCD-HIT-2Dなどがある。

https://github.com/weizhongli/cdhit/blob/master/doc/cdhit-user-guide.wiki

(レポジトリより転載)
 引用

Cd-hit: a fast program for clustering and comparing large sets of protein or nucleotide sequences.

Li W1, Godzik A.

Bioinformatics. 2006 Jul 1;22(13):1658-9. Epub 2006 May 26.

 

CD-HIT | 核酸およびアミノ酸配列のクラスタリング

 

関連

De novo transcriptomeならこちらもみて下さい。

vsearchのクラスタリングも利用できます。経験上こちらの方が精度が高いです。

複数アセンブリのredundancyに対処する。