data(gaschrom)
ref <- gaschrom[1,]
samp <- gaschrom[16,]
gaschrom.ptw <- ptw(ref, samp)
summary(gaschrom.ptw)
gaschrom.ptw <- ptw(ref, samp, init.coef = c(0, 1, 0, 0))
summary(gaschrom.ptw)
ref <- gaschrom[1,]
samp <- gaschrom[2:16,]
gaschrom.ptw <- ptw(ref, samp, warp.type = "individual", verbose = TRUE,
optim.crit = "RMS", init.coef = c(0, 1, 0, 0))
summary(gaschrom.ptw)
ref <- gaschrom[1:8,]
samp <- gaschrom[9:16,]
gaschrom.ptw <- ptw(ref, samp, warp.type = "individual",
optim.crit = "RMS", init.coef = c(0, 1, 0, 0))
summary(gaschrom.ptw)
gaschrom.ptw <- ptw(ref, samp, warp.type = "global",
optim.crit = "RMS", init.coef = c(0, 1, 0, 0))
summary(gaschrom.ptw)
# Example of a three-way data set
data(lcms)
# first bring all samples to the same scale
lcms.scaled <- aperm(apply(lcms, c(1,3),
function(x) x/mean(x) ), c(2,1,3))
# add zeros to the start and end of the chromatograms
lcms.s.z <- aperm(apply(lcms.scaled, c(1,3),
function(x) padzeros(x, 250) ), c(2,1,3))
# define a global 2nd degree warping
warp1 <- ptw(lcms.s.z[,,2], lcms.s.z[,,3], warp.type="global")
warp.samp <- warp1$warped.sample
warp.samp[is.na(warp.samp)] <- 0
# refine by adding 5th degree warpings for individual chromatograms
warp2 <- ptw(lcms.s.z[,,2], warp.samp, init.coef=c(0,1,0,0,0,0))
warp.samp2 <- warp2$warped.sample
warp.samp2[is.na(warp.samp2)] <- 0
# compare TICs
layout(matrix(1:2,2,1, byrow=TRUE))
plot(colSums(lcms.s.z[,,2]), type="l", ylab = "",
main = "TIC: original data")
lines(colSums(lcms.s.z[,,3]), col=2, lty=2)
plot(colSums(lcms.s.z[,,2]), type="l", ylab = "",
main = "TIC: warped data")
lines(colSums(warp.samp2), lty=2, col=2)
Run the code above in your browser using DataLab