Entering edit mode
9.4 years ago
quachtina96
▴
40
Hi,
I am trying to convert my bam file into two fastq files in the command line, but I run into an error and I'm not sure what to change/do differently. Thoughts/advice?
my line:
bedtools bamtofastq ID18_Father_exome_L001_001_mtExtract.qsort.bam -fq test1.fq -fq2 test2.fq
the error:
*****ERROR: Unrecognized parameter: ID18_Father_exome_L001_001_mtExtract.qsort.bam *****
*****
*****ERROR: Need -bam.
*****
Tool: bedtools bamtofastq (aka bamToFastq)
Version: v2.17.0
Summary: Convert BAM alignments to FASTQ files.
Usage: bamToFastq [OPTIONS] -i <BAM> -fq <FQ>
Options:
-fq2 FASTQ for second end. Used if BAM contains paired-end data.
BAM should be sorted by query name is creating paired FASTQ.
-tags Create FASTQ based on the mate info
in the BAM R2 and Q2 tags.
Tips:
If you want to create a single, interleaved FASTQ file
for paired-end data, you can just write both to /dev/stdout:
bedtools bamtofastq -i x.bam -fq /dev/stdout -fq2 /dev/stdout > x.ilv.fq
As I was writing the question, I realized that I didn't include the -i before the bam file name, however including it resulted in the following error:
error: unrecognized command: -i
Please help!
Hi Devon! You were right. I put in on the left of bamToFastq instead of the right! But I have one more question:With the following command,
I got the following in the output:
Do you know what I could do to fix this? Or what this may mean?
Make sure to query sort the file (samtools sort -n).
See my reply in this A: Can't convert paired end BAM to bed using bedtools for a way to stop this error and why it occurs. If you have a paired-end dataset, then bedtools wants the pairs on subsequent lines. To do this you have to sort the BAM file by read name.
Yes, I did sort the BAM file by read name before running the command. I am not sure if my situation is different because the bam I am working with is only the mtDNAextract bam and thus is just the chrM. The rest of the header is there from when I extracted the bam with header (came from the bam from which I extracted the chrM). The bam file I am working with is only chrM. the first portion of the header is the following:
and so on...
If you have any singletons then there's nothing you can do but exclude them. In other words, do a
samtools view mtExtract.qsort.bam | grep "D3NJ6HQ1:424:HA49WADXX:1:1103:21194:65285"
and see if you get both mates. If not, then you might need to prefilter things. You might also just check the fastq files. If bedtools just skips over these then you have nothing to worry about.