You have a file containing the gene coordinates, and another file containing your MeDIP-seq reads.
A possible solution is to convert both files to the BED format, and then use intersectBed from bedtools to merge the two.
Example input genes file:
chr7 1000 1500 gene1 0 +
chr7 2000 2500 gene2 0 +
chr7 4000 5000 gene3 0 +
chr7 6000 7000 gene4 0 +
Example input MeDIP-seq reads count file:
chr7 1000 1001 sc 10 +
chr7 1100 1101 sc 10 +
chr7 1200 1201 sc 2 +
chr7 1300 1301 sc 10 +
chr7 1400 1401 sc 1 +
chr7 1500 1501 sc 10 +
chr7 1600 1601 sc 0 +
chr7 1700 1701 sc 10 +
chr7 1900 1901 sc 10 +
chr7 2000 2001 sc 10 +
chr7 2100 2101 sc 10 +
chr7 2200 2201 sc 10 +
chr7 2300 2301 sc 10 +
chr7 2400 2401 sc 10 +
chr7 2500 2501 sc 10 +
chr7 2600 2601 sc 10 +
Example of merged bed file (use the options -wa and -wb):
$: intersectBed -a bedseqscount.bed -b bed_genes.bed -wa -wb
chr7 1000 1001 sc 10 + chr7 1000 1500 gene1 0 +
chr7 1100 1101 sc 10 + chr7 1000 1500 gene1 0 +
chr7 1200 1201 sc 2 + chr7 1000 1500 gene1 0 +
chr7 1300 1301 sc 10 + chr7 1000 1500 gene1 0 +
chr7 1400 1401 sc 1 + chr7 1000 1500 gene1 0 +
chr7 2000 2001 sc 10 + chr7 2000 2500 gene2 0 +
chr7 2100 2101 sc 10 + chr7 2000 2500 gene2 0 +
chr7 2200 2201 sc 10 + chr7 2000 2500 gene2 0 +
chr7 2300 2301 sc 10 + chr7 2000 2500 gene2 0 +
chr7 2400 2401 sc 10 + chr7 2000 2500 gene2 0 +
From this file you can easily calculate the sum of values per each gene. There are many ways to do it, for example the doBy library in R.
Thank you so much for your help. How can I convert .txt file to .BED format with delimited columns? is there a way I can do it in Matlab?
best, Amy
You'll have to write a script to do it. I can't help you more because I don't know how your txt file looks like. If you want help, you should better open a new question and show an example of how your txt file looks like.