Does the multiIntersectBed function of the bedtools work with the parameter of fraction (`-f`). I am trying to intersect 4 bed files together to see if they have overlaps together but minimum bases should be around 50% , am not interested in single base match. I am interested in finding if 50% or above of bases in each file match among all bed files giving me the pattern showing the listing of the column where I can see all the labels together. I am trying to do something like this but it does not seem to work. if anyone can give me some suggestions how to get this done? It seems that `-u` and `-f` does not work here. Is there a way I can do that? I tried BEDOPS as well, not that much of a help. I would appreciate some input.

    multiIntersectBed -i file1.bed file2.bed file3.bed file4.bed -header -names A B C D -header -u -f .50| head

Regards
You can't do this directly with bedtools multiinter, but you can answer this by combing a few tools. It is a smidge complicated, but it should work and it demonstrates how combining multiple bedtools can usually get you the answer you need.

```
➜ cat a.bed
chr1    15    20    a1
chr1    18    25    a2   
➜ cat b.bed
chr1    16    20    b
➜ cat c.bed
chr1    17    21    c
```

Step 1: Find intervals common to all three files. The fourth column of the output is the number of datasets present at the interval, so it can be used as a filtering criterion.

```
➜ bedtools multiinter -i a.bed b.bed c.bed | awk '$4 == 3' > common.bed
➜ cat common.bed
chr1    17    21    3    1,2,3    1    1    1
```

Step 2. The issue now is that you don't know the degree of overlap these intervals have with the original intervals in each file. So, we will now just use the intersect tool to intersect the common intervals with the original 3 files while requiring 50% overlap.

```
➜ bedtools intersect -a common.bed \
                      -b a.bed b.bed c.bed \
                      -f 0.50 -r \
                      -wa -wb \
    > common.with.originals.bed
➜ cat common.with.originals.bed
chr1  17  21  3   1,2,3  1  1  1  1  chr1  15  20  a1
chr1  17  21  3   1,2,3  1  1  1  1  chr1  18  25  a2
chr1  17  21  3   1,2,3  1  1  1  2  chr1  16  25  b
chr1  17  21  3   1,2,3  1  1  1  3  chr1  17  21  c
```

Step 3. Now we have to filter the output from step 2 to ensure that the "common" intervals indeed overlapped with all 3 datasets. Conveniently, when using the `-wb` option with multiple "B" files, the intersect tool reports the dataset from which the hit came. In this case, that will be the 9th column. So, we just need to test that each interval from step 2 had hits from all three input files. We can do this with the groupby tool.

```
➜ bedtools groupby -g 1-8 -c 9 -o count_distinct -i common.with.originals.bed
chr1  17  21  3   1,2,3   1   1   1   3
```

Since the last column now reflect the count of distinct datasets that overlapped the common interval at 50%, you can use awk to filter for only those intervals where the count is 3.

```
➜ bedtools groupby -g 1-8 -c 9 -o count_distinct -i common.with.originals.bed \
  | awk '$9==3'
chr1  17  21  3   1,2,3   1   1   1   3
```