Skip to contents

slide creates a data.table defining sliding window positions for analyzing sequences or data along a continuous range. This function provides the foundation for positional analyses of codon usage patterns within genes.

Usage

slide(from, to, step = 1, before = 0, after = 0)

Arguments

from

Integer specifying the start position of the analysis range.

to

Integer specifying the end position of the analysis range.

step

Integer specifying the step size between consecutive window centers (default: 1). Larger values create non-overlapping or less overlapping windows.

before

Integer specifying the number of positions to include before the window center (default: 0). Determines the left boundary of each window.

after

Integer specifying the number of positions to include after the window center (default: 0). Determines the right boundary of each window.

Value

A data.table with three columns:

  • start: Start position of each window

  • center: Center position of each window

  • end: End position of each window

Examples

# Create sliding windows with step size 2 and window size 3
slide(1, 10, step = 2, before = 1, after = 1)
#>    start center   end
#>    <num>  <num> <num>
#> 1:     1      2     3
#> 2:     3      4     5
#> 3:     5      6     7
#> 4:     7      8     9