| 1 | # Scythe - A Bayesian adapter trimmer (version 0.994 BETA) |
| 2 | |
| 3 | Scythe and all supporting documentation |
| 4 | Copyright (c) Vince Buffalo, 2011-2014 |
| 5 | |
| 6 | Contact: Vince Buffalo <[email protected]> (with the poly-A tail removed) |
| 7 | |
| 8 | If you wish to report a bug, please open an issue on Github |
| 9 | (http://github.com/vsbuffalo/scythe/issues) so that it can be |
| 10 | tracked. You can contact me as well, but please open an issue first. |
| 11 | |
| 12 | ## About |
| 13 | |
| 14 | Scythe uses a Naive Bayesian approach to classify contaminant |
| 15 | substrings in sequence reads. It considers quality information, which |
| 16 | can make it robust in picking out 3'-end adapters, which often include |
| 17 | poor quality bases. |
| 18 | |
| 19 | Most next generation sequencing reads have deteriorating quality |
| 20 | towards the 3'-end. It's common for a quality-based trimmer to be |
| 21 | employed before mapping, assemblies, and analysis to remove these poor |
| 22 | quality bases. However, quality-based trimming could remove bases that |
| 23 | are helpful in identifying (and removing) 3'-end adapter |
| 24 | contaminants. Thus, it is recommended you run Scythe *before* |
| 25 | quality-based trimming, as part of a read quality control pipeline. |
| 26 | |
| 27 | The Bayesian approach Scythe uses compares two likelihood models: the |
| 28 | probability of seeing the matches in a sequence given contamination, |
| 29 | and not given contamination. Given that the read is contaminated, the |
| 30 | probability of seeing a certain number of matches and mismatches is a |
| 31 | function of the quality of the sequence. Given the read is not |
| 32 | contaminated (and is thus assumed to be random sequence), the |
| 33 | probability of seeing a certain number of matches and mismatches is |
| 34 | chance. The posterior is calculated across both these likelihood |
| 35 | models, and the class (contaminated or not contaminated) with the |
| 36 | maximum posterior probability is the class selected. |
| 37 | |
| 38 | ## Requirements |
| 39 | |
| 40 | Scythe can be compiled using GCC or Clang; compilation during |
| 41 | development used the latter. Scythe relies on Heng Li's kseq.h, which |
| 42 | is bundled with the source. |
| 43 | |
| 44 | Scythe requires Zlib, which can be obtained at <http://www.zlib.net/>. |
| 45 | |
| 46 | ## Building and Installing Scythe |
| 47 | |
| 48 | To build Scythe, enter: |
| 49 | |
| 50 | make all |
| 51 | |
| 52 | Then, copy or move "scythe" to a directory in your $PATH. |
| 53 | |
| 54 | ## Usage |
| 55 | |
| 56 | Scythe can be run minimally with: |
| 57 | |
| 58 | scythe -a adapter_file.fasta -o trimmed_sequences.fasta sequences.fastq |
| 59 | |
| 60 | By default, the prior contamination rate is 0.05. This can be changed |
| 61 | (and one is encouraged to do so!) with: |
| 62 | |
| 63 | scythe -a adapter_file.fasta -p 0.1 -o trimmed_sequences.fastq sequences.fastq |
| 64 | |
| 65 | If you'd like to use standard out, it is recommended you use the |
| 66 | `--quiet` option: |
| 67 | |
| 68 | scythe -a adapter_file.fasta --quiet sequences.fastq > trimmed_sequences.fastq |
| 69 | |
| 70 | Also, more detailed output about matches can be obtained with: |
| 71 | |
| 72 | scythe -a adapter_file.fasta -o trimmed_sequences.fastq -m matches.txt sequences.fastq |
| 73 | |
| 74 | By default, Illumina's quality scheme (pipeline > 1.3) is used. Sanger |
| 75 | or Solexa (pipeline < 1.3) qualities can be specified with `-q`: |
| 76 | |
| 77 | scythe -a adapter_file.fasta -q solexa -o trimmed_sequences.fastq sequences.fastq |
| 78 | |
| 79 | Lastly, one can specify the minimum match length argument with `-n |
| 80 | <integer>` and the minimum length of sequence (discarded less than or |
| 81 | equal to this parameter) to keep after trimming with `-M <integer>`: |
| 82 | |
| 83 | scythe -a adapter_file.fasta -n 0 -M 10 -o trimmed_sequences.fastq sequences.fastq |
| 84 | |
| 85 | The default is 5. If this pre-processing is upstream of assembly on a |
| 86 | very contaminated lane, decreasing this parameter could lead to *very* |
| 87 | liberal trimming, i.e. of only a few bases. |
| 88 | |
| 89 | ## Notes |
| 90 | |
| 91 | Note that the two provided adapter sequence files contain non-FASTA |
| 92 | characters to denote the locations of barcode sequences, which always |
| 93 | appear in TruSeq adapters, and may or may not appear in forward and/or |
| 94 | reverse reads using the original Solexa/Illumina adapter sequences, |
| 95 | depending on library preparation. You'll need to modify the adapter |
| 96 | sequence files in order to use them. |
| 97 | |
| 98 | In the case of the original Solexa/Illumina adapter sequences, we've seen |
| 99 | barcodes "upstream" of forward reads (in which case the reverse complement |
| 100 | of the barcode will appear before the adapter sequence at the 3'-end of |
| 101 | reverse reads - replacing the [NNNNNN]). We've also seen barcodes upstream |
| 102 | of reverse reads (in which case the reverse complement of the barcode will |
| 103 | appear before the adapter sequence at the 3'-end of forward reads - |
| 104 | replacing the [MMMMMM]). Your definition of the barcode may be someone |
| 105 | else's reverse-complemented barcode, and the barcode may or may not be 6 |
| 106 | bases. |
| 107 | |
| 108 | In the case of TruSeq adapter sequences, there will always be a 6 bp |
| 109 | barcode in place of the [NNNNNN] in sequence contaminating forward reads |
| 110 | (if the fragment is short enough, of course). This barcode sequence should |
| 111 | match the barcode included in the reads' FASTQ headers. |
| 112 | |
| 113 | Scythe only checks for 3'-end contaminants. As of commit `7f49366`, |
| 114 | the algorithm has changd, and Scythe now matches 3' contaminants up to |
| 115 | the 5'-end. Still, do not use Scythe for 5'-trimming as (1) this is a |
| 116 | trivial problem for most Illumina sequences, as the quality is high in |
| 117 | this region, and (2) Scythe does not allow for adapters overlap the |
| 118 | 5'-end (though this may come in the future). |
| 119 | |
| 120 | For reads with contamination in *any* position, the program TagDust |
| 121 | (<http://genome.gsc.riken.jp/osc/english/dataresource/>) is |
| 122 | recommended. Scythe has the advantages of allowing fuzzier matching |
| 123 | and being base quality-aware, while TagDust has the advantages of very |
| 124 | fast matching (but allowing few mismatches, and not considering |
| 125 | quality) and FDR. Note that TagDust removes contaminated reads |
| 126 | *entirely*, while Scythe trims off contaminating sequence, leaving |
| 127 | valuable uncontaminated read sequence! |
| 128 | |
| 129 | A possible pipeline would run FASTQ reads through Scythe, then |
| 130 | TagDust, then a quality-based trimmer, and finally through a read |
| 131 | quality statistics program such as qrqc |
| 132 | (<http://bioconductor.org/packages/devel/bioc/html/qrqc.html>) or FASTqc |
| 133 | (<http://www.bioinformatics.bbsrc.ac.uk/projects/fastqc/>). |
| 134 | |
| 135 | ## FAQ |
| 136 | |
| 137 | ### Does Scythe work with paired-end data? |
| 138 | |
| 139 | Scythe does work with paired-end data. Each file must be run |
| 140 | separately, but Scythe will not remove reads entirely leaving |
| 141 | mismatched pairs. |
| 142 | |
| 143 | In some cases, barcodes are ligated to both the 3'-end and 5'-end of |
| 144 | reads. 5'-end removal is trivial since base calling is near-perfect |
| 145 | there, but 3'-end removal can be trickier. Some users have created |
| 146 | Scythe adapter files that contain all possible barcodes concatenated |
| 147 | with possible adapters, so that both can be recognized and |
| 148 | removed. This has worked well and is recommended for cases when 3'-end |
| 149 | quality deteriorates and prevents barcode removal. Newer Illumina |
| 150 | chemistry has the barcode separated from the fragment, so that it |
| 151 | appears as an entirely separate read and is used to demultiplex sample |
| 152 | reads by Illumina's CASAVA pipeline. |
| 153 | |
| 154 | ### Does Scythe work on 5'-end or other contaminants? |
| 155 | |
| 156 | No. Embracing the Unix tool philosophy that tools should do one thing |
| 157 | very well, Scythe just removes 3'-end contaminants where there could |
| 158 | be multiple base mismatches due to poor base quality. N-mismatch |
| 159 | algorithms (such as TagDust) don't consider base qualities. Scythe |
| 160 | will allow more mismatches in an alignment if the mismatched bases are |
| 161 | of low quality. |
| 162 | |
| 163 | **Scythe only checks as far in as the entire adapter contaminant's |
| 164 | length.** However, some investigation has shown that Illumina |
| 165 | pipelines sometimes produce reads longer than the read length + |
| 166 | adapter length. The extra bases have always been observed to be |
| 167 | A's. Some testing has shown this can be addressed by appending A's to |
| 168 | the adapters in the adapters file. Since Scythe begins by checking for |
| 169 | contamination from the 5'-end of the adapter, this won't affect the |
| 170 | normal adapter contaminant cases. |
| 171 | |
| 172 | ### What does the numeric output from Scythe mean? |
| 173 | |
| 174 | For each adapter in the file, the contaminants removed by position are |
| 175 | returned via standard error. For example: |
| 176 | |
| 177 | Adapter 1 'fake adapter' contamination occurences: |
| 178 | [10, 2, 4, 5, 6] |
| 179 | |
| 180 | indicates that "fake adapter" is 5 bases long (the length of the array |
| 181 | returned), and that there were 10 contaminants found of first base (-n |
| 182 | was set to 0 then), 2 of the first two bases, 4 contaminants of the |
| 183 | first 3 bases, 5 of the first 4 bases, etc. |
| 184 | |
| 185 | ### Does Scythe work on FASTA files? |
| 186 | |
| 187 | No, as these have no quality information. |
| 188 | |
| 189 | ### How can I report a bug? |
| 190 | |
| 191 | See the section below. |
| 192 | |
| 193 | ### How does Scythe compare to program "x"? |
| 194 | |
| 195 | As far as I know, Scythe is the only program that employs a Bayesian |
| 196 | model that allows prior contaminant estimates to be used. This prior |
| 197 | is a more realistic approach than setting a fixed number of mismatches |
| 198 | because we can visually estimate it with the Unix tool `less`. |
| 199 | |
| 200 | Scythe also looks at base-level qualities, *not* just a fixed level of |
| 201 | mismatches. A fixed number of mismatches is a bad approach with data |
| 202 | our group (the UC Davis Bioinformatics Core) has seen, as a small bad |
| 203 | quality run can quickly exhaust even a high numbers of fixed |
| 204 | mismatches and lead to higher false negatives. |
| 205 | |
| 206 | ### How do I cite Scythe? |
| 207 | |
| 208 | Just link to this Github repository, until I finish the manuscript |
| 209 | (sorry). |
| 210 | |
| 211 | ## Reporting Bugs |
| 212 | |
| 213 | Scythe is free software and is proved without a warranty. However, I |
| 214 | am proud of this software and I will do my best to provide updates, |
| 215 | bug fixes, and additional documentation as needed. Please report all |
| 216 | bugs and issues to Github's issue tracker |
| 217 | (http://github.com/vsbuffalo/scythe/issues). If you want to email me, |
| 218 | do so in addition to an issue request. |
| 219 | |
| 220 | If you have a suggestion or comment on Scythe's methods, you can email |
| 221 | me directly. |
| 222 | |
| 223 | ## Is there a paper about Scythe? |
| 224 | |
| 225 | I am currently writing a paper on Scythe's methods. In my preliminary |
| 226 | testing, Scythe has fewer false positives and false negatives than its |
| 227 | competitors. |