Question: Looping bedtools multicov on paired bam and bed files
1
gravatar for elb
9 months ago by
elb200
Torino
elb200 wrote:

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 • 212 views
ADD COMMENTlink modified 9 months ago by ATpoint44k • written 9 months ago by elb200
2
gravatar for ATpoint
9 months ago by
ATpoint44k
ATpoint44k wrote:
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 COMMENTlink written 9 months ago by ATpoint44k

Thank you very much!

ADD REPLYlink written 9 months ago by elb200
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 950 users visited in the last hour