Skip to contents

slide_apply applies a function to a sliding window of codons.

Usage

slide_apply(seq, .f, step = 1, before = 0, after = 0, ...)

Arguments

seq

DNAString, the sequence

.f

function, the codon index calculation function to apply, for example, get_enc.

step

integer, the step size in number of codons

before

integer, the number of codons before the center of a window

after

integer, the number of codons after the center of a window

...

additional arguments to pass to the function .f

Value

data.table with start, center, end, and codon usage index columns

Examples

slide_apply(yeast_cds[[1]], get_enc, step = 1, before = 10, after = 10)
#>      start center   end    index
#>      <num>  <num> <num>    <num>
#>   1:     1     31    63 55.15243
#>   2:     4     34    66 55.20681
#>   3:     7     37    69 55.63983
#>   4:    10     40    72 54.41121
#>   5:    13     43    75 54.34740
#>  ---                            
#> 133:   397    427   459 49.88711
#> 134:   400    430   462 49.24240
#> 135:   403    433   465 49.44166
#> 136:   406    436   468 49.55795
#> 137:   409    439   471 50.11617