Skip to content

Commit

Permalink
[export_tbx2bw] skip chromosomes without mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
alexg9010 committed Jul 19, 2024
1 parent 598af04 commit db812cc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/export_tbx2bw.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ methList <- lapply(SinfoList,

message("Processing chromosome ",seqnames(gr),"...")

tryCatch(
{

# read directly from tabix file and process in chunks
dt <- methylKit:::applyTbxByOverlap(
tbxFile = filepath,
Expand All @@ -136,9 +139,16 @@ methList <- lapply(SinfoList,
return(GenomicRanges::makeGRangesFromDataFrame(
dt,seqinfo = Sinfo, keep.extra.columns=TRUE)
)

},
error = function(e) {
message("Chromosome ",seqnames(gr)," failed.")
return(NULL)
})
})

methList <- unlist(GRangesList(methList))
# remove empty list elements
methList <- unlist(GRangesList(methList[!sapply(methList,is.null)]))

rtracklayer::export.bw( object = methList, con = out_path )

Expand Down

0 comments on commit db812cc

Please sign in to comment.