This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to compare multiple bed files with a collection of these bed files one by one, calculate the number of overlapping fragments, and output to form a matrix

How to compare multiple bed files with a collection of these bed files one by one, calculate the number of overlapping fragments, and output a matrix to create a COOC diagram

bedtools cooc-diagram bed

Please edit the post to make the title more concise.

1 answer

for A in *.bed
do
  for B in *.bed
  do
    bedtools intersect -a $A -b $B | wc -l | tr "\n" "\t"
  done
  echo
done

In the previous post, due to my unclear description of the problem, the answer provided could only provide the number of repeated segments. However, I would like to know which segments in each bed file and the number of repetitions in the set bed file are missing, as well as which segments are zero repetitions compared to the set bed file. I really need your help, and I would greatly appreciate it if you could provide me with a solution

Log in to answer this question.