sliding_quantile: Compute quantile of scores in a sliding window

Description Usage Arguments Value Author(s) See Also Examples

Description

This functions is used to slide a window of specified size over scores at given positions. Computed is the quantile over the scores in the window.

Usage

1
2
sliding.quantile(positions, scores, half.width, prob = 0.5,
                 return.counts = TRUE)

Arguments

positions

numeric; sorted vector of (genomic) positions of scores

scores

numeric; scores to be smoothed associated to the positions

half.width

numeric, half the window size of the sliding window

prob

numeric specifying which quantile is to be computed over the scores in the window; default 0.5 means compute the median over the scores.

return.counts

logical; should the number of points, e.g. probes, that were used for computing the median in each sliding window also returned?

Value

Matrix with two columns:

quantile

medians over running window centered at the positions that were specified in argument positions.

count

number of points that were considered for computing the median at each position

These positions are given as row.names of the resulting vector. If argument return.counts is FALSE, only a vector of the medians is returned, with the positions as names.

Author(s)

Oleg Sklyar and Joern Toedling

See Also

quantile

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  sampleSize <- 1000
  ap <- cumsum(1+round(runif(sampleSize)*10))
  as <- c(rnorm(floor(sampleSize/3)),
          rnorm(ceiling(sampleSize/3),mean=1.5),
          rnorm(floor(sampleSize/3)))
  arm <- sliding.quantile(ap, as, 20)
  arq <- sliding.quantile(ap, as, 20, prob=0.25)
  plot(ap, as, pch=20, xlab="position",ylab="level")
  points(ap, arm[,1], type="l", col="red", lwd=2)
  points(ap, arq[,1], type="l", col="green", lwd=2)
  legend(x="topleft", legend=c("median","1st quartile"),
         col=c("red","green"), lty=1, lwd=2)

Example output

Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: RColorBrewer
Loading required package: limma

Attaching package: 'limma'

The following object is masked from 'package:BiocGenerics':

    plotMA

Loading required package: Matrix
Loading required package: grid
Loading required package: lattice
Warning message:
In read.dcf(con) :
  URL 'http://bioconductor.org/BiocInstaller.dcf': status was 'Couldn't resolve host name'

Ringo documentation built on Nov. 8, 2020, 5:34 p.m.