Attempt at "fixing" the consensus sequence in a homopolymer region
Source:R/cluster.R
fix_homopolymers.RdAttempt at "fixing" the consensus sequence in a homopolymer region
Value
a data frame with these columns:
consensus: the "fixed" consensus sequence
n_adjusted the number of "fixed" homopolymer stretches
Details
Resolves N-ambiguities in the consensus if surrounded by a homopolymer stretch, replacing them with the corresponding reference sequence (which is assumed to be the most likely true sequence)
Ns are usually found on the left side (or near it), as minimap2 tends to left-align gaps, and if there is an ambiguous situation (base + gap), the consensus becomes an N.
A consensus/reference pairwise alignment is done
The leftmost N is identified
The first non-N base downstream (right) of this N is assumed to be the repeated base (likely true if gaps are left-aligned). Jump to 7. if none is found.
The longest stretch of the given base/N/gaps is searched in the aligned consensus
If the aligned reference contains only the given base and gaps within the range identified in 4., then the consensus sequence is replaced with the aligned reference
Go back to 2., searching for the next N
Remove all gaps from the consensus and return this sequence