R/as.list-functions.R

Defines functions .as.occurrence.list.MassObjectList

## .as.occurrence.list
##  internal function to create a list of peaks occurrence
##
## params:
##  l: list of AbstractMassObject objects
##
## returns:
##  a list, where sample is the sample id, i is the index of the uniqueMass,
##  and mass is the unique mass vector
.as.occurrence.list.MassObjectList <- function(l) {
    .stopIfNotIsMassObjectList(l)

    mass <- .unlist(lapply(l, function(x)x@mass))
    uniqueMass <- sort.int(unique(mass))
    n <- lengths(l)

    list(
        sample = rep.int(seq_along(l), lengths(l)),
        i = findInterval(mass, uniqueMass),
        mass = uniqueMass
    )
}

Try the MALDIquant package in your browser

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

MALDIquant documentation built on March 31, 2023, 10:40 p.m.