[R] Problem with substr

sophy1987 yatingcheng.marina at gmail.com
Tue Nov 15 22:31:25 CET 2011


Hi, everyone
When I ran this cript,  There is Error in substring(tmp.subject, tmp.end[ex]
+ 1, tmp.start[ex + 1] - 1) : 
  invalid substring argument(s)

Could someone figure out what the problem is?

for(i in 1:length(genebody[,1])){

	tmp.id<-as.vector(genebody[i,1])											# get gene id
	tmp.subject<-as.vector(genebody[i,2])										# get gene sequence
	tmp.exons<-exons[which(exons[,1]==tmp.id),]									# get exons of the
selected genes

	tmp.pattern<-as.vector(tmp.exons[,3])										# define exons as patterns
for alignment
	tmp.align<-pairwiseAlignment(pattern=tmp.pattern,
subject=tmp.subject,type="local")			# align all exons pairwise to gene
sequence
	tmp.start<-start(subject(tmp.align))										# vector of all alignment
starts
	tmp.end<-end(subject(tmp.align))											# vector of all alignment ends
	
	for(ex in 1:(length(tmp.end)-1)){											# extract introns

		tmp.intron<-substr(tmp.subject,tmp.end[ex]+1,tmp.start[ex+1]-1)

             
introns<-rbind(introns,cbind(tmp.id,tmp.end[ex]+1,tmp.start[ex+1]-1,tmp.intron))

				}

	}


Thank you

--
View this message in context: http://r.789695.n4.nabble.com/Problem-with-substr-tp4074312p4074312.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list