R/group_bymzisotopes1.R

Defines functions group_bymzisotopes1

group_bymzisotopes1 <- function(dataA, max.mz.diff = 30, 
    numisotopes = 4) {
    
    
    
    # Step 1 Group features by m/zdim(data_a)[1]
    mz_groups <- lapply(1:dim(dataA)[1], function(j) {
        
        commat = {
        }
        commzA = new("list")
        commzB = new("list")
        
        getbind_same <- c(j)
        
        
        
        for (isotopepattern in c(1:numisotopes)) {
            
            isotopemass = dataA$mz[j] + isotopepattern
            
            ppmb = (max.mz.diff) * (isotopemass/1e+06)
            
            getbind_same <- c(getbind_same, which(abs(dataA$mz - 
                isotopemass) <= ppmb))
            
            
            
        }
        gid <- paste("parent", getbind_same, sep = "")
        
        return(getbind_same)
        
    })
    
    return(mz_groups)
}
yufree/xMSannotator documentation built on Oct. 31, 2022, 12:20 a.m.