Looping bedtools multicov on paired bam and bed files
1
1
Entering edit mode
4.0 years ago
elb ▴ 250

Hi guys, I would like to run bedtools multicov on paired (by name) .bam files and .bed files. In other words the situation is the following:

bedtools multicov -bams 1265_29_S1_L001_R1_001.sorted_PCRDuped.bam -bed 1265_29_S1_L001_R1_001_q0.001broad_peaks.bed > 1265_29_S1_L001_R1_001_q0.001_Counts.bed
bedtools multicov -bams 1265_30_S1_L001_R1_001.sorted_PCRDuped.bam -bed 1265_30_S1_L001_R1_001_q0.001broad_peaks.bed > 1265_30_S1_L001_R1_001_q0.001_Counts.bed
bedtools multicov -bams 1265_31_S1_L001_R1_001.sorted_PCRDuped.bam -bed 1265_31_S1_L001_R1_001_q0.001broad_peaks.bed > 1265_31_S1_L001_R1_001_q0.001_Counts.bed
  

I have many paired .bam/.bed files. Is there a way to run bedtools multicov by looping over paired .bam/.bed files by matching names? Thank you in advance!

ChIP-Seq bedtools • 1.0k views
ADD COMMENT
2
Entering edit mode
4.0 years ago
ATpoint 82k
for i in *.sorted_PCRDuped.bam
  do
  Basename=$(echo $i | awk -F ".sorted_PCRDuped.bam" '{print $1}')
  bedtools multicov \
  -bams ${Basename}.sorted_PCRDuped.bam \
  -bed ${Basename}_q0.001broad_peaks.bed \
  > ${Basename}_q0.001_Counts.bed
  done
ADD COMMENT
0
Entering edit mode

Thank you very much!

ADD REPLY

Login before adding your answer.

Traffic: 1835 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6