R/sortSNPs.R

`sortSNPs` <-
function (data, colSNPs, info) 
{
    o <- order(info[, 2], info[, 3])
    label.SNPs.o <- info[o, 1]
    label.SNPs <- names(data[, colSNPs, drop=FALSE])

#control
    ans <- match(label.SNPs, label.SNPs.o)
    if (sum(is.na(ans)) > 0) {
        
        warning("The SNPs: ", as.character(label.SNPs[is.na(ans)]),
                "are not included in the file with the genomic positions and they are discarded" )
        
    }

    ans <- match(label.SNPs.o, label.SNPs)


    out <- colSNPs[ans[!is.na(ans)]]
    out <- out[!is.na(out)]
    res <- list(pos=out, dataSorted=info[o,])
    res 
}
isglobal-brge/SNPassoc documentation built on May 15, 2023, 8:10 p.m.