Skip to content

SLLOOOWWW function ...

3 messages · Johannes Graumann, Michael Dewey, Bart Joosen

#
Does anybody have any insight into how to make this faster?
I suspect, that the rounding going on may be an issue, as is the stepping
through data frame rows using integers ...

If you have the patience to teach a noob, he will highly appreciate it ;0)

Joh

digit <- 4
for (minute in seq(from=25,to=lrange[2])){
  # Extract all data associtaed with the current time (minute)
  frame <- subset(mylist,mylist[["Time"]] == minute)
  # Sort by Intensity
  frame <- frame[order(frame[["Intensity"]],decreasing = TRUE),]
  # Establish output frame using the most intense candidate
  newframe <- frame[1,]
  # Establish overlap-checking vector using the most intense candidate
  lowppm <- round(newframe[1,][["Mass"]]-newframe[1,
[["Mass"]]/1E6*ppmrange,digits=digit)
  highppm <- round(newframe[1,][["Mass"]]+newframe[1,
[["Mass"]]/1E6*ppmrange,digits=digit)
  presence <- seq(from=lowppm,to=highppm,by=10^(-digit))
  # Walk through the entire original frame and check whether peaks are
overlap-free ... do so until max of 2000 entries
  for (int in seq(from=2,to=nrow(frame))) {
    if(nrow(newframe) < 2000) {
      lowppm <- round(frame[int,][["Mass"]]-frame[int,
[["Mass"]]/1E6*ppmrange,digits=digit)
      highppm <- round(frame[int,][["Mass"]]+frame[int,
[["Mass"]]/1E6*ppmrange,digits=digit)
      windowrange <- seq(from=lowppm,to=highppm,by=10^(-digit))
      if (sum(round(windowrange,digits=digit) %in%
round(presence,digits=digit)) < 1) {
        newframe <- rbind(newframe,frame[int,])
        presence <- c(presence,windowrange)
      }
    } else {
      break()
    }
  }
1 day later
#
At 12:32 17/07/2007, Johannes Graumann wrote:
I am not an expert on R programming by any means but I notice you are 
growing your new data frame row by row. I believe it is normally 
recommended to allocate enough space to start with.
Michael Dewey
http://www.aghmed.fsnet.co.uk
1 day later
#
Hi

If I'm right you are trying to find peaks with about the same mass as the
maximum intensity.
Why not make the difference between the maximum mass and the list of masses
subsetted by intensity.
then subset the difference with a thresholded value.


If I'm not understanding your question clear, please let me know what you
are trying to do.
I've written some scripts for MS spectra analyses, if you're interested,
I'll try to find them.


Good luck

Bart
Johannes Graumann-2 wrote: