Skip to contents

slide_codon creates sliding window intervals specifically designed for codon-based analysis of DNA sequences. This function automatically handles codon boundaries and is useful for studying positional effects in codon usage within genes.

Usage

slide_codon(seq, step = 1, before = 0, after = 0)

Arguments

seq

A DNA sequence as a DNAString object, or any object that can be coerced to DNAString.

step

Integer specifying the step size between consecutive window centers in codons (default: 1). A step of 3 creates non-overlapping windows.

before

Integer specifying the number of codons to include before the window center (default: 0).

after

Integer specifying the number of codons to include after the window center (default: 0).

Value

A data.table with three columns containing nucleotide positions:

  • start: Start nucleotide position of each window

  • center: Center nucleotide position of each window

  • end: End nucleotide position of each window

Examples

# Create sliding windows for codon analysis
x <- Biostrings::DNAString('ATCTACATAGCTACGTAGCTCGATGCTAGCATGCATCGTACGATCGTCGATCGTAG')
slide_codon(x, step = 3, before = 1, after = 1)
#>    start center   end
#>    <num>  <num> <num>
#> 1:     1      4     9
#> 2:    10     13    18
#> 3:    19     22    27
#> 4:    28     31    36
#> 5:    37     40    45
#> 6:    46     49    54