Open Ge0rges opened 11 months ago
Ok it seems that this is due to the fact that 0 rows are left after coverage filtering. MethylKit unfortunately does not handle this very gracefully. @alexg9010 is there a way to skip files with 0 rows after coverage filtering instead of crashing?
Browse[5]> n
debug: data[, coverage.col] = round(data[, coverage.col])
Browse[5]> n
debug: data = data[data[, coverage.col] >= mincov, ]
Browse[5]> n
debug: strand = rep("+", nrow(data))
Browse[5]> print(data)
[1] V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18
<0 lignes> (ou 'row.names' de longueur nulle)
Hi @Ge0rges ,
You are right, this edge case is not handled very well. For now, you could use tryCatch
to filter files with zero rows. using this code snippet:
meth_list <- lapply(seq_along(file.list),
function(i) {
tryCatch(
expr = {
methRead(
location = file.list[[i]],
sample.id = as.list(samples)[[i]],
assembly=assembly,
# treatment=treatment,
context="CHH",
pipeline=pipeline,
header=FALSE,
mincov=5)
)
},
error = function(e) {
message(paste0("file ", file.list[[i]], " failed to load."))
return(NULL)
}
)
})
failed_samples <- sapply(meth_list, is.null)
meth_obj <- methylRawList(meth_list[!failed_samples], treatment = treatment[!failed_samples])
Best Alex
Thanks for that solution.
Hello,
I have written an R script that uses methylKit to ultimately get DMRs. In this script, I read in multiple
.bed
files into a singlemethRead()
call. The script completes successfully on at least 3 different sets of data I have input.I am encountering an odd issue however with one dataset where the following error occurs:
As you can see, this happens when reading in file 2. However, these files are all generated in an identical fashion by a master script. Here is what their head looks like:
Relevant script:
I appreciate any tips.