【发布时间】:2021-09-24 11:35:37
【问题描述】:
我创建了这个函数来从两个不同的文件中获取一些信息
create_distance_to_strand <- function(data, data2, nameCsv) {
newData <- data %>%
select(seqnames, start, end, V4, seqnames, geneStart, geneEnd, geneStrand, distanceToTSS, SYMBOL, geneLength)%>%
rename(peak = V4)
joined_df <- merge(newData , closest_dist, by.x = "peak",
by.y = "peak", all.x = TRUE, all.y = TRUE) %>% drop_na()
write.table(joined_df , nameCsv, sep = "\t")
return(joined_df)
}
closest_dist = read.csv("closest_distance", header = T, sep ="\t")
annotation = read.csv("results_annotation", header = T, sep ="\t")
myDistanceToStrand <- create_distance_to_strand(annotation, closest_dist, "frame.csv")
它按预期工作。但是,如果我有不同的"closest_dist" 文件,我会尝试使其更高效,以便将该功能应用于所有文件。
我试过这个:
files <- list.files(pattern = "closest*")
proof = lapply(files, create_distance_to_strand(annotation, closest_dist, "proof.csv"))
但是不行
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'y' in selecting a method for function 'merge': object 'closest_dist' not found
有什么建议吗? 谢谢
【问题讨论】: