pybedtools.bedtool.BedTool.multi_intersect

BedTool.multi_intersect(*args, **kwargs)[source]

Wraps bedtools multiintersect.

Provide a list of filenames as the “i” argument. e.g. if you already have BedTool objects then use their .fn attribute, like this:

>>> x = pybedtools.BedTool()
>>> a = pybedtools.example_bedtool('a.bed')
>>> b = pybedtools.example_bedtool('b.bed')
>>> result = x.multi_intersect(i=[a.fn, b.fn])
>>> print(result)   
chr1        1       155     1       1       1       0
chr1        155     200     2       1,2     1       1
chr1        200     500     1       1       1       0
chr1        800     900     1       2       0       1
chr1        900     901     2       1,2     1       1
chr1        901     950     1       1       1       0

There are two alternatives for supplying a genome. Use g="genome.filename" if you have a genome’s chrom sizes saved as a file. This is the what BEDTools expects when using it from the command line. Alternatively, use the genome="assembly.name" (for example, genome="hg19") to use chrom sizes for that assembly without having to manage a separate file. The genome argument triggers a call pybedtools.chromsizes, so see that method for more details.

Original BEDTools help::

Tool:    bedtools multiinter (aka multiIntersectBed)
Version: v2.30.0
Summary: Identifies common intervals among multiple
         BED/GFF/VCF files.

Usage:   bedtools multiinter [OPTIONS] -i FILE1 FILE2 .. FILEn
         Requires that each interval file is sorted by chrom/start. 

Options: 
        -cluster        Invoke Ryan Layers's clustering algorithm.

        -header         Print a header line.
                        (chrom/start/end + names of each file).

        -names          A list of names (one/file) to describe each file in -i.
                        These names will be printed in the header line.

        -g              Use genome file to calculate empty regions.
                        - STRING.

        -empty          Report empty regions (i.e., start/end intervals w/o
                        values in all files).
                        - Requires the '-g FILE' parameter.

        -filler TEXT    Use TEXT when representing intervals having no value.
                        - Default is '0', but you can use 'N/A' or any text.

        -examples       Show detailed usage examples.