macでインフォマティクス

macでインフォマティクス

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

bamCoverageを使いカバレッジトラックを作成する

2019 9/13 インストール追記

2024/.04/15更新

 

deeptoolsはRNA-seq解析やchip-seq解析に特化したアライメントのカウント分析ツール(webサーバ)である。ヒートマップ出力などの機能を持ち、ツールの中にあるbamCoverageを使うと、bamのカバレッジ情報をwig形式などで出力してカバレッジトラックをIGVなどに表示させることができる。

 

bamCoverage

bamCoverage — deepTools 2.3.1 documentation 

 

インストール

Github

https://github.com/deeptools/deepTools

#conda(link)
mamba create -n deeptools python=3.8 -y
conda activate deeptools
mamba install -c bioconda deeptools

#pip(PyPI)
pip install deeptools

 

 実行方法

カバレッジ情報をウィンドウサイズ10で出力する。マッピングクオリティが10以下リードはカウントしない。

bamCoverage --bam input.bam -o output.bw -of bigwig --binSize=10 --minMappingQuality 10 --numberOfProcessors=max
  • --minMappingQuality INT If set, only reads that have a mapping quality score of at least this are considered. (default: None) 
  • -o outFileName
  • -of=bigwig Output file type. Either “bigwig” or “bedgraph”. Possible choices: bigwig, bedgraph
  • --binSize=50 Size of the bins, in bases, for the output of the bigwig/bedgraph file.
  • --numberOfProcessors=max Number of processors to use. Type “max/2” to use half the maximum number of processors or “max” to use all available processors.

他にも様々なオプションがある。詳細はこちらを参考にしてください。

 

出力されたbigwigをIGVに読み込ませる。

igv -g reference.fa input.bam,output.bw

f:id:kazumaxneo:20171103214125j:plainmapping qualityが30以下をカウント対象から外して計算したため、図の中央左の白いリード付近のカバレッジはほぼゼロになっている。これは複数箇所にアライメントされたリードはmapping quality scoreが非常に低くなる(ゼロになる)ため、上の計算条件ではカバレッジのカウント対象から外れるためである。

一方で、塩基置換が複数おきても曖昧なマッピングではないならばmapping quality scoreは影響を受けないので、MQ≥10で計算しても中央右のSNPs集中部位のカバレッジはほぼ落ち込んでいない。

参考 Understanding Qualities

 

 

bedで出力する。

bamCoverage --bam input.bam -o output.bw -of bedgraph --binSize=10 --minMappingQuality 10 --numberOfProcessors=max

 user$ head -20 test.bw 

chr 0 50 0

chr 50 70 2

chr 70 90 4

chr 90 100 6

chr 100 110 7

chr 110 120 9

chr 120 130 12

chr 130 140 15

chr 140 150 16

chr 150 170 17

chr 170 180 20

chr 180 190 22

chr 190 210 24

chr 210 220 25

chr 220 250 23

chr 250 280 25

chr 280 290 23

chr 290 300 21

chr 300 310 18

chr 310 320 19

 

 

igvtoolsでも可能。

igvtools count input.bam output.wig reference.fa --minMapQuality 30 -w 10

igvtools(リンク)はbrewやconda(conda install -c bioconda -y igvtools)で導入できます。

引用

deepTools: a flexible platform for exploring deep-sequencing data

Fidel Ramírez, Friederike Dündar, Sarah Dieh,  Björn A. Grüning, and Thomas Manke

Nucleic Acids Res. 2014 Jul 1; 42(Web Server issue): W187–W191.

 

mapping quality scoresについて

Mapping short DNA sequencing reads and calling variants using mapping quality scores

Heng Li,1 Jue Ruan,2 and Richard Durbin1,3

Genome Res. 2008 Nov;18(11):1851-8. doi: 10.1101/gr.078212.108. Epub 2008 Aug 19.

 

関連


古い情報

<python2.7>

インストール後にbamCoverageを実行すると、python2.7環境であったが

 Reason: Incompatible library version: pyBigWig.so requires version 9.0.0 or later, but libcurl.4.dylib provides version 7.0.0

 が出た。

python - error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 - Stack Overflow

 を参考に修復した。

 

メタゲノム内の遺伝子を系統樹的に分類するためのスケーラブルなツール GraftM

2022/05/04 インストール手順修正

 

gtaftMは指定した遺伝子ファミリーをメタゲノムデータから探し出し、あらかじめ作成した系統樹に配置するためのツール。

 

HP

GraftM - How to get fast community profiles from metagenomes

manual

https://github.com/geronimp/graftM/wiki

 

インストール

condaとpipで導入できるが、次の依存ツールは別に導入されていなければならない。

依存

  • OrfM v. >= 0.2.0
  • HMMer v. >= 3.1b1
  • fxtract
  • pplacer v. >= 2.6.32
  • Krona v. >= 2.4
  • MAFFT v. >= 7.22
  • DIAMOND v. >= 0.7.9

Gihtub

#conda(link)
mamba create -n graftm -y
conda activate graftm
mamba install -c bioconda graftm -y

#pip
pip install graftm #python2.7

> graftM 

                                  GraftM  0.13.1

 

                            Joel Boyd, Ben Woodcroft

 

    GraftM is a tool for rapid, phylogenetically informed gene-centric

    analysis of sequence data. The main 'graft' pipeline identifies short read

    sequences with homology to genes of interest (16S rRNA or protein coding)

    using Hidden Markov Models (HMMs), which are then placed into a

    phylogenetic tree. The classification of sequences is inferred by their

    placement relative to annotated reference sequences in the tree. For

    protein coding genes, a 'best BLAST hit' style analysis can also be used.

 

    A manuscript describing and benchmarking the tool is in preparation:

 

    Boyd, J., Woodcroft B., Tyson, G. "GraftM: A tool for scalable,

    phylogenetically informed classification of genes within metagenomes (in

    preparation).

 

  -----------------------------------------------------------------------------

 

  Community profiling

    graft         ->  Identify and phylogenetically classify sequences

                      belonging to a gene family in a metagenome.

    expand_search ->  Create a sample-specific HMM from an assembly or genome

                      set.

 

  Gpkg creation

    create        ->  Create a gene family specific graftm package (gpkg).

    update        ->  Update an existing graftm packages with new sequences.

 

  Utilities

    tree          ->  Decorate or reroot phylogenetic trees for graft packages.

    archive       ->  Compress or decompress a graftm package.

 

 

実行方法

入力配列データは、fasta (.fa) または fastqで、gzip (.fq.gz) にも対応している。タンパク質またはヌクレオチド配列が利用可能。スペースでファイルを区切るだけで、1回の実行で複数のデータセットを使用することができる。 GraftM データベース(リファレンス、HMMなどのデータベース)のパスを指定する必要がある。

GraftM graft --forward reads1.fa reads2.fa --graftM_package mcrA.gpkg 

 

 

  

引用

追記

GraftM: a tool for scalable, phylogenetically informed classification of genes within metagenomes
Boyd JA, Woodcroft BJ, Tyson GW

Nucleic Acids Res. 2018 Jun 1;46(10):e59

 

GraftM - How to get fast community profiles from metagenomes

 

 

 

 

ハイブリッドアセンブリにも対応したショートリードアセンブラ Unicycler

2019 追記、 dockerリンク追加、help all追加、コメント追記

2020 help更新、追記

2021 2/25 誤字修正、5/9 ツイート追加

2022 1/25 v5に対応してインストール手順を修正、02/22, 09/21 インストール手順を修正

2023/07/11,12 追記

2024/02/07, 11追記

 

 現在、バクテリアゲノムはIlluminaシーケンシングプラットフォームによって支配されている。イルミナのリードは正確で、ベースあたりのコストが低く、全ゲノムシーケンシングの普及が可能である。しかし、多くのイルミナシーケンシングは、バクテリアゲノムの多くのリピートエレメントよりも短いフラグメント(500 bp以下)を使用している[ref,1]。これにより、ショートリードのアセンブリツール(アセンブラ)による完全なゲノムのresolutionを防ぎ、代わりに数十のアセンブリ(contigs)に断片化する。結果として、利用可能なバクテリアゲノムのほとんどは不完全であり、これは大規模な比較ゲノム研究を妨げる。

 Pacific Biosciences(PacBio)およびOxford Nanopore Technologies(ONT)シーケンシングプラットフォームは、10kbp以上のDNA断片をシーケンシングできるが、イルミナのプラットフォームよりも1塩基あたりのコストが高くなる。 PacBioおよびONTロングリードは、バクテリアゲノムアセンブリを完成させるにはしばしば十分だが、イルミナのリード(5-15%vs <1%)よりもずっと高いベースエラー率を持っている[ref.2,3]。したがって、ほとんどの研究者は、安価なIlluminaシーケンシングを使用して多くの分離株の断片化されたドラフトアセンブリを生成するか、高価なロングリード技術を使用して少ない分離株で完全なアセンブリを生成するかを選択する必要がある。ハイブリッドアセンブリは、代替手段としてショートリードとロングリードのコンビネーションを使用する。このアプローチでは、ショートリードは正確なコンティグを生成するために使用され、ロングリードはそれらを一緒にスキャフォールドするための情報を提供する。これは、完全なバクテリアゲノムへの最も費用効果の高い経路となり得る。

 近年のロングリード技術の進歩にもかかわらず、イルミナのリードりは、public health and research laboratoriesで広く使用されており[ref.4]、高精度で低コストであるためにしばらくの間続くだろう。さらに、イルミナのデータは既に数十万のバクテリア分離株で利用可能であり、これらの大部分はロングリードシーケンシングデータに置き換えられる可能性は低い。(一部略)

 ハイブリッドアセンブリは、ショートリード優先またはロングリード優先のいずれかの方法で達成することができる。ショートリード優先の方法では、スキャフォールディングツールにロングリードを使用してIlluminaコンティグを一緒に結合する。しかし、スキャフォールディングミスは一般的であり、シークエンスの構造上のミスマッチ(misassemblies)につながる[ref,5]。ロングリード優先アプローチは、訂正されていないロング・リードのアセンブリ、それに続くショートリードを用いたアセンブリエラー訂正を含む[ref.3]。あるいは、最初にショートリードを使用してロングリードのエラーを修正し、その後に修正されたロングリード[ref,6,7]を使ってアセンブリする。エラー訂正がアセンブリの前または後に実行されるかどうかにかかわらず、ロングリード優先アプローチは、ショートリード優先のアプローチよりもロングリードのデプスを必要とする。

ここでは、バクテリア分離株ゲノム用の新しいハイブリッドアセンブリパイプラインであるUnicyclerを紹介する。 Unicyclerは最初にショートリードを正確かつ接続されたアセンブリグラフ、つまりコンティグと相互接続の両方を含むデータ構造にアセンブルする[ref,8]。その後、ロングリードを使用して、グラフ内の最適なパスを検索する。ショートリード優先のアプローチに従うことによって、Unicyclerは少量のロングリードも有効に使用するが、ロングリードのデプスで十分であれば、完成したアセンブリ(1レプリコンあたり1コンティグ)を生成することができる。アセンブリグラフ接続を使用して可能なスキャホールディング構成を制約することにより、Unicyclerは、ショートリードファーストアセンブラよりもミスアセンブリ率が低くなる。

 

 

 

 Unicyclerはショートリードのde novo asssembly、ロングリードのde novo asssembly、ショートリードとロングリードを両方使ったハイブリッドのde novo asssemblyに対応したアセンブルパイプライン。単離されたバクテリア向けに設計されており、真核生物のゲノムやメタゲノムには対応していない。

 ショートリードからアセンブルのグラフを構築するために、内部でspadesを使用している。この時、Unicyclerはspadesのオプチマイザーとして機能する。具体的には、幅広いk-merを試し、dead-endとcontig数が両方とも最も少なくなる条件でアセンブルを行う。そのため、ショートリードだけのアセンブルでも、spadesよりパフォーマンスが上がる可能性がある。ロングリードだけを使ったアセンブルでは、内部でminiasmとraconが動く。miniasmでアセンブルすると、contigのエラー率は元のロングリードと同じくらいになるが、raconでiterative にpolishすることでエラーを取り除いている。

  Unicylcerの出力は、fastaとgfaファイルの両方で出力される。gfaはアセンブル情報を全て記載できるフォーマットであり、そのため、gfaの情報だけでbandageに読み込んでグラフパスを可視化することができる。また、Unicyclerはcontig末端の配列を刈り込むため、spadesのように末端にk-merサイズの重複ができることがない。そのためより正確にアセンブルの状態を把握することができる。

 

 

2022 1/24

 2021 5/9

 

インストール

追記

本体 Github

#conda (20222/02/22現在はv5.0がlatest)
mamba create -n unicycler python=3.9 -y
conda activate unicycler
mamba install -c bioconda unicycler -y


#from source
git clone https://github.com/rrwick/Unicycler.git
cd Unicycler
python3 setup.py install

> unicycler -h

$ unicycler -h

usage: unicycler [-h] [--help_all] [--version] [-1 SHORT1] [-2 SHORT2] [-s UNPAIRED] [-l LONG] -o OUT [--verbosity VERBOSITY] [--min_fasta_length MIN_FASTA_LENGTH] [--keep KEEP] [-t THREADS] [--mode {conservative,normal,bold}]

                 [--linear_seqs LINEAR_SEQS] [--vcf]

 

       __

       \ \___

        \ ___\

        //

   ____//      _    _         _                     _

 //_  //\\    | |  | |       |_|                   | |

//  \//  \\   | |  | | _ __   _   ___  _   _   ___ | |  ___  _ __

||  (O)  ||   | |  | || '_ \ | | / __|| | | | / __|| | / _ \| '__|

\\    \_ //   | |__| || | | || || (__ | |_| || (__ | ||  __/| |

 \\_____//     \____/ |_| |_||_| \___| \__, | \___||_| \___||_|

                                        __/ |

                                       |___/

 

Unicycler: an assembly pipeline for bacterial genomes

 

Help:

  -h, --help                           Show this help message and exit

  --help_all                           Show a help message with all program options

  --version                            Show Unicycler's version number

 

Input:

  -1 SHORT1, --short1 SHORT1           FASTQ file of first short reads in each pair (required)

  -2 SHORT2, --short2 SHORT2           FASTQ file of second short reads in each pair (required)

  -s UNPAIRED, --unpaired UNPAIRED     FASTQ file of unpaired short reads (optional)

  -l LONG, --long LONG                 FASTQ or FASTA file of long reads (optional)

 

Output:

  -o OUT, --out OUT                    Output directory (required)

  --verbosity VERBOSITY                Level of stdout and log file information (default: 1)

                                         0 = no stdout, 1 = basic progress indicators, 2 = extra info, 3 = debugging info

  --min_fasta_length MIN_FASTA_LENGTH  Exclude contigs from the FASTA file which are shorter than this length (default: 100)

  --keep KEEP                          Level of file retention (default: 1)

                                         0 = only keep final files: assembly (FASTA, GFA and log), 1 = also save graphs at main checkpoints, 2 = also keep SAM (enables fast rerun in different mode),

                                         3 = keep all temp files and save all graphs (for debugging)

  --vcf                                Produce a VCF by mapping the short reads to the final assembly (experimental, default: do not produce a vcf file)

 

Other:

  -t THREADS, --threads THREADS        Number of threads used (default: 8)

  --mode {conservative,normal,bold}    Bridging mode (default: normal)

                                         conservative = smaller contigs, lowest misassembly rate

                                         normal = moderate contig size and misassembly rate

                                         bold = longest contigs, higher misassembly rate

  --linear_seqs LINEAR_SEQS            The expected number of linear (i.e. non-circular) sequences in the underlying sequence (default: 0)

help all

> unicycler --help_all

$ unicycler --help_all

usage: unicycler [-h] [--help_all] [--version] [-1 SHORT1] [-2 SHORT2] [-s UNPAIRED] [-l LONG] -o OUT [--verbosity VERBOSITY] [--min_fasta_length MIN_FASTA_LENGTH] [--keep KEEP] [-t THREADS] [--mode {conservative,normal,bold}]

                 [--min_bridge_qual MIN_BRIDGE_QUAL] [--linear_seqs LINEAR_SEQS] [--min_anchor_seg_len MIN_ANCHOR_SEG_LEN] [--spades_path SPADES_PATH] [--no_correct] [--min_kmer_frac MIN_KMER_FRAC] [--max_kmer_frac MAX_KMER_FRAC] [--kmers KMERS]

                 [--kmer_count KMER_COUNT] [--depth_filter DEPTH_FILTER] [--largest_component] [--spades_tmp_dir SPADES_TMP_DIR] [--no_miniasm] [--racon_path RACON_PATH] [--existing_long_read_assembly EXISTING_LONG_READ_ASSEMBLY] [--no_rotate]

                 [--start_genes START_GENES] [--start_gene_id START_GENE_ID] [--start_gene_cov START_GENE_COV] [--makeblastdb_path MAKEBLASTDB_PATH] [--tblastn_path TBLASTN_PATH] [--no_pilon] [--bowtie2_path BOWTIE2_PATH]

                 [--bowtie2_build_path BOWTIE2_BUILD_PATH] [--samtools_path SAMTOOLS_PATH] [--pilon_path PILON_PATH] [--java_path JAVA_PATH] [--min_polish_size MIN_POLISH_SIZE] [--vcf] [--bcftools_path BCFTOOLS_PATH]

                 [--min_component_size MIN_COMPONENT_SIZE] [--min_dead_end_size MIN_DEAD_END_SIZE] [--contamination CONTAMINATION] [--scores SCORES] [--low_score LOW_SCORE]

 

       __

       \ \___

        \ ___\

        //

   ____//      _    _         _                     _

 //_  //\\    | |  | |       |_|                   | |

//  \//  \\   | |  | | _ __   _   ___  _   _   ___ | |  ___  _ __

||  (O)  ||   | |  | || '_ \ | | / __|| | | | / __|| | / _ \| '__|

\\    \_ //   | |__| || | | || || (__ | |_| || (__ | ||  __/| |

 \\_____//     \____/ |_| |_||_| \___| \__, | \___||_| \___||_|

                                        __/ |

                                       |___/

 

Unicycler: an assembly pipeline for bacterial genomes

 

Help:

  -h, --help                            Show this help message and exit

  --help_all                            Show a help message with all program options

  --version                             Show Unicycler's version number

 

Input:

  -1 SHORT1, --short1 SHORT1            FASTQ file of first short reads in each pair (required)

  -2 SHORT2, --short2 SHORT2            FASTQ file of second short reads in each pair (required)

  -s UNPAIRED, --unpaired UNPAIRED      FASTQ file of unpaired short reads (optional)

  -l LONG, --long LONG                  FASTQ or FASTA file of long reads (optional)

 

Output:

  -o OUT, --out OUT                     Output directory (required)

  --verbosity VERBOSITY                 Level of stdout and log file information (default: 1)

                                          0 = no stdout, 1 = basic progress indicators, 2 = extra info, 3 = debugging info

  --min_fasta_length MIN_FASTA_LENGTH   Exclude contigs from the FASTA file which are shorter than this length (default: 100)

  --keep KEEP                           Level of file retention (default: 1)

                                          0 = only keep final files: assembly (FASTA, GFA and log), 1 = also save graphs at main checkpoints, 2 = also keep SAM (enables fast rerun in different mode),

                                          3 = keep all temp files and save all graphs (for debugging)

  --vcf                                 Produce a VCF by mapping the short reads to the final assembly (experimental, default: do not produce a vcf file)

 

Other:

  -t THREADS, --threads THREADS         Number of threads used (default: 8)

  --mode {conservative,normal,bold}     Bridging mode (default: normal)

                                          conservative = smaller contigs, lowest misassembly rate

                                          normal = moderate contig size and misassembly rate

                                          bold = longest contigs, higher misassembly rate

  --min_bridge_qual MIN_BRIDGE_QUAL     Do not apply bridges with a quality below this value

                                          conservative mode default: 25.0

                                          normal mode default: 10.0

                                          bold mode default: 1.0

  --linear_seqs LINEAR_SEQS             The expected number of linear (i.e. non-circular) sequences in the underlying sequence (default: 0)

  --min_anchor_seg_len MIN_ANCHOR_SEG_LEN

                                        If set, Unicycler will not use segments shorter than this as scaffolding anchors (default: automatic threshold)

 

SPAdes assembly:

  These options control the short-read SPAdes assembly at the beginning of the Unicycler pipeline.

 

  --spades_path SPADES_PATH             Path to the SPAdes executable (default: spades.py)

  --no_correct                          Skip SPAdes error correction step (default: conduct SPAdes error correction)

  --min_kmer_frac MIN_KMER_FRAC         Lowest k-mer size for SPAdes assembly, expressed as a fraction of the read length (default: 0.2)

  --max_kmer_frac MAX_KMER_FRAC         Highest k-mer size for SPAdes assembly, expressed as a fraction of the read length (default: 0.95)

  --kmers KMERS                         Exact k-mers to use for SPAdes assembly, comma-separated (example: 22,33,44, default: automatic)

  --kmer_count KMER_COUNT               Number of k-mer steps to use in SPAdes assembly (default: 10)

  --depth_filter DEPTH_FILTER           Filter out contigs lower than this fraction of the chromosomal depth, if doing so does not result in graph dead ends (default: 0.25)

  --largest_component                   Only keep the largest connected component of the assembly graph (default: keep all connected components)

  --spades_tmp_dir SPADES_TMP_DIR       Specify SPAdes temporary directory using the SPAdes --tmp-dir option (default: make a temporary directory in the output directory)

 

miniasm+Racon assembly:

  These options control the use of miniasm and Racon to produce long-read bridges.

 

  --no_miniasm                          Skip miniasm+Racon bridging (default: use miniasm and Racon to produce long-read bridges)

  --racon_path RACON_PATH               Path to the Racon executable (default: racon)

  --existing_long_read_assembly EXISTING_LONG_READ_ASSEMBLY

                                        A pre-prepared long read assembly for the sample in GFA format. If this option is used, Unicycler will skip the miniasm/Racon steps and instead use the given assembly (default: perform long read assembly

                                        using miniasm/Racon)

 

Assembly rotation:

  These options control the rotation of completed circular sequence near the end of the Unicycler pipeline.

 

  --no_rotate                           Do not rotate completed replicons to start at a standard gene (default: completed replicons are rotated)

  --start_genes START_GENES             FASTA file of genes for start point of rotated replicons (default: start_genes.fasta)

  --start_gene_id START_GENE_ID         The minimum required BLAST percent identity for a start gene search (default: 90.0)

  --start_gene_cov START_GENE_COV       The minimum required BLAST percent coverage for a start gene search (default: 95.0)

  --makeblastdb_path MAKEBLASTDB_PATH   Path to the makeblastdb executable (default: makeblastdb)

  --tblastn_path TBLASTN_PATH           Path to the tblastn executable (default: tblastn)

 

Pilon polishing:

  These options control the final assembly polish using Pilon at the end of the Unicycler pipeline.

 

  --no_pilon                            Do not use Pilon to polish the final assembly (default: Pilon is used)

  --bowtie2_path BOWTIE2_PATH           Path to the bowtie2 executable (default: bowtie2)

  --bowtie2_build_path BOWTIE2_BUILD_PATH

                                        Path to the bowtie2_build executable (default: bowtie2-build)

  --samtools_path SAMTOOLS_PATH         Path to the samtools executable (default: samtools)

  --pilon_path PILON_PATH               Path to a Pilon executable or the Pilon Java archive file (default: pilon)

  --java_path JAVA_PATH                 Path to the java executable (default: java)

  --min_polish_size MIN_POLISH_SIZE     Contigs shorter than this value (bp) will not be polished using Pilon (default: 10000)

 

VCF:

  These options control the production of the VCF of the final assembly.

 

  --bcftools_path BCFTOOLS_PATH         Path to the bcftools executable (default: bcftools)

 

Graph cleaning:

  These options control the removal of small leftover sequences after bridging is complete.

 

  --min_component_size MIN_COMPONENT_SIZE

                                        Graph components smaller than this size (bp) will be removed from the final graph (default: 1000)

  --min_dead_end_size MIN_DEAD_END_SIZE

                                        Graph dead ends smaller than this size (bp) will be removed from the final graph (default: 1000)

 

Long read alignment:

  These options control the alignment of long reads to the assembly graph.

 

  --contamination CONTAMINATION         FASTA file of known contamination in long reads

  --scores SCORES                       Comma-delimited string of alignment scores: match, mismatch, gap open, gap extend (default: 3,-6,-5,-2)

  --low_score LOW_SCORE                 Score threshold - alignments below this are considered poor (default: set threshold automatically)

 

追記

dockerイメージ

https://hub.docker.com/r/staphb/unicycler/

 

実行方法

ショートリードのアセンブリ

unicycler -1 R1.fq.gz -2 R2.fq.gz -o output_dir -t 12

 もちろん非圧縮のfastqも使用できる。

 

 ハイブリッドアセンブリ

unicycler -1 short_reads_1.fq.gz -2 short_reads_2.fq.gz -l long_reads.fq.gz -o output_dir

 

ロングリードonlyアセンブリ(minimap => miniasm => Racon)

unicycler -l long_reads.fq.gz -o output_dir

 

 

Tips、気づいた事

  • アセンブルの精度とcontiguityは‑‑modeオプションで設定できる。defaultではブリッジのクオリティの閾値 (cutoffを決める値)は10だが、--mode conservativeでは25になる。同時にショートリードをブリッジ情報として使われなくなる。--mode boldでは反対にcutoffの値が最低の1まで下がり、ショートリードもブリッジ情報として利用される。エラーのリスクも出てくるが、コンティグの連続性をできる限り高める必要があるならこのモードも試すと良い。
  • アセンブルした配列のFASTA形式ファイルとアセンブリグラフのGFAファイルは必ず出力されるが、他の関連ファイルの数はkeepフラグの数値の大小で調整できる。--keep 0で関連ファイルはほぼ残らなくなる。数値をあげると関連ファイルも残るようになり、--keep 3で中間ファイルも含め全てのファイルが出力されるようになる(詳細はレポジトリを確認)。
  • 単純な環状配列ができた場合、unicyclerはゲノムを回転/反転させて、デフォルトではdnaAまたはrepAを+1にする。--start_genesオプションで指定することができる。
  • コンタミネーションを除去するために、Unicyclerはの低デプスなアセンブリをフィルタリングする。汚染の有無を調べるなら、低レベルなコンタミネーションのグラフからの配列も出力も出すSPAdesの方が適している。
  • raconやnanopolish、pilonの単独、または併用polishよりunicyclerの方が良好な結果を出している(What is a good genome assembly? – Albertsen Lab)(数年前の情報)。
  • ハイブリッドモードのアセンブリでもリピートが完全に解読されない結果が出てしまうことがある。より長いロングリードだけコマンドで抽出してアセンブリをやり直すと、それだけで複雑な繰り返し領域のアセンブリが改善することがある。うまくいくかどうかはリード長に依存している。失敗した時のアセンブリグラフをBandageに読み込んで、リピート領域の長さを確認する。そのリピートよりも十分に長いリードが読まれているなら、この方法でうまく繋がる可能性がある。ONTのリードを使っていてウルトラロングリードも得られているなら試してみてください。
  • 繰り返しになるが、アセンブルがFinishしない場合、assembly.gfaをbandageグラフビューアで視覚化して原因を探る。例えばプラスミド間で共有されている長いリピートがあるなら、目的のプラスミドのリードだけを回収してローカルアセンブリするとFinishする可能性がある。例えば20kbの高度に断片化した繰り返し配列領域があるなら、例えば20kb以上のロングリードだけ取り出し、それを使ってロングリードベースのアセンブルを行うと人繋ぎの配列が得られる可能性がある。
  • unicyclerのアセンブリではアセンブル後に複数回のpolishingによってエラーがゼロになるまで繰り返されている。多くのケースでQ50Q60を超えるアセンブリが得られるが、アセンブリエラーが完全にゼロの保証はない。経験上、まだ修正すべきエラーが10~100残っているゲノムも度々見られる。unicyclerのアセンブリにショートリードをバックマッピングし、ホモのSNVやindelがコールされないかチェックすること。コールされるならpilonなどでpolishを行う。微妙なポジションであれば、spadesなどで得たcontig.fastaをminimap2 の-x asm5設定でunicyclerのゲノム配列にアラインし、ショートリードとspadesのトラック情報から正しい塩基配列を確認する。同一系統の他の株のゲノムがでているなら、それもアラインすると参考になる。
  • flyeでもアセンブルを行い、アセンブリ構造に大きな違いがないかを確認する。見つかるなら、その部位のFlyeのコンティグとのアラインメントを目視で確認する。
  • 環状ゲノムの場合、スタート位置とエンド部位のジャンクションにエラーがあっても、線形のfastaファイルだとエラーはコールされない。+1をseqkitなどで1,000~10,000ほど回転させ、エラーがないか確認すると良い。
  • spadesのアセンブリとunicyclerのアセンブリは大雑把にはほとんど同等の品質を持つが(注;UnicyclerはSPAdesを使用してイルミナリードをアセンブリグラフにアセンブルする)、unicyclerのほうが単純リピートやタンデムリピート領域のリピート回数の表現で良好なことが多い(*1)。これはspadesのハイブリッドアセンブリとunicyclerのハイブリッドアセンブリの比較においても同じ傾向がある。理由として、spadesがハイブリッドアセンブリであっても、ショートリードベースで進め、エラーがあってもショートリードで作ったグラフを信用してノード間をブリッジするのに対して、1)unicyclerにはspadesのアセンブリでデッドエンドがない適切なk値を見つけるプロセスがあること(unicycler.log参照)、2)unicyclerにはspadesのアセンブリをそのまま最終出力とするのではなく、ポストアセンブリ処理でグラフを解きほぐす処理が加わっていること、3) ミスアセンブルの割合を減らすために、rpeat resolutionで信頼性の低いリピートを除外する事、が関係していると考えられる。つまり、SPAdesはショートリードでは正確な配列決定が難しいタンデムリピート領域もグラフから配列を確定させてしまい、ロングリード情報が利用できる時もこの領域は再考されない。このあたりの方針の違いが関係していると考えられる。ただし、アセンブリはエラーがあるリードからできるだけ長い配列を組み立てるためのヒューリスティックであり、どのようなデータやゲノムでも万能に動作するアルゴリズムではない。慎重に進めるにはTrycyclerのように複数のアセンブル結果を比較検討する必要がある(参考)。
  • SPAdesのアセンブリグラフは最終k値分だけ末端配列が重複しているため、下流の解析で邪魔になることがある(そのため、contig.fastaのそれぞれの配列の末端の配列をトリミングして使うこともある)。一方でunicyclerのアセンブリグラフは配列の重複なしでアセンブリグラフが構築されている(レポジトリより)。そのため、複雑な領域のグラフでは、SPAdesのグラフでは見られない非常に短い配列のノード(例えば1bpなど極端に短いもの)が見られることがある。これは配列間重複がないため極端に短いのだが、信頼性の高い分岐として残っており、情報としては重要。短い分岐はショートリードしか利用できない時に度々見られる。

 

引用

Unicycler: Resolving bacterial genome assemblies from short and long sequencing reads

Ryan R. Wick , Louise M. Judd, Claire L. Gorrie, Kathryn E. Holt

PLoS Comput Biol. 2017 Jun 8;13(6):e1005595.

 

*1

補足;リピートが続く領域で長い分岐が発生するなら切れるが、タンデムリピートや数塩基単位のダイレクトリピート;(XXXXXX)nではその限りではない。一本の配列として配列決定されてしまうケースがある。そのような時、アセンブルに使ったリードをアラインしてエラーを見つけることが出来れば良いのだが、ダイレクトリピートでは”ショート”リードを正確にアラインすることができないため、エラーとしてコールされないことがある。結果として、慎重に進めたにも関わらず、公的データベースにサブミットしたゲノム配列にエラーが残っていることが起こり得る。

 

関連

 

参考

複数のアセンブラからコンセンサス配列を抽出する『Trycycler』を使ってみる - Qiita

ハイブリッドアセンブルを行うquickmerge

2021 6/17 condaインストール追記

 

quickmergeは、ロングリード情報を使い、アセンブルcontiguityを向上させるツール。特にロングリードのカバレッジがmodestな時にcontiguityが大きく向上するとされる。他のツールのアセンブル結果を入力ファイルとする。

 

インストール

Github

https://github.com/mahulchak/quickmerge

git clone https://github.com/mahulchak/quickmerge.git
cd quickmerge
bash make_merger.sh

#conda
conda install -c bioconda quickmerge

 

実行方法

使用するには、DBG2OLC(紹介)などで実行されたハイブリッドアセンブリされたデータと、ロングリードだけでアセンブルされたデータが必要となる。オーサーらはハイブリッドアセンブリにはDBG2OLCを用い、ロングリードだけのアセンブリにはPBcR、canu、FALCONなどを用いている。

 

ラッパーツールを用いたランが推奨されている。

 merge_wrapper.py hybrid_assembly.fasta self_assembly.fasta

 マニュアルで進めることも可能です。詳細はオーサーらの説明を参考にしてください。

https://github.com/mahulchak/quickmerge

  

発表された論文では、high qualityなゲノムの抽出からアセンブルのpolishまで一通りの流れが書かれており勉強になります。

 

引用

Contiguous and accurate de novo assembly of metazoan genomes with modest long read coverage

Mahul Chakraborty James G. Baldwin-Brown Anthony D. Long J. J. Emerson

Nucleic Acids Research, Volume 44, Issue 19, 2 November 2016, Pages e147,

 

ロングリードをpolishする nanocorrect

2018 9/22 タイトル変更

 

nanocorrectはナノポアリードをpolishする方法論。速度が遅いのが欠点らしく、後継としてnaonpolishが発表されている(リンク)。 

  

インストール

依存

全てbrewで導入できる。

Github

 

実行方法

最初にDALIGNERのデータベースを作る。

nanocorrect-overlap INPUT=reads.fasta NAME=nc

 ncは自分が決めた名前である。

全リードをpolishする。

python nanocorrect.py nc all > corrected.fasta

論文では99.5%リファレンスのE.coliの塩基と合致するconitgが得られたと記載されている。 また複数回して精度を上げられる。

 

引用

A complete bacterial genome assembled de novo using only nanopore sequencing data

Nicholas J Loman, Joshua Quick & Jared T Simpson

Nature Methods 12, 733–735 (2015)

 

高速なSNV、indel、CNVのシミュレータ SlnC

 

 SlnCは最も多い変異であるSNV、indel、CNVをシミュレートできるNGSのリードシミュレーションツール。マルチコアに対応しており、ARTのようなツールと比較して高速にカバレッジのディープなデータセットを発生させることができる。

  

ダウンロード

依存

brewで導入できる。

SourceForge (Binaryのみ)

https://sourceforge.net/p/sincsimulator/code/ci/master/tree/

git clone https://git.code.sf.net/p/sincsimulator/code sincsimulator-code

注: mac OSXのようなDarwin系列OSでは動作しないので、cent OSに導入した。binaryにパスを通しておく。

 

実行方法

Step 1: Quality profile generation

genProfile -R <read tag(1 for R1, 2 for R2)> -l <read length> <input.txt>順番で記載する。

genProfile -R 1 -l 100 input.txt

 

 Step 2: Simulation of SNPs, INDELs, CNVs

SInC_simulate ref.fasta

Example:

./SInC_simulate -S 0.002 -I 0.0001 -p 2 -l 1000 -u 150000 -t 2

 

 Step 3: Read generation

SInC_readGen [options] <in.ref.fa> <read_1_profile.txt> <read_2_prof.txt>  

Example:

./SInC_readGen -C 5 -T 1 -R 100 chr22_allele_1.fa 100_bp_read1_profile.txt 100_bp_read2_profile.txt

./SInC_readGen -C 5 -T 1 -R 100 chr22_allele_2.fa 100_bp_read1_profile.txt 100_bp_read2_profile.txt 

 

 

 

引用

SInC: an accurate and fast error-model based simulator for SNPs, Indels and CNVs coupled with a read generator for short-read sequence data

Pattnaik S, Gupta S, Rao AA, Panda B

BMC Bioinformatics. 2014 Feb 5;15:40

 

SInC: an accurate and fast error-model based simulator for SNPs, Indels and CNVs coupled with a read generator for short-read sequence data. - PubMed - NCBI

 

 

シュードゲノムのシミューレーター Simulome

 

Simulomeは2017年に発表されたbacteria向けの遺伝子のシミュレートツールである。gene情報を与えることで、標準では一部の遺伝子に限定してシミュレートする。具体的には、遺伝子の長さの分布を調べ、その平均と標準偏差から遺伝子のサンプリングをお行い、サンプリングされた遺伝子のみ出力してpseudo-genomeを作成する。このとき、SNPsやindelのフラグをつけることで、指向的な変異を導入することが可能になっている。また、単純にゲノム全体を(変異を入れて)シミュレートすることも可能である。

 

 wiki

https://github.com/price0416/Simulome/wiki

マニュアル

ダウンロードしたフォルダにマニュアルPDFが含まれている。

ダウンロード

依存

  • Python 2.7.2
  • Biopython 1.6.1+
  • BLAST 2.3.0+ 

Github

GitHub - price0416/Simulome: Simulome, genome and mutant variant simulator.

 

実行方法

sample_dataディレクトリのデータを使いテストランを行う。500遺伝子サンプリングしてpusedo-genomeを作成する。1遺伝子につき10のSNPsを導入する。

python2.7 simulome.py --genome=sample_data/ecoli_genome.fasta --anno=sample_data/ecoli_anno.gtf --output=ecoli_simulation -- num_genes=500 --snp=TRUE --num_snp=10
  • --genome= File representing genome. FASTA nucleotide format.
  • --anno= File containing genome annotation information in GTF/GFF3 format.
  • --output= Creates a folder named with the supplied prefix containing output files.
  • --num_snp= The number of SNPs to simulate per gene. This argument is required for SNP run mode.

全ゲノムのシミュレートは--num_snpフラグは除き、--whole_genome TRUEをつける。

 

 

500遺伝子サンプリングしてpusedo-genomeを作成する。1遺伝子につき、1つの100-bp挿入を導入する。

python2.7 simulome.py --genome=sample_data/ecoli_genome.fasta --anno=sample_data/ecoli_anno.gtf --output=ecoli_simulation -- num_genes=500 --snp=TRUE --num_snp=10 --indel 3 --ins_len=100
  • --indel File representing genome. FASTA nucleotide format.

 Possible values are:

  1 = Insertions only.

  2 = Deletions only.

  3 = Both insertions and deletions.

  • --ins_len= Length of insertion events. Required for insertion mode.

 

Synonymous mutationとnonsynonymous mutationsの指定してアミノ酸変化を起こす塩基置換の割合を指定したり、duplication eventを導入したりできます。かなりのオプションがあるので、詳細はPDFマニュアルを確認してください。

 

引用

Simulome: a genome sequence and variant simulator.

Adam Price and Cynthia Gibas

Bioinformatics, 33(12), 2017, 1876–1878