我一直在尝试使用从最近这样做的人传下来的R降价代码来分析我的Kallisto Quant数据。然而,与他们的输出不同,我收到一个错误,说该对象' kallistoData'找不到相同的代码。
```{r 1, warning=FALSE}
setwd("~/Desktop/KallistoQuant/1")
## this will create lists of all the samples
kallistoDirs = dir(".")
kallistoDirs = kallistoDirs[!grepl("\\.(R|py|pl|sh|xlsx?
|txt|tsv|csv|org|md|obo|png|jpg|pdf)$",
kallistoDirs,
ignore.case=TRUE)]
kallistoFiles = paste0(kallistoDirs, "/abundance.tsv")
names(kallistoFiles) = kallistoDirs
if(file.exists(kallistoFiles))
kallistoData = lapply(kallistoFiles,
read.table,
sep = "\t",
row.names = 1,
header = TRUE)
## this for loop uses the reduce function to make two data frame with counts or tpm from all the samples
ids = Reduce(f=union, x=lapply(kallistoData, rownames))
## ^this is where I see the error
if (all(sapply(kallistoData, function(x) {all(rownames(x)==ids)})))
{
count = data.frame(
id = ids,
sapply(kallistoData, function(x) {x$est_counts}),
check.names = FALSE,
stringsAsFactors = FALSE)
tpm = data.frame(id = ids,
sapply(kallistoData,
function(x) {x$tpm}),
check.names = FALSE,
stringsAsFactors = FALSE)
}
row.names(count) <- count$id
count[1] <- NULL
row.names(tpm) <- tpm$id
tpm[1] <- NULL
write.csv(count, "../1.csv", row.names=T)
write.csv(tpm, "../1TPM.csv", row.names=T)
```
感谢您的帮助!