Creates a new virtual track.

gvtrack.create(vtrack = NULL, src = NULL, func = NULL, params = NULL)

Arguments

vtrack

virtual track name

src

source (track or intervals)

func, params

see below

Value

None.

Details

This function creates a new virtual track named 'vtrack' with the given source, function and parameters. 'src' can be either a track or intervals (1D or 2D). Use the following table for a reference of all valid source, function and parameters combinations:

src = [Track], func = "avg", params = NULL
Average track value in iterator interval.

src = [Track], func = "max", params = NULL
Maximal track value in iterator interval.

src = [Track], func = "min", params = NULL
Minimal track value in iterator interval.

src = ['Dense' / 'Sparse' / 'Array' track], func = "nearest", params = NULL
Mean track value in iterator interval. If there are no track values covered by an iterator interator (can occur only in 'Sparse' track), the nearest track value is returned.

src = ['Dense' / 'Sparse' / 'Array' track], func = "stddev", params = NULL
Unbiased standard deviation of track values in iterator interval.

src = ['Dense' / 'Sparse' / 'Array' track], func = "sum", params = NULL
Sum of track values in iterator interval.

src = ['Dense' / 'Sparse' / 'Array' track], func = "quantile", params = [Percentile in the range of [0, 1]]
Quantile of track values in iterator interval.

src = ['Dense' track], func = "global.percentile", params = NULL
Percentile of an average track value in iterator interval relatively to all values of the track.

src = ['Dense' track], func = "global.percentile.max", params = NULL
Percentile of a maximal track value in iterator interval relatively to all values of the track.

src = ['Dense' track], func = "global.percentile.min", params = NULL
Percentile of a minimal track value in iterator interval relatively to all values of the track.

src = [2D track], func = "area", params = NULL
Area covered by iterator interval.

src = [2D track], func = "weighted.sum", params = NULL
Weighted sum of values where each weight equals to the intersection area between the iterator interval and the rectangle containing the value.

src = [1D intervals], func = "distance", params = [Minimal distance from center (default: 0)]
Given the center 'C' of the current iterator interval returns 'DC * X/2', where 'DC' is the normalized distance to the center of the interval that contains 'C', and 'X' is the value of the parameter. If no interval contains 'C' the resulted value is 'D + XXX/2' where 'D' is the distance between 'C' and the edge of the closest interval. Distance can be positive or negative depending on the position of the coordinate relative to the interval and the strand (-1 or 1) of the interval. Distance is always positive if 'strand' is '0' or if 'strand' column is missing. Distance is 'NA' if no intervals exist for the current chromosome.

src = [1D intervals], func = "distance.center", params = NULL
Given the center 'C' of the current iterator interval returns 'NaN' if 'C' is outside of the intervals, otherwise returns the distance between 'C' and the center of the closest interval. Distance can be positive or negative depending on the position of the coordinate relative to the interval and the strand (-1 or 1) of the interval. Distance is always positive if 'strand' is '0' or if 'strand' column is missing.

Once a virtual track is created one can modify its iterator behavior by calling 'gvtrack.iterator' or 'gvtrack.iterator.2d'.

Examples

# \dontshow{
options(gmax.processes = 2)
# }

gdb.init_examples()

gvtrack.create("vtrack1", "dense_track", "max")
gvtrack.create("vtrack2", "dense_track", "quantile", 0.5)
gextract("dense_track", "vtrack1", "vtrack2",
    gintervals(1, 0, 10000),
    iterator = 1000
)
#>    chrom start   end dense_track vtrack1 vtrack2 intervalID
#> 1   chr1     0  1000  0.08988887    0.20    0.06          1
#> 2   chr1  1000  2000  0.04100000    0.26    0.02          1
#> 3   chr1  2000  3000  0.04100000    0.10    0.04          1
#> 4   chr1  3000  4000  0.04100000    0.14    0.04          1
#> 5   chr1  4000  5000  0.04300000    0.18    0.04          1
#> 6   chr1  5000  6000  0.04000000    0.10    0.04          1
#> 7   chr1  6000  7000  0.05799999    0.22    0.04          1
#> 8   chr1  7000  8000  0.02400000    0.06    0.02          1
#> 9   chr1  8000  9000  0.03300000    0.10    0.03          1
#> 10  chr1  9000 10000  0.06899999    0.18    0.07          1

gvtrack.create("vtrack3", "dense_track", "global.percentile")
gvtrack.create("vtrack4", "annotations", "distance")
gdist("vtrack3", seq(0, 1, l = 10), "vtrack4", seq(-500, 500, 200))
#>                     (-500,-300] (-300,-100] (-100,100] (100,300] (300,500]
#> (0,0.111111]                  2           5         77         7         8
#> (0.111111,0.222222]           0           0          0         0         0
#> (0.222222,0.333333]           5           7         36         9         7
#> (0.333333,0.444444]           5           2         32         3         1
#> (0.444444,0.555556]           2           2         24         2         2
#> (0.555556,0.666667]           4           1         29         6         2
#> (0.666667,0.777778]           0           2         29         2         4
#> (0.777778,0.888889]           0           1         35         0         1
#> (0.888889,1]                  2           3         18         2         3
#> attr(,"breaks")
#> attr(,"breaks")[[1]]
#>  [1] 0.0000000 0.1111111 0.2222222 0.3333333 0.4444444 0.5555556 0.6666667
#>  [8] 0.7777778 0.8888889 1.0000000
#> 
#> attr(,"breaks")[[2]]
#> [1] -500 -300 -100  100  300  500
#>