############################################### # I run the following attachd code lines # But I kept getting error message like this: ############################################### # when i is: 849 time is: Sun May 23 20:54:35 2010 # when i is: 850 time is: Sun May 23 20:54:35 2010 # Error in assign(".Method", method, envir = envir) : # formal argument "envir" matched by multiple actual arguments # Error in shift(restrict(nir, start = solved_start, end = solved_end), : # error in evaluating the argument 'x' in selecting a method for function 'shift' # when i is: 1002 time is: Sun May 23 20:55:37 2010 # when i is: 1003 time is: Sun May 23 20:55:37 2010 # Error in assign(".target", method@target, envir = envir) : # formal argument "envir" matched by multiple actual arguments # Error in shift(restrict(nir, start = solved_start, end = solved_end), : # error in evaluating the argument 'x' in selecting a method for function 'shift' ################################################################### # # The following is my code: # #################################################################### library("ShortRead") library("Biostrings") library("IRanges") library("BSgenome") library("rtracklayer") library("biomaRt") library("BSgenome.Hsapiens.UCSC.hg18") get.rev.fasta<-function( chr = Hsapiens$chrX, chr.name="chrX" ) { # This funciton is used to get all bases for one chromosome and then reverse it to # create a reversed fasta file. I will get the complement later options(digits=16) # We need to set up this, otherwise, num.line will just be an integer num.line = floor(length(chr)/50) # this gives the total number of lines, note, here we need to use floor reminder = length(chr)%%50 # this gives the number of bases in the last line LL<-length(chr) fasta.list<-as.character( rep(NA, num.line + 2 ) ) fasta.list[1]<-paste(">", chr.name, sep="") # This is the first line (e.g., ">chr1") in a fastq file. for ( i in 1:num.line ) { # if (i%%5000==0) { cat("when i is:", i, "time is:", date(), "\n") } cat("when i is:", i, "time is:", date(), "\n") start.1 = LL-i*50 +1 ; end.1 = LL-(i-1)*50 xx<-getSeq(Hsapiens, paste(chr.name), start= start.1, end=end.1, strand="+") xx.1<-strsplit(xx, "") # split string to a vector xx.2<-lapply(xx.1, rev) # reverse it xx.3<-sapply(xx.2, paste, collapse="") # convert vector to string # class(xx.3) # this is a chracter fasta.list[i+1]<-xx.3 } xx<-getSeq(Hsapiens, paste(chr.name), start=1 , end= reminder, strand="+") xx.1<-strsplit(xx, "") # split string to a vector xx.2<-lapply(xx.1, rev) # reverse it xx.3<-sapply(xx.2, paste, collapse="") # convert vector to string fasta.list[num.line + 1 ]<-xx.3 # This is the last line in the reverse fasta files. return(fasta.list) } get.rev.fasta( chr = Hsapiens$chrX, chr.name="chrX" )