bash:mothur 的 trainset14_032015.rdp 的 README 中意外标记“(”附近有语法错误

bash:mothur 的 trainset14_032015.rdp 的 README 中意外标记“(”附近有语法错误

我正在尝试运行 mothur 中 trainset14_032015.rdp 的使用自述文件(http://blog.mothur.org/2014/10/28/RDP-v10-reference-files/),但是当我到达这一步时它不起作用,显示此错误:

$ tax_file <- scan(file="trainset14_032015_rmdup.tax", what="", sep="\n", quiet=TRUE)
bash: syntax error near unexpected token `('

因此,我读取并在 () 的开头和结尾放置了一些“”或‘’,但是它不起作用,因为它现在说该文件不存在,但事实确实如此!

$ tax_file <- scan"(file='/home/eugenia/Desktop/trainset14/trainset14_032015_rmdup.tax',what="", seq="\n", quiet=TRUE)"
bash: -: No such file or directory

我应该怎么办?

答案1

这些不是 bash 命令,而是 R 命令。出于某种原因,README 中没有明确说明,但这已经<-很明显了。我不知道mothur是什么原因,但您显示的 README 中的这些命令都应该在 R 中运行,而不是在 bash 中运行:

tax <- read.table(file="trainset10_082014_rmdup.tax", sep="\t")
tax$V2 <- gsub(" ", "_", tax$V2)    #remove spaces and replace with '_'
tax$V2 <- gsub("[^;]*_incertae_sedis$", "", tax$V2)
tax$V2 <- gsub('\"', '', tax$V2) #remove quote marks

levels <- read.table(file="trainset10_db_taxid.txt", sep="*", stringsAsFactors=F)
subs <- levels[grep("sub", levels$V5),]
sub.names <- subs$V2

tax.split <- strsplit(tax$V2, split=";")

remove.subs <- function(tax.vector){
    return(tax.vector[which(!tax.vector %in% sub.names)])
}

no.subs <- lapply(tax.split, remove.subs)
no.subs.str <- unlist(lapply(no.subs, paste, collapse=";"))
no.subs.str <- gsub("^Root;(.*)$", "\\1;", no.subs.str)

write.table(cbind(as.character(tax$V1), no.subs.str), "trainset10_082014.rdp.tax", row.names=F, col.names=F, quote=F, sep="\t")

上述所有命令(如前所述,应在 R 中运行)都用于准备文件以供使用mothur。它们只是修改包含分类信息的文件,使其与兼容mothur。本文作者选择使用 R 进行格式化步骤。

因此,您需要在 R 中运行我在此处引用的命令(打开终端,R在 R 的交互式 shell 中运行并粘贴命令)。我在此处未引用的命令应在 bash 中运行。

相关内容