R/computeSpectra.R

Defines functions computeSpectra

computeSpectra <- function(peaks=NULL, rt=NULL, rtRange=NULL, corThresh=NULL){

if(is.null(peaks)|is.null(rt)){

stop("Not enough data was provided!")

}

corPeaks<-cor(t(peaks))
diffrt <- diff(rt)

spectraID <- 1:length(rt)

i <- 1
spectraID[1]=1
index <- 1:length(rt)
for(i in c(1:length(spectraID))){
  if(!length(which(spectraID[i]==spectraID))>1){
    if(length(which(abs(rt[i]-rt[c(which(corPeaks[i,]>=corThresh)[-i])])<rtRange))>0){
      ind <- which(corPeaks[i,]>=corThresh)[-i][which(abs(rt[i]-rt[c(which(corPeaks[i,]>=corThresh)[-i])])<rtRange)]
      spectraID[ind] <- spectraID[i]
      index <- index[-ind]
    }
  }
}

return(spectraID)
}

Try the MAIT package in your browser

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

MAIT documentation built on Nov. 8, 2020, 5:43 p.m.