Global Parametric Time Warping in R The PTW package · The PTW package Global Parametric Time...

Post on 14-Oct-2020

4 views 0 download

Transcript of Global Parametric Time Warping in R The PTW package · The PTW package Global Parametric Time...

The PTW packageGlobal Parametric Time Warping in RTom Bloemberg

Institute for Molecules and Materials

Dept. Chemometrics / Analytical Chemistry

www.ru.nl/imm

Chromatographic example

The PTW packageGlobal Parametric Time Warping in R

Alignment

• Also: – ‘Synchronization’

– ‘(Time) Warping’

• Shift, stretch, compress• Applications in:

– Speech analysis

– Chromatography– NMR

– …

The PTW packageGlobal Parametric Time Warping in R

Parametric Time Warping1

• Before warping:

• After warping:

• Polynomial model of warping function:

• Minimize:

...)( 2210 +++= tataatw

The PTW packageGlobal Parametric Time Warping in R

1 Eilers, P.H.C. Analytical Chemistry 76 (2) 404-411 2004

∑=

=Q

q

qqtatw

0

)(

)Sample()Reference( tt ↔

))(Sample()Reference( twt ↔

( )∑ −i

ii twt 2))((Sample)(Reference

A single alignment

> library(ptw)

> data(chromatograms)

> chromatograms <- basel.off(chromatograms)

> C.warped <- ptw(chromatograms[1, ], chromatograms[1 6, ])

> plot(C.warped, plot.orig=TRUE, plot.wf=TRUE)

The PTW packageGlobal Parametric Time Warping in R

> library(ptw)

> data(chromatograms)

> chromatograms <- basel.off(chromatograms)

> C.warped <- ptw(chromatograms[1:8, ], chromatograms [9:16, ])

> plot(C.warped, plot.orig=TRUE, plot.wf=TRUE)

Multiple alignments

The PTW packageGlobal Parametric Time Warping in R

> library(ptw)

> data(chromatograms)

> chromatograms <- basel.off(chromatograms)

> C.warped <- ptw(chromatograms[1, ], chromatograms[2 :16, ])

> plot(C.warped, plot.orig=TRUE, plot.wf=TRUE)

LC-MS data

The PTW packageGlobal Parametric Time Warping in R

m/z

T

T

m/z

Tm/z

LC-MS data

The PTW packageGlobal Parametric Time Warping in R

m/z

T

Sig

nal

Global Alignment

The PTW packageGlobal Parametric Time Warping in R

• Choose ‘High Quality’ traces using CODA2,3

2Windig, W. Analytical Chemistry 68 (20) 3602-3606 1996

3Christin, C. Analytical Chemistry 80 (18) 7012-7021 2008

m/z

Time> library(ptw)

> data(LCMS)

> HQ <- coda(LCMS, combine=c(1,2), windows=c(3,1), n Chroms=5)

> LCMS.Warped <- ptw(LCMS[1, , ], LCMS[2, , ], HQ=HQ, align.method=“global”)

Global Alignment

The PTW packageGlobal Parametric Time Warping in R

> library(ptw)

> data(LCMS)

> HQ <- coda(LCMS, combine=c(1,2), windows=c(3,1), n Chroms=5)

> LCMS.Warped <- ptw(LCMS[1,,], LCMS[2,,], HQ=HQ, align.method = “global”)

> library(ptw)

> data(LCMS)

> HQ <- coda(LCMS, combine=c(1,2), windows=c(3,1), n Chroms=5)

> LCMS.Warped <- ptw(colSums(LCMS[1, , HQ]), colSums(LCMS[2, , HQ]), align.method = “individual”)

Discussion

The PTW packageGlobal Parametric Time Warping in R

• Second alignment package for R (next to dtw)

• Individual, multiple and global warpings• Trace selection (CODA)• Baseline removal (asymmetric LS)• Smoothing (Whittaker)

Planning

The PTW packageGlobal Parametric Time Warping in R

• Implement semi-PTW

• Implement other distance measures• Connect with dtw-package• Release on 1 September 2009

Acknowledgements

Jan Gerretzen

Hans WoutersRon WehrensLutgarde Buydens

Paul Eilers

Jolein GloerichHans WesselsBert van der Heuvel

The PTW packageGlobal Parametric Time Warping in R