R/Recollapse.R

Defines functions Recollapse

Documented in Recollapse

Recollapse <-
function(seqs,nr){
    ## Reollapse haplotipes after some transformation
        ## seqs: a DNAStringSet with rawreads
        ##   nr: vector of counts
    # Read and sort the sequences.
    seqso<-seqs
    sqtbl <- sort(tapply(nr,as.character(seqso),sum),decreasing=TRUE)
    seqso <- names(sqtbl)
    names(seqso) <- seq_len(length(seqso))
    # Store the abundnaces
    nr <- as.integer(sqtbl)
    # Create an DNAStringSet or AAStringSet
    if(is(seqs,"DNAStringSet")) seqso <- DNAStringSet(seqso)
    if(is(seqs,"AAStringSet")) seqso <- AAStringSet(seqso)
    # Return a list of two elements with the alignment 
    # and the abundances. 
    return(list(nr=nr,seqs=seqso))
}

Try the QSutils package in your browser

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

QSutils documentation built on Nov. 8, 2020, 7:42 p.m.