R/fpca.R

Defines functions fpca

Documented in fpca

fpca <- function(profiles,numberOfComponents,K,nderiv,lambda){
  # Functional Principal Component Analysis of the read-enriched regions
#require(splines)

	numberOfProfiles <- length(profiles)
	profMatrix <- t(profiles)
	argvalsBS <- 1:nrow(profMatrix)
	bspl <- create.bspline.basis(rangeval=c(1,nrow(profMatrix)),nbasis=K, norder=4)
	fdamatrix <- Data2fd(y=profMatrix, argvals= argvalsBS, basisobj=bspl,nderiv=nderiv, lambda=lambda)
	fpcamatrix <- pca.fd(fdobj = fdamatrix, nharm = numberOfComponents, harmfdPar=fdPar(fdamatrix), centerfns = TRUE)
	pcOfprofMatrix <- eval.fd(argvalsBS,fpcamatrix$harmonics)
	return(list(eigenfunctions=pcOfprofMatrix,fpcaout=fpcamatrix,fdaData=fdamatrix,rangevalues=argvalsBS,basisfunct=bspl))

}

Try the NarrowPeaks package in your browser

Any scripts or data that you put into this service are public.

NarrowPeaks documentation built on April 28, 2020, 6:51 p.m.