WPCMS: Weighted Principal Curve Metric Scaling

Description Usage Arguments Value Examples

View source: R/WPCMS.R

Description

WPCMS function calculates the Weighted Principal Curve Metric Scaling solution for a contact matrix Z (e.g. representing a Hi-C contact matrix after some proper transformation applied) and a spline basis matrix H. The optimal solution is found via minimizing the weighted Frobenius norm

|| W x (Z - D^2(X) + β) ||

w.r.t. Θ subject to the smooth curve constraint X = HΘ. Here D(X) refers to the matrix of pairwise distances. The spatial coordiantes of the resulting reconstruction are presented in X.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
WPCMS(
  Z,
  H,
  W = matrix(1, nrow(Z), ncol(Z)),
  beta0 = -min(Z),
  Theta0 = matrix(rnorm(ncol(H) * 3), ncol(H), 3),
  update_beta = TRUE,
  eps = 1e-06,
  maxiter = 100,
  verbose = FALSE
)

Arguments

Z

a square symmetric matrix.

H

a spline basis matrix. By default assumed to have orthogonal columns. If not, orthogonalization should be done via QR decomposition.

W

a weights matrix, same dimension as Z. By default equal weights W = 1 are assumed.

Theta0

an initialization for spline basis coefficient matrix Theta. By defaul Theta0 = matrix(rnorm(ncol(H) * 3), ncol(H), 3), i.e. a random initialization is considered.

update_beta

If update_beta = TRUE, then the algorithm finds an optimal intercept value. If update_beta = TRUE, then the intercept is considered to be fixed and set to beta0.

eps

a positive convergence tolerance.

maxiter

an integer giving the maximal number of iterations.

verbose

logical. If TRUE, the WPCMS loss after each iteration is printed.

Value

A list containing the WPCMS problem solution:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(C)

#transform contact counts to distances
Z = 1/(C+1)

#create spline basis matrix
H = splines::bs(1:ncol(C), df = 5)

#orthogonalize H using QR decomposition
H = qr.Q(qr(H))

#run WPCMS with equal weights; optimize intercept 
WPCMS(Z, H)$X

#run WPCMS with random weights; fixed intercept
W = matrix(runif(length(Z)), dim(Z))
WPCMS(Z, H, W, beta = 1)$X

ElenaTuzhilina/PoisMS documentation built on Dec. 11, 2020, 1:29 a.m.