这是我的代码
slidingwindowplotATGC = function(windowsize, inputseq)
{
starts = seq(1, length(inputseq)-windowsize, by = windowsize)
n = length(starts)
chunkGs = numeric(n)
chunkAs = numeric(n)
chunkTs = numeric(n)
chunkCs = numeric(n)
for (i in 1:n) {
chunk = windowsize[starts[i]:(starts[i]+9999)]
chunkG = sum("g" == chunk)/length(chunk)
chunkA = sum("a" == chunk)/length(chunk)
chunkT = sum("t" == chunk)/length(chunk)
chunkC = sum("c" == chunk)/length(chunk)
chunkGs[i] = chunkG
chunkAs[i] = chunkA
chunkTs[i] = chunkT
chunkCs[i] = chunkC
}
plot(starts,chunkGs,type="b",ylim=c(min(min(chunkAs),min(chunkTs),min(chunkCs),min(chunkGs)),max(max(chunkAs),max(chunkTs),max(chunkCs),max(chunkGs))),col = "red")
points(starts,chunkTs,col = "blue")
points(starts,chunkAs,col = "green")
points(starts,chunkCs)
}
Im getting the following error message,
Error in seq.default(1, length(inputseq) - windowsize, by = windowsize) :
wrong sign in 'by' argument
我以前运行过这种类型的代码,从未遇到过这样的问题。实际上,我重新运行了之前完美运行的旧代码,但这次却收到了一条毫无意义的错误消息!在我彻底疯掉之前,我需要帮助解决这个问题...也许我只是不擅长这个程序,但我觉得它好像有自己的思想...之前我还收到过关于"ylim"函数的错误消息,指出它需要一个有限值,而我正是给了它一个有限值?救命啊!!!
nchar(inputseq)
而不是length(inputseq)
... - Ben Bolkerylim
错误信息的原因是你计算的碱基频率向量中的所有内容都是NA
... - Ben Bolker