bamCoverage not generating BigWig output file when using for loop
2
1
Entering edit mode
2.8 years ago

Hello!

I am trying to create multiple BigWig files from BAM files, and it seems like the loop is not giving an output file after converting. When ran with an individual file, this code works. However, the loop causes some issues that I cannot figure out.

Original code for single BAM file:

bamCoverage -b BAM_SRR11031277_mm10_sorted.bam \
-o BAM_SRR11031277_mm10_sorted.bw \
--binSize 20 \
--normalizeUsing BPM \
--smoothLength 60 \
--extendReads 150 \
--centerReads \
-p 6 

Loop:

for (( c = 479; c = 480; c++ ))
do
bamCoverage -b BAM_SRR9049${c}_sorted.bam \
-o BAM_SRR9049${c}_sorted.bw \
--binSize 20 \
--normalizeUsing BPM \
--smoothLength 60 \
--extendReads 150 \
--centerReads \
-p 6
done

slurm output file (for an individual run in the loop)

normalization: BPM
bamFilesList: ['BAM_SRR9049528_sorted.bam']
binLength: 20
numberOfSamples: None
blackListFileName: None
skipZeroOverZero: False
bed_and_bin: False
genomeChunkSize: None
defaultFragmentLength: 150
numberOfProcessors: 6
verbose: False
region: None
bedFile: None
minMappingQuality: None
ignoreDuplicates: False
chrsToSkip: []
stepSize: 20
center_read: True
samFlag_include: None
samFlag_exclude: None
minFragmentLength: 0
maxFragmentLength: 0
zerosToNans: False
smoothLength: 60
save_data: False
out_file_for_raw_data: None
maxPairedFragmentLength: 600

Thank you in advance!

deeptools bamCoverage • 1.6k views
ADD COMMENT
1
Entering edit mode
2.8 years ago

Your loop is probably not what you think. Try this and you will see your issue (infinite loop, hit control+C to escape from it):

for (( c = 479; c = 480; c++ ))
do
echo $c
done

You probably want something like this instead:

for (( c = 479; c <= 480; c++ ))
do
echo $c
done
ADD COMMENT
0
Entering edit mode

Thank you! I missed that typo, good catch.

ADD REPLY
0
Entering edit mode
2.8 years ago

I cannot help posting a snakemake implementation...:

SRR = ['SRR9049479', 'SRR9049480']

rule all:
    input:
        expand('BAM_{srr}_sorted.bw', srr= SRR)


rule makeBam:
    output:
        bam= 'BAM_{srr}_sorted.bam',
    shell:
        r"""
        bwa mem ... > {output.bam}
        """

rule bamCoverage:
    input:
        bam= 'BAM_{srr}_sorted.bam',
    output:
        bw= 'BAM_{srr}_sorted.bw',
    shell:
        r"""
        bamCoverage -b {input.bam} \
            -o {output.bw} \
            --binSize 20 \
            --normalizeUsing BPM \
            --smoothLength 60 \
            --extendReads 150 \
            --centerReads \
            -p 6
        """

Save as Snakefile and execute it with "snakemake -p -j 1 --dry-run" (omit --dry-run to actually execute it)

ADD COMMENT
0
Entering edit mode

I'm not very familiar with snakemake, what are the advantages of using this over for loops? I noticed you had to type the individual runs. My entire dataset has 60+ files, I was only using 2 to test it since I had errors.

ADD REPLY

Login before adding your answer.

Traffic: 1787 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