Bam2chicago: no such file or directory

Issue #29 resolved
Pablo Acera created an issue

Hi, I wrote a ticket yesterday, but you close it and indeed fix the error that was happening, thank you very much for that. Unfortunately, when I run it now, I get and different error:

Checking rmap and baitmap files... Rmap and baitmap files checked successfully Processing sample output_sample... Using bam file ../out_hicup/SRR3535023_1_2.hicup.bam Using baitmap file /Users/pacera/developing/C-HiC/tests/data/test_makeBaitmap/test.baitmap Using digest map (rmap) file /Users/pacera/developing/C-HiC/tests/data/test_makeRmap/restriction_enzyme_test_HindIII_GRCh38.rmap Baitmap file contains >4 columns. Checking if /Users/pacera/developing/C-HiC/tests/data/test_makeBaitmap/test.baitmap_4col.txt exists... Found /Users/pacera/developing/C-HiC/tests/data/test_makeBaitmap/test.baitmap_4col.txt Intersecting with bait fragments (using min overhang of 0.6)... Flipping all reads that overlap with the bait on to the right-hand side... Intersecting with bait fragments again to produce a list of bait-to-bait interactions that can be used separately; note they will also be retained in the main output... Intersecting with restriction fragments (using min overhang of 0.6)... Removing reads that failed the min overhang filter... Adding frag length and signed distance from bait; removing self-ligation fragments (if any; not expected with HiCUP input)... Can't open output_sample/SRR3535023_1_2.hicup_mappedToBaitsBoRAndRFrag_fmore06.bedpe: No such file or directory. rm: output_sample/SRR3535023_1_2.hicup_mappedToBaitsBoRAndRFrag_fmore06.bedpe: No such file or directory

It looks like bam2chicago.sh is not able to generate some file. Please, is that because I am using just two chromosomes and a subset of the total reads? I cannot think on anything else. I have tried to run it using different BAM files using HiCUP, with both hg19 and hg38. Thank you very much for your time.

Comments (5)

  1. Mikhail Spivakov

    Hi Pablo

    Sadly I cannot solve this without trying to run it myself on the actual data.

    Does this file actually not exist: output_sample/SRR3535023_1_2.hicup_mappedToBaitsBoRAndRFrag_fmore06.bedpe?

    Can it be created in that directory in terms of filesystem permissions?

    You can try running the shell script step by step yourself to try and identify the problem. Failing that, please share with me a minimal example of all files that reproduces this issue.

  2. Pablo Acera reporter

    Hi Mikhail,

    Thank you very much for your answer.

    I have been running the script by chunks of code and I have found two issues. I am going to post it here just in case someone can benefit from it.

    The first one happends when I used HICUP to map my reads, the bam file generated has the chromosome number as "chr#". But when using rmap and baitmap from CHiCAGO, the chromosomes are just a number, so bedtools does not recognise any match. The second issue I am having and more mysterious.. when running this command; bedtools pairtobed -abam $bam -bedpe -b $baitfendsid -f 0.6 > ${samplename}/${bamname}_mappedToBaits.bedpe

    My output ${samplename}/${bamname}_mappedToBaits.bedpe contains 14 columns. But apparently should be 15 columns, as the following awk code; awk 'BEGIN{ OFS="\t" } { minRight=$13<$3?$13:$3; maxLeft=$12>$2?$12:$2; if($1==$11 && (minRight-maxLeft)/($3-$2)>=0.6){ print $4,$5,$6,$1,$2,$3,$7,$8,$10,$9,$11,$12,$13,$14,$15 } else { print $0 } }' ${samplename}/${bamname}_mappedToBaits.bedpe > ${samplename}/${bamname}_mappedToBaits_baitOnRight.bedpe

    If I am not wrong, this reorder the columns. But as my file has 14 columns, the $15 column is just a tab without any number. This produce that future bedtools command fails because of tabs at the end. I have tried several times. Does ${samplename}/${bamname}_mappedToBaits.bedpe really has to have 15 columns??

    Thank you very much for your time. Cheers

  3. Mikhail Spivakov

    Thanks for reporting this. Yes, the chr / no chr mismatch is a typical and rather annoying issue. Perhaps we should include a check for this.

    As for 14 vs 15 columns, one situation where this may arise is if your baitmap file doesn't have fragment annotations - only fragment coordinates and numbers. Can you check if this is the case?

  4. Pablo Acera reporter

    Hi Mikhail, thank you for your quick answer.

    Indeed I have my baitmap file without fragment annotations. Sorry I thought that this part to the code;

    if [ $baitcolno -gt 4 ]; then echo "Baitmap file contains >4 columns. Checking if ${baitfendsid}_4col.txt exists..." if ! [ -e ${baitfendsid}_4col.txt ]; then echo "It doesn't. So trimming the extra columns and saving the result in ${baitfendsid}_4col.txt..." awk '{print $1"\t"$2"\t"$3"\t"$4}' ${baitfendsid} > ${baitfendsid}_4col.txt else echo "Found ${baitfendsid}_4col.txt" fi baitfendsid=echo ${baitfendsid}_4col.txt fi echo "Intersecting with bait fragments (using min overhang of 0.6)..." bedtools pairtobed -abam $bam -bedpe -b $baitfendsid -f 0.6 > ${samplename}/${bamname}_mappedToBaits.bedpe

    Was selecting the file with just four columns, as my file has, without the annotation. Thank you again, cheers.

  5. Log in to comment