我在R(3.2.3)
中运行此代码outfolder <- "CAI_inter_domains_ENA/"
if (!file.exists(outfolder))dir.create(outfolder)
genome.and.organisms <- read.csv(file = "test_genomes_ENA10.csv", header = FALSE,
as.is=TRUE)
# calculating the codon adaptation index for all genomes and its domains
for (genomeID in genome.and.organisms[,1]) {
fileout <- paste(outfolder, genomeID, "_CAI_inter.csv", sep="")
#check if file already exists
if (!file.exists(fileout)) {
# Going through all genome numbers and retrieving their weight vectors and domain data
w.files <- paste("Reference_weight_tables_ENA/", genomeID, ".csv", sep = "")
if (file.exists(w.files)){
w.data <- read.csv(file = w.files, header = FALSE, as.is = TRUE)
# ordering on rownames, for it to be correctly used by cai function
ordered.w <- w.data[with(w.data, order(V1)), ]
# only leaving numbers
w <- ordered.w[,2]
domain.files <- paste("Domain_data_ENA/", genomeID, ".csv", sep = "")
domain.data <- read.csv(file = domain.files, header = TRUE,
as.is=TRUE)
#alot of different stuff happens here..
#like making dataframes
# these are written to a file
write.table(domain.data.CDS, file = "tmp.csv", append = FALSE, sep = ",", row.names = FALSE, quote = FALSE, col.names = FALSE)
# converting the sequences to fasta format with python file
convertcmd <- "python Write_csvtofasta.py"
system(convertcmd)
# opening the written file and calculating the CAI
fasta.domains <- read.fasta(file = "tmp.fasta")
cai.inter.output <- sapply(fasta.domains, cai, w = w)
write.table(cai.inter.output, file = fileout, append = F, sep = ",",
row.names = names(cai.inter.output), quote = F, col.names = F)
}
代码工作正常,直到它使用“cai”函数的部分,在那里它抛出了我的错误,我不知道我该怎么做才能解决它:
Error in seq.default(from = frame + 1, to = length(seq), by = word) :
wrong sign in 'by' argument
tmp.fasta是一个fasta文件,其中包含大量的fasta序列,就像通常的fasta文件格式一样: (http://bioinformatics.intec.ugent.be/MotifSuite/images/Fasta.png)
for循环仅适用于某些基因组ID,因为我试图将输入文件“test_genomes_ENA10.csv”更改为只有一个基因组ID。
我试图更仔细地查看seq.default函数,这一行会引发错误:
if (n < 0L)
stop("wrong sign in 'by' argument")
但是当我调查这个if语句如何被评估为真时,对我来说是一个谜。
这里的任何人都可以帮我解决这个神秘的错误吗?
聚苯乙烯。功能
cai
来自“seqinr”包