Cost Matrix

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Calculation of the cost matrix

Wolfgang Huber April 13, 2011

Problem statement and denitions

Let ynj be the data value at position (genomic coordinate) n = 1, . . . , N for replicate array j = 1, . . . , J. Hence we have J arrays and sequences of length N . The goal of this note is to describe an O(N J) algorithm to calculate the cost matrix of a piecewise linear model for the segmentation of the (1, . . . , N ) axis. It is implemented in the function costMatrix in the package tilingArray. The cost matrix is the input for a dynamic programming algorithm that nds the optimal (least squares) segmentation. The cost matrix Gkm is the sum of squared residuals for a segment from m to m + k 1 (i. e. including m + k 1 but excluding m + k),
J m+k1

Gkm :=
j=1 n=m

(ynj km )2

(1)

where 1 m m + k 1 N and km is the mean of that segment, km = 1 Jk


J m+k1

ynj .
j=1 n=m

(2)

Sidenote: a perhaps more straightforward denition of a cost matrix would be Gm m = G(m m) m , the sum of squared residuals for a segment from m to m 1. I use version (1) because it makes it easier to use the condition of maximum segment length (k <= kmax ), which I need to get the algorithm from complexity O(N 2 ) to O(N ).

Algebra
J m+k1

Gkm =
j=1 n=m 2 ynj n,j

(ynj km )2 1 yn j Jk n ,j
2

(3)

(4)

=
n

1 qn Jk

rn
n

(5)

with qn :=
j 2 ynj

(6) (7)

rn :=
j

ynj

If y is an N J matrix, then the N -vectors q and r can be obtained by q = rowSums(y*y) r = rowSums(y) Now dene

c d which be obtained from c = cumsum(r) d = cumsum(q) then (5) becomes

=
n=1

rn qn
n=1

(8) (9)

(dm+k1 dm1 )

1 (cm+k1 cm1 )2 Jk

(10)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy