Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

One useful way to compare two experiments (especially biological replicates, or similar experiments in two yeast strains/cell lines/mouse strains) is to compare where reads in one experiment overlap with reads in another experiment.  Bedtools offers a simple way to do this using the intersect function.

 

The intersect function has many options that control how to report the intersection.  We'll be focusing on just a few of these options, listed below.

-a and -b indicate what files to intersect.  in -b, you can specify one, or several files to intersect with the file specified in -a.

 bedtools intersect options

In this section, we'll intersect two human experiments - one from sequencing RNA, and one from sequencing miRNA.  Copy these files over to your directory:

 

Code Block
languagebash
titlebedtools intersect file gathering
cds 
mkdir intersect 
cd intersect 
cp /scratch/02423/nsabell/core_ngs/alignment/bam/human_rnaseq_bwa.bam . 
cp /scratch/02423/nsabell/core_ngs/alignment/bam/human_mirnaseq.bam .
 

As above, let's convert the high quality reads from these files over into a filtered bam file, then a bed file.

 

Expand
titlebam filtering and bed conversion of human bam files

#code goes here

 

Exercise 5: Intersect two experiments using intersect and examine the output

 

Expand
titlebedtools intersect code and output
Code Block
languagebash
cd intersect
module load bedtools #if you haven't loaded it up yet this session
 
bedtools intersect -wao -a  \
                             -b output.merge.bed > intersect.bed
wc -l intersect.bed
more intersect.bed

 

Using the options we've specified (-wao) the resulting file will have entries for file A, file B and the number of base pairs overlap between the feature in A and the features in B.