1

I would like to find overlapped regions in the file and merge them keeping the earlier start and the later stop (merge 2 regions in 1)

I meant to use Genomic Ranges but I am not sure how to code the script.

This is what the file fileA.txt contain:

chr     start       end       value
chr1    58708485    58708713  1
chr1    58709084    58710538  2
chr1    98766295    98766639  3
chr1    98766902    98770338  4

Script:

library(GenomicRanges)
query = with(fileA.txt, GRanges(chr, IRanges(start=start, end=end)))
subject = with(fileA.txt, GRanges(chr, IRanges(start=start, end=end)))
hits = findOverlaps(gr1)
ranges(query)[queryHits(hits)] = ranges(subject)[subjectHits(hits)]

I am not sure how to set query and subject for a single file, as well the object being a document need any kind of "" or specific format (bedGraph, txt are fine?) in order to be recognised in the script?

Thank you a lot in advance for your help!

K.

Kaitsja
  • 23
  • 3

0 Answers0