Question: Looping bedtools multicov on paired bam and bed files
1
gravatar for elb
3 months ago by
elb180
Torino
elb180 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 • 140 views
ADD COMMENTlink modified 3 months ago by ATpoint36k • written 3 months ago by elb180
2
gravatar for ATpoint
3 months ago by
ATpoint36k
Germany
ATpoint36k 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 3 months ago by ATpoint36k

Thank you very much!

ADD REPLYlink written 3 months ago by elb180
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: 1405 users visited in the last hour