Bugs

Please report bugs in comments…

Until the next update, copy and paste following commands at the R console each time you loaded the package haplotypes.

 

– Fixing a bug in ‘as.dna’ methods for signature Haplotypes.


#Coerce a Haplotype object to a Dna object

setMethod(f="as.dna", signature= "Haplotype", definition=function(x)
{

	seq<-x@sequence
	if(!nrow(seq)) stop("Haplotype object does not contain DNA sequences")
	dnaobj<-new("Dna",sequence=seq,seqlengths=rep(ncol(seq),nrow(seq)),seqnames=rownames(seq))
	dnaobj
}
)

– Fixing a bug in Extract methods for signature Dna


#Extract method for Dna objects

setMethod("[","Dna", function(x,i=1:nrow(x),j=1:ncol(x),as.matrix=TRUE)
{
	seq<-x@sequence[i,j,drop=FALSE]
	lseq<-ncol(seq)
	seqnames<-x@seqnames[i]
	if(as.matrix) return(seq) else new("Dna",sequence=seq,seqlengths=lseq,seqnames=seqnames)

})

– Fixing a bug in append methods for signature Dna


#append method for Dna objects 

setMethod(f="append", signature= "Dna", definition=function(x,values)
{
	seq<- rbind(x@sequence,values@sequence)
	dnaobj<-new("Dna",sequence=seq,seqlengths=c(x@seqlengths,values@seqlengths),seqnames=c(x@seqnames,values@seqnames))
	dnaobj
})

– Fixing a bug in subs method, May 2016


#Generic subs
setGeneric (
name= "subs",
def=function(x,...)standardGeneric("subs")
)



#subs method for Dna objects

setMethod(f="subs", signature= "Dna", definition=function (x,fifth=FALSE)
{
    
    seq<-toupper(x@sequence)
    if(!fifth) seq[is.na(match(seq,c("A","T","C","G")))]<-"?"
    if(fifth) seq[is.na(match(seq,c("A","T","C","G","-")))]<-"?"
    uniqs<-apply(seq,2,unique)
    if(is.matrix(uniqs))
    {
        uniqs<-lapply(seq_len(ncol(uniqs)), function(i) uniqs[,i])
        names(uniqs)<-colnames(seq)
    }
    whichpoly<-which(unlist(lapply(uniqs,length))>1)
    polymat<-seq[,whichpoly,drop=FALSE]
    
    if(ncol(polymat)>0)
    {
        
        polylist<- vector("list",0)
        
        for(i in 1:ncol(polymat))
        {
            
            substit<-unique(polymat[,i,drop=FALSE][polymat[,i,drop=FALSE]!="?"])
            
            if(length(substit)>1)
            {
                
                poly<-list(substit)
                names(poly)<-whichpoly[i]
                polylist<-c(polylist,poly)
            }
            
        }
        seq<-seq[,as.numeric(names(polylist)),drop=FALSE]
        return(list(subsmat=seq,subs=polylist,subsmnum=length(polylist)))
        
    } else {
        return(list(subsmat=polymat,subs=list(),subsmnum=0))
    }
}
)
Reklamlar

Bugs” üzerine bir yorum

  1. Thaks for the nice package.

    I have problems with the parsimnet funtion. What das der error message mean?
    > p<-parsimnet(x,indels="sic",prob=.95)
    Fehler in jump[prevset, nexp] <- jump[prevp, prevset] + x :
    Ersetzung hat Länge 0

    Is it possible to read also "R,M,Y" Baseinformation with the haplotype package?

    Thank xou very much.

    Cheers,
    Jonas Hagge


    Hi Jonas;
    It is difficult to understand the problem without seeing the data or at least all the codes. ‘x’ should be a Dna object from package haplotypes or a pairwise distance matrix (matrix or dist object) as in this example:

    require(haplotypes)
    data(dna.obj)
    x<- dna.obj
    #only the first 5 sequences
    x<-x[1:5,,as.matrix=FALSE]
    d<-distance(x)
    print(d)
         seq1 seq2 seq3 seq4
    seq2    2               
    seq3    1    1          
    seq4    1    1    0     
    seq5    4    3    3    3
    
    

    or:

    d<-as.matrix(distance(x))
    print(d)
    
         seq1 seq2 seq3 seq4 seq5
    seq1    0    2    1    1    4
    seq2    2    0    1    1    3
    seq3    1    1    0    0    3
    seq4    1    1    0    0    3
    seq5    4    3    3    3    0
    
    

    Do you mean protein codes? If yes, it is not available. However, an absolute character pairwise distance matrix can be imported to R (e.g. generated in PAUP). -Caner

Bir Cevap Yazın

Aşağıya bilgilerinizi girin veya oturum açmak için bir simgeye tıklayın:

WordPress.com Logosu

WordPress.com hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Twitter resmi

Twitter hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Facebook fotoğrafı

Facebook hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Google+ fotoğrafı

Google+ hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Connecting to %s