Skip to content

ivar consensus: call reference at positions with low coverage #131

@alephreish

Description

@alephreish

I'm using ivar consensus to create updated reference sequences in simple cases (i.e. mapping of Sanger contigs to a reference assembly), similar to FastaAlternateReferenceMaker. For this to work, consensus should take reference residues at positions with low (zero) coverage, an option that AFAICT it does not have.

$ cat pile.txt
ref	1	A	0	*	*
ref	2	A	1	T	~
ref	3	T	0	*	*
ref	4	G	0	*	*
ref	5	G	0	*	*
$ ivar consensus -p cons -m 1 < pile.txt 
Minimum Quality: 20
Threshold: 0
Minimum depth: 1
Regions with depth less than minimum depth covered by: N
Reference length: 5
Positions with 0 depth: 4
Positions with depth below 1: 4
$ cat cons.fa 
>Consensus_cons_threshold_0_quality_20
NTNNN

A workaround is to mess with the pileup, forcing zero-depth positions to have the reference residue:

$ awk '!$4{$4=1;$5=".";$6="~"}1' OFS=\\t pile.txt | ivar consensus -p cons -m 1
Minimum Quality: 20
Threshold: 0
Minimum depth: 1
Regions with depth less than minimum depth covered by: N
Reference length: 5
Positions with 0 depth: 0
Positions with depth below 1: 0
$ cat cons.fa 
>Consensus_cons_threshold_0_quality_20
ATTGG

But I think it would be natural to add an argument (or to extend -n) that would indicate that the reference should be called for regions with zero coverage (perhaps in lower case).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions