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 56.73911
#>   2:     4     34    66 56.74898
#>   3:     7     37    69 56.93998
#>   4:    10     40    72 56.36228
#>   5:    13     43    75 56.82310
#>  ---                            
#> 133:   397    427   459 55.08742
#> 134:   400    430   462 54.82654
#> 135:   403    433   465 54.93603
#> 136:   406    436   468 55.23971
#> 137:   409    439   471 55.67965