3
$\begingroup$

Background I want to trim leading and (likely just) trailing N's from my WES (Illumina NextSeq500) reads with cutadapt (--trim-n).

I also want to filter for reads with > 40%? N's (--max-n).

Question Does cutadapt first remove the trailing/leading N's before removing reads with >X% N's? This is because if, hypothetically, 40% of the N's are on the end of the reads, I want to keep them.

Cheers and thanks in advance.

$\endgroup$

1 Answer 1

3
$\begingroup$

Yes, it behaves just like you expect, where a read with >40% Ns but only at the ends will still be kept (after trimming).


Cutadapt runs in two stages, with read modification first and read filtering after. So first, --trim-n removes Ns at the start and end of reads are removed, and only then is a rule like --max-n applied.

Here's an example where the first 5 sequences have Ns at the ends and the next 5 have Ns interspersed:

>seq01  0%
CACATCAAGAGGTCCTTGGCGACTATTAGCGCCCGGCGGACCCAATCGTA
>seq02 20%
NNNNNCAAGAGGTCCTTGGCGACTATTAGCGCCCGGCGGACCCAANNNNN
>seq03 40%
NNNNNNNNNNGGTCCTTGGCGACTATTAGCGCCCGGCGGANNNNNNNNNN
>seq04 60%
NNNNNNNNNNNNNNNTTGGCGACTATTAGCGCCCGNNNNNNNNNNNNNNN
>seq05 80%
NNNNNNNNNNNNNNNNNNNNGACTATTAGCNNNNNNNNNNNNNNNNNNNN
>seq06 10%
CACATCANGAGGTCCTTNGCGACTATTNGCGCCCGGCNGACCCAATCNTA
>seq07 20%
CANATCANGAGGNCCTTNGCGANTATTNGCGCNCGGCNGACCNAATCNTA
>seq08 40%
CNNATCNNGAGNNCCTNNGCGNNTATNNGCGNNCGGNNGACNNAATNNTA
>seq09 60%
CNNANCNNGNGNNCNTNNGNGNNTNTNNGNGNNCNGNNGNCNNANTNNNA
>seq10 80%
CNNNNNNNGNNNNCNNNNGNNNNTNNNNGNNNNCNNNNGNNNNANNNNNA

With just read filtering:

$ cutadapt --quiet --max-n 0.4 seqs.fa -o -
>seq01  0%
CACATCAAGAGGTCCTTGGCGACTATTAGCGCCCGGCGGACCCAATCGTA
>seq02 20%
NNNNNCAAGAGGTCCTTGGCGACTATTAGCGCCCGGCGGACCCAANNNNN
>seq03 40%
NNNNNNNNNNGGTCCTTGGCGACTATTAGCGCCCGGCGGANNNNNNNNNN
>seq06 10%
CACATCANGAGGTCCTTNGCGACTATTNGCGCCCGGCNGACCCAATCNTA
>seq07 20%
CANATCANGAGGNCCTTNGCGANTATTNGCGCNCGGCNGACCNAATCNTA
>seq08 40%
CNNATCNNGAGNNCCTNNGCGNNTATNNGCGNNCGGNNGACNNAATNNTA

With trimming also:

$ cutadapt --quiet --max-n 0.4 --trim-n seqs.fa -o -
>seq01  0%
CACATCAAGAGGTCCTTGGCGACTATTAGCGCCCGGCGGACCCAATCGTA
>seq02 20%
CAAGAGGTCCTTGGCGACTATTAGCGCCCGGCGGACCCAA
>seq03 40%
GGTCCTTGGCGACTATTAGCGCCCGGCGGA
>seq04 60%
TTGGCGACTATTAGCGCCCG
>seq05 80%
GACTATTAGC
>seq06 10%
CACATCANGAGGTCCTTNGCGACTATTNGCGCCCGGCNGACCCAATCNTA
>seq07 20%
CANATCANGAGGNCCTTNGCGANTATTNGCGCNCGGCNGACCNAATCNTA
>seq08 40%
CNNATCNNGAGNNCCTNNGCGNNTATNNGCGNNCGGNNGACNNAATNNTA
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.