Description Usage Arguments Details Value Author(s) Examples
Applies a function over a matrix or a vector using sliding
windows. sw
is a generic function with a method for
"DNAbin"
matrices.
1 2 3 4 5 6 7 8 9 10 11 | sw(x, width, step, ...)
## Default S3 method:
sw(x, width = 100, step = 50, POS = NULL,
FUN = mean, out.of.pos = NA_real_, na.rm = TRUE, L = NULL, ...)
## S3 method for class 'DNAbin'
sw(x, width = 100, step = 50, FUN = GC.content,
rowAverage = FALSE, quiet = TRUE, ...)
## S3 method for class 'sw'
plot(x, type = "l", xlab = "Position", x.scaling = 1,
show.ranges = FALSE, col.ranges = "blue",
lty.ranges = 1, lwd.ranges = 1, ...)
|
x |
a vector or a matrix. |
width |
an integer giving the window width. |
step |
an integer giving the step separating successive windows. |
POS |
a numeric vector giving the positions of the sites. |
FUN |
the function to be applied to the windows. |
rowAverage |
a logical value: if |
out.of.pos |
the values used for the sites which are not in
|
na.rm |
option passed to |
L |
the length of the chromosome (or sequence). If not given,
this is largest value in |
quiet |
a logical value: if |
type |
the type of plotting (see |
xlab |
the label under the x-axis. |
x.scaling |
the scaling of the x-axis. |
show.ranges |
a logical value specifying whether to show the
ranges of the windows with horizontal segments (ignored with a
warning if |
col.ranges, lty.ranges, lwd.ranges |
arguments to modify the
appearance of the above segments (see |
... |
further arguments passed to and from methods. |
FUN
should return a single value.
x
should be a matrix for the "DNAbin"
method, or a
vector for the default one.
For the default method, the vector x
is expanded into a vector
of length L
(see above on how this value is found) and the
positions which are not in POS
are filled with the value given
in out.of.pos
. The resulting vector is then analysed with the
function FUN
which must have an option na.rm
. If the
function you want to use does not have this option, you can use
something like FUN = function(x, na.rm = TRUE)
foo(x[!is.na(x)])
, replacing ‘foo’ by the name of your function. You
may also include more control on the handling of missing data.
a matrix or a vector (if rowAverage = TRUE
).
Emmanuel Paradis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | data(woodmouse)
sw(woodmouse)
sw(woodmouse, 200, 200)
sw(woodmouse, 200, 200, rowAverage = TRUE)
## to get the proportions of G:
foo <- function(x) base.freq(x)["g"]
sw(woodmouse, 200, 200, FUN = foo, rowAverage = TRUE)
## a simulated example with the default method:
x <- runif(100)
pos <- sort(sample(1e6, 100))
resx <- sw(x, w = 2e4, s = 5e3, POS = pos, L = 1e6)
plot(resx, show.ranges = TRUE, x.scaling = 1e6, xlab = "Position (Mb)")
|
Loading required package: ape
Loading required package: adegenet
Loading required package: ade4
Registered S3 method overwritten by 'spdep':
method from
plot.mst ape
/// adegenet 2.1.3 is loaded ////////////
> overview: '?adegenet'
> tutorials/doc/questions: 'adegenetWeb()'
> bug reports/feature requests: adegenetIssues()
Registered S3 method overwritten by 'pegas':
method from
print.amova ade4
Attaching package: ‘pegas’
The following object is masked from ‘package:ade4’:
amova
The following object is masked from ‘package:ape’:
mst
[1,100] [51,150] [101,200] [151,250] [201,300] [251,350] [301,400]
No305 0.3877551 0.40 0.3900000 0.3900000 0.36 0.35 0.40
No304 0.3800000 0.39 0.3800000 0.3800000 0.35 0.33 0.38
No306 0.3700000 0.39 0.3800000 0.3800000 0.35 0.33 0.38
No0906S 0.3700000 0.38 0.3800000 0.3800000 0.35 0.31 0.36
No0908S 0.3800000 0.40 0.3800000 0.3800000 0.36 0.34 0.38
No0909S 0.3900000 0.41 0.3800000 0.3900000 0.36 0.36 0.41
No0910S 0.3500000 0.39 0.3900000 0.3800000 0.35 0.32 0.37
No0912S 0.3900000 0.41 0.3800000 0.3800000 0.36 0.35 0.39
No0913S 0.3800000 0.39 0.3800000 0.3900000 0.36 0.32 0.37
No1103S 0.3800000 0.41 0.3800000 0.3800000 0.35 0.34 0.39
No1007S 0.3900000 0.41 0.3800000 0.3900000 0.36 0.36 0.41
No1114S 0.4000000 0.40 0.3939394 0.3939394 0.35 0.35 0.40
No1202S 0.3600000 0.39 0.3900000 0.3900000 0.36 0.32 0.37
No1206S 0.3700000 0.39 0.3800000 0.3800000 0.36 0.34 0.38
No1208S 0.4020619 0.41 0.3800000 0.4000000 0.37 0.36 0.41
[351,450] [401,500] [451,550] [501,600] [551,650] [601,700] [651,750]
No305 0.3636364 0.3838384 0.43 0.41 0.43 0.35 0.34
No304 0.3673469 0.3775510 0.41 0.39 0.42 0.35 0.35
No306 0.3600000 0.3700000 0.41 0.39 0.42 0.35 0.34
No0906S 0.3600000 0.3800000 0.42 0.39 0.42 0.34 0.33
No0908S 0.3700000 0.3800000 0.42 0.40 0.42 0.35 0.34
No0909S 0.3600000 0.3900000 0.42 0.38 0.42 0.35 0.34
No0910S 0.3600000 0.3800000 0.42 0.39 0.42 0.36 0.35
No0912S 0.3600000 0.3800000 0.43 0.40 0.42 0.36 0.35
No0913S 0.3600000 0.3700000 0.41 0.39 0.42 0.36 0.36
No1103S 0.3600000 0.3800000 0.42 0.39 0.42 0.35 0.34
No1007S 0.3600000 0.3900000 0.42 0.38 0.42 0.35 0.34
No1114S 0.3600000 0.3900000 0.41 0.38 0.42 0.36 0.35
No1202S 0.3600000 0.3800000 0.42 0.39 0.42 0.36 0.35
No1206S 0.3600000 0.3800000 0.42 0.39 0.42 0.35 0.35
No1208S 0.3700000 0.4000000 0.42 0.38 0.42 0.35 0.34
[701,800] [751,850] [801,900] [851,950] [901,965]
No305 0.4400000 0.4200000 0.38 0.40 0.4153846
No304 0.4500000 0.4400000 0.40 0.40 0.4218750
No306 0.4387755 0.4387755 0.40 0.40 0.4000000
No0906S 0.4400000 0.4300000 0.39 0.40 0.3934426
No0908S 0.4400000 0.4300000 0.39 0.40 0.4262295
No0909S 0.4400000 0.4300000 0.40 0.41 0.4262295
No0910S 0.4400000 0.4300000 0.39 0.40 0.4262295
No0912S 0.4400000 0.4200000 0.38 0.40 0.4262295
No0913S 0.4500000 0.4400000 0.40 0.40 0.4262295
No1103S 0.4400000 0.4200000 0.38 0.40 0.4262295
No1007S 0.4400000 0.4300000 0.40 0.41 0.4262295
No1114S 0.4400000 0.4300000 0.39 0.41 0.4426230
No1202S 0.4400000 0.4300000 0.39 0.40 0.4262295
No1206S 0.4500000 0.4300000 0.39 0.40 0.4262295
No1208S 0.4400000 0.4300000 0.40 0.41 0.4262295
attr(,"class")
[1] "sw"
[1,200] [201,400] [401,600] [601,800] [801,965]
No305 0.3888889 0.380 0.3969849 0.3950000 0.3939394
No304 0.3800000 0.365 0.3838384 0.4000000 0.4085366
No306 0.3750000 0.365 0.3800000 0.3939394 0.4000000
No0906S 0.3750000 0.355 0.3850000 0.3900000 0.3913043
No0908S 0.3800000 0.370 0.3900000 0.3950000 0.4037267
No0909S 0.3850000 0.385 0.3850000 0.3950000 0.4099379
No0910S 0.3700000 0.360 0.3850000 0.4000000 0.4037267
No0912S 0.3850000 0.375 0.3900000 0.4000000 0.3975155
No0913S 0.3800000 0.365 0.3800000 0.4050000 0.4099379
No1103S 0.3800000 0.370 0.3850000 0.3950000 0.3975155
No1007S 0.3850000 0.385 0.3850000 0.3950000 0.4099379
No1114S 0.3961039 0.375 0.3850000 0.4000000 0.4099379
No1202S 0.3750000 0.365 0.3850000 0.4000000 0.4037267
No1206S 0.3750000 0.370 0.3850000 0.4000000 0.4037267
No1208S 0.3908629 0.390 0.3900000 0.3950000 0.4099379
attr(,"class")
[1] "sw"
[1,200] [201,400] [401,600] [601,800] [801,965]
0.3811462 0.3716667 0.3860527 0.3972648 0.4035449
attr(,"class")
[1] "sw"
[1,200] [201,400] [401,600] [601,800] [801,965]
0.08816548 0.18900000 0.14581248 0.10507005 0.09563067
attr(,"class")
[1] "sw"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.