Pre-assembly analyses bjorn.nystedt@scilifelab.se Facility manager, SciLifeLab Bioinformatics Long-term Support (a.k.a WABI) Credits to Doug Scofield, Nat Street, Francesco Vezzi, Amaryllis Vidali, Andrea Zuccolo and others!
Two types of assemblies Case 1 : Flycatcher (1.2 Gbp) Herring (800 Mbp) Malassezia (7 Mbp)
Two types of assemblies Case 1 : Flycatcher (1.2 Gbp) Herring (800 Mbp) Malassezia (7 Mbp) Case 2 : Spruce (20 Gbp) Barnacle (1.4 Gbp) Wolbachia (4 Mbp)
Just a word on N50… N50 typically refers to a contig (or scaffold) length But… The original definition is the number of contigs needed to reach half of the genome size (L50 is the length) Many programs use the total assembly size as a proxy for the genome size; this is sometimes completely misleading: Use NG50! PI:s don’t understand N50 anyway; use something more intuitive : - contigs larger than 1 kbp sum to 93% of the genome size - contigs larger than 10 kbp sum to 48% of the genome size - contigs larger than 100 kbp sum to 19% of the genome size N50 NG50 Assembly size Genome size Genome Assembly 3 contigs 100 kbp 5 contigs 30 kbp
Why is it hard?
The devil is in the repeats Mathematically best result: C R A B
Repeat errors Collapsed repeats Overlapping non-identical reads and chimeras Overlapping non-identical reads Wrong contig order Inversions
It’s getting worse A: ATCGGGTATATAG-CCTA ||||||| || || |||| B: ATCGGGTGTACAGCCCTA A ? A & B B
…and humans are easy. Bacteria, archaea, fungi, some plants Most animals, some plants Many plants Also: Heterozygozity is generally very low in mammals; most other species are much harder
Pre assembly Quality trimming (Error correction) Kmer analysis De novo repeat library
Quality trimming DeBruijn-graph assemblers are in principle sensitive to errors since they do not take base quality values into account Trim adapters (e.g. Cutadapt) Filter on quality, both 5’ and 3’ end! (e.g. Trimmomatic) Consider hard-trimming of 5’ end Error correction (e.g. Quake) Inspect (e.g. FastQC) Plots by Olof Karlberg
Reads vs kmers …….. 1 read: 100 bp Kmers: k=21bp N= (L – k + 1) (100bp – 21 bp + 1) 80 …….. Base coverage * (L-k+1) = Kmer coverage L Ex: 50X * (100-21+1) = 40X (i.e. kmer coverage is 80% of base coverage) 100
Kmer analyses Compute the frequency of each kmer in the dataset (e.g. Jellyfish --both-strands) Note: RAM-intense!
Digging into the kmers Genome size Remove low-copy kmers Identify the coverage peak Divide total nb of kmers by peak “Cpeak 20 million distinct kmers occure 55 times in all reads combined” Genome size = Ktot/Cpeak Here: 1.4 Gbp = 80 G / 55 Note: Ktot = Nb reads * (L-k+1) Base coverage = Cpeak (L-k+1)/L Here: 69X = 55 (100 – 21 +1)/100
Repeats: first shot The nb of distinct kmers in the single-copy peak corresponds roughly to the single-copy genome size Single-copy Example Beetle: 0.75 Gbp is single-copy, so almost 40% of the 1.2 Gbp genome is repeated (kmer=27) Repeats
Heterozygocity Double peak in the kmer histogram; clear indication of heterozygocity Not entirely easy to quantify (although attempts have been made)
A word on quality filtering… Light QC filter Hard QC filter
Repeat library and repeat quantification Create a de novo repeat library Run a low-coverage (e.g. 0.1X) assembly (e.g. RepeatExplorer or Trinity) Filter contaminants and mito/chloro [ Make non-redundant (e.g. Cdhit) ] Quantify the (high) repeat content by an independent subset of reads - Mapping (e.g. bwa), or - Mask with RepeatMasker
Repeat library from low coverage data Sparse seq data Overlaps?
Repeat library from low coverage data Sparse seq data Overlaps? Assembled contigs
Repeat library from low coverage data Sparse seq data Overlaps? Assembled contigs Warning! Beware of contaminations, plastids etc
Quantify your repeat seqs Independent set of sparse data Screen reads with repeat seqs 33% of all bases in the reads are covered by repeat seqs 33% of the genome is “repeated” Warning! The quantification depends heavily on the size of the original read set
Classifying repeats LTR Gypsy/Copia LINE/SINE Getting tricky… DNA elements … Getting tricky… Classifying the repeat library directly RepeatMasker Repeat protein domain serach (http://www.repeatmasker.org/cgi-bin/RepeatProteinMaskRequest) Problems No close homologs in databases Rapid evolution of repeats (like transposable elements) Non-autonomous TE:s do not contain proteins Solutions Fetch intact ORF:s from hits in assembly Extend assembly matches and get more complete elements Check match alignment profiles in assembly (LINES conserved at 3’ end but not at 5’..) => Often slow, manual, species-specific solutions
Take home Genome assembly is sometimes reasonably easy, if you are lucky and not too picky. There are tools to indicate which one you are up against. Adapters and quality trimming is a pain in the neck. But you should probably do it. Unless you use ALLPATHS-LG Genome size and repeat content can (often better!) be estimated without an assembly
Thanks