distance_peak {FunChIP} | R Documentation

## Computing distance matrices among spline-smoothed peaks and among their derivatives.

### Description

Given a metric (L^1, L^2 or L^∞), it computes the pairwise distance among the spline approximation of the peaks and among their derivatives. If summit is provided, peaks are centered around the summit to compute the distances.

### Usage

    distance_peak(object, p = 1, rescale = FALSE)

### Arguments

`object` | GRanges object of length N. It has to contain the metadata columns `spline`, `spline_der`, `width_spline`.
`p` | integer. It must assume values in `{0, 1, 2}`. They correspond respectively to the L^{∞}, L^1 and L^2 norm. See details for the definition of the norms.
`rescale` | logical. If `TRUE` the distance among scaled peaks is computed. For the definition of scaled peaks see smooth_peak.

### Details

This function computes the pairwise distance of a set of N peaks. Given the spline-smoothed peaks s_i and their derivatives s^{\prime}_i (i = 1, …, N), it returns two matrices `dist_matrix_d0` and `dist_matrix_d1` whose elements (i,j), with i, j = 1, …, N, are

dist_matrix_d0 (i.j) = || s_i - s_j||_p dist_matrix_d1 (i.j) = || s'_i - s'_j||_p

.

In particular, in order to define the distance between two functions f and g:

- define a common domain U, given by the union of the domains of f and g. If a function is not defined on the whole domain, it is extended with 0's on the missing parts. The value of 0 is chosen because the background of the peaks has been removed during the definition of the splines, and hence they can now be continuously extended with 0's.

- choose the order of the norm `p`. Given the function f defined on U we have:

  || f ||_0 = || f ||_{L^∞} = max_{x in U} | f(x) |

  ,

  || f ||_1 = || f ||_{L^{1}} = int (|f(x)| dx)

  ,

  || f ||_2 = || f ||_{L^{2}} = sqrt(int (f(x))^2 dx)

  .

### Value

list with two components

`dist_matrix_d0` | N x N matrix of the pairwise distances between the splines.
`dist_matrix_d2` | N x N matrix of the pairwise distances between the derivatives of splines.

### Author(s)

Alice Parodi, Marco J. Morelli, Laura M. Sangalli, Piercesare Secchi, Simone Vantini

### Examples

    # load the data
    data(peaks)

    # Compute the pairwise
    # L2 distance between the peaks
    dist_matrices <- distance_peak(peaks.data.summit, p = 2)

[Package FunChIP version 1.10.0 Index]