Volumes/GENOMA/BWA/GENOMA/BWA/V350019555_L03_B5GHUMqcnrRAABA-549.bam Error loading BAM file: org.broad.igv.exceptions.DataLoadException: An error occurred while accessing: /Volumes/GENOMA/BWA/GENOMA/BWA/V350019555_L03_B5GHUMqcnrRAABA-549.bam.bai Index file not found. Tried /Volumes/GENOMA/BWA/GENOMA/BWA/V350019555_L03_B5GHUMqcnrRAABA-549.bai /Volumes/GENOMA/BWA/GENOMA/BWA/V350019555_L03_B5GHUMqcnrRAABA-549.bam.csi /Volumes/GENOMA/BWA/GENOMA/BWA/V350019555_L03_B5GHUMqcnrRAABA-549.csi
Looks like you have not indexed your BAM files. Are they co-ordinated sorted? If not you should do that first. If you have samtools installed you can use that or use igvtools included in IGV. You can also use samtools merge to merge the BAM files. See help page here.
This may be language related but the command is samtools merge not mergue.
When you get the files merged, you will want to samtools sort --write-index -o sorted.bam merged.bam to get final merged/sorted/indexed file. Final file can then be visualized using IGV.
Will the files be fine or is it a problem with the syntax?
(base) javier@iMac-de-JAVIER BWA % samtools merge 1.bam V350019555_L03_B5GHUMqcnrRAABA-549.bam V350019555_L03_B5GHUMqcnrRAABA-550.bam V350019555_L03_B5GHUMqcnrRAABA-551.bam V350019555_L03_B5GHUMqcnrRAABA-552.bam V350019555_L03_B5GHUMqcnrRAABA-553.bam V350019555_L03_B5GHUMqcnrRAABA-554.bam V350019555_L03_B5GHUMqcnrRAABA-555.bam V350019555_L03_B5GHUMqcnrRAABA-556.bam
[W::bam_merge_core2] No @HD tag found.
[W::sam_read1] parse error at line 2
[bam_merge_core2] failed to read first record from V350019555_L03_B5GHUMqcnrRAABA-554.bam
(base) javier@iMac-de-JAVIER BWA %
Looks like you BAM files are missing headers. How were they generated? What shows up in the output of samtools view -H V350019555_L03_B5GHUMqcnrRAABA-554.bam | head -5 ?
Thank you very much for what you are telling me, but I have entered the previous command and it gives me this error
base) javier@iMac-de-JAVIER BWA % samtools merge -o merged.bam V350019555_L03_B5GHUMqcnrRAABA-549.bam
V350019555_L03_B5GHUMqcnrRAABA-550.bam
V350019555_L03_B5GHUMqcnrRAABA-551.bam
V350019555_L03_B5GHUMqcnrRAABA-552.bam
V350019555_L03_B5GHUMqcnrRAABA-543.bam
V350019555_L03_B5GHUMqcnrRAABA-554.bam
V350019555_L03_B5GHUMqcnrRAABA-555.bam
V350019555_L03_B5GHUMqcnrRAABA-556.bam
samtools: invalid option -- o
Usage: samtools merge [-nurlf] [-h inh.sam] [-b <bamlist.fofn>] <out.bam> <in1.bam> [<in2.bam> ... <inN.bam>]
Options:
-n Input files are sorted by read name
-r Attach RG tag (inferred from file names)
-u Uncompressed BAM output
-f Overwrite the output BAM if exist
-1 Compress level 1
-l INT Compression level, from 0 to 9 [-1]
-R STR Merge file in the specified region STR [all]
-h FILE Copy the header in FILE to <out.bam> [in1.bam]
-c Combine @RG headers with colliding IDs [alter IDs to be distinct]
-p Combine @PG headers with colliding IDs [alter IDs to be distinct]
-s VALUE Override random seed
-b FILE List of input BAM filenames, one per line [null]
-@, --threads INT
Number of BAM/CRAM compression threads [0]
--input-fmt-option OPT[=VAL]
Specify a single input file format option in the form
of OPTION or OPTION=VALUE
-O, --output-fmt FORMAT[,OPT[=VAL]]...
Specify output format (SAM, BAM, CRAM)
--output-fmt-option OPT[=VAL]
Specify a single output file format option in the form
of OPTION or OPTION=VALUE
--reference FILE
Reference sequence FASTA FILE [null]
zsh: command not found: V350019555_L03_B5GHUMqcnrRAABA-550.bam
zsh: command not found: V350019555_L03_B5GHUMqcnrRAABA-551.bam
zsh: command not found: V350019555_L03_B5GHUMqcnrRAABA-552.bam
zsh: command not found: V350019555_L03_B5GHUMqcnrRAABA-543.bam
zsh: command not found: V350019555_L03_B5GHUMqcnrRAABA-554.bam
zsh: command not found: V350019555_L03_B5GHUMqcnrRAABA-555.bam
zsh: command not found: V350019555_L03_B5GHUMqcnrRAABA-556.bam
(base) javier@iMac-de-JAVIER BWA %
A current version of samtools has the -o option for merge. BAM files to be merged should be on the same command line one after the other like in usage statement below.
Since you appear to be confused about the samtools versions (I responded to you on SeqAnswers) I will also post this here. Samtools versions went incrementally after the first decimal: 1.1,1.2,1.3 .... 1.10,1.11 .. on to current version 1.14.
You seem to be copy-pasting from a list of BAM files where files are one-per-line (i.e. separated by new-lines), which is why zsh: command not found errors are being thrown.
Ensure your BAM files are separated by spaces. Try this once you have the latest version of samtools:
t does not reject the files, but it gives me this error, the version is samtools 1,3.1
(base) javier@iMac-de-JAVIER BWA % samtools merge -o merged.bam V350019555_L03_B5GHUMqcnrRAABA-549.bam V350019555_L03_B5GHUMqcnrRAABA-550.bam V350019555_L03_B5GHUMqcnrRAABA-551.bam V350019555_L03_B5GHUMqcnrRAAB(base) javier@iMac-de-JAVIER BWA % samtools merge -o merged.bam V350019555_L03_B5GHUMqcnrRAABA-549.bam V350019555_L03_B5GHUMqcnrRAABA-550.bam V350019555_L03_B5GHUMqcnrR(base) javier@iMac-de-JAVIER BWA % samtools merge -o merged.bam V350019555_L03_B5GHUMqcnrRAABA-549.bam V350019555_L03_B5GHUMqcnrRAABA-550.(base) javier@iMac-de-JAVIER BWA % samtools merge -o merged.bam V350019555_L03_B5GHUMqcnrRAABA-549.bam V350019555_L03_B5GHUMqcnrRAABA-550.bam V350019555_L03_B5GHUMqcnrRAABA-551.bam V350019555_L03_B5GHUMqcnrRAABA-552.bam V350019555_L03_B5GHUMqcnrRAABA-553.bam V350019555_L03_B5GHUMqcnrRAABA-554.bam V350019555_L03_B5GHUMqcnrRAABA-555.bam V350019555_L03_B5GHUMqcnrRAABA-556.bam
samtools: invalid option -- o
Usage: samtools merge [-nurlf] [-h inh.sam] [-b <bamlist.fofn>] <out.bam> <in1.bam> [<in2.bam> ... <inN.bam>]
Options:
-n Input files are sorted by read name
-r Attach RG tag (inferred from file names)
-u Uncompressed BAM output
-f Overwrite the output BAM if exist
-1 Compress level 1
-l INT Compression level, from 0 to 9 [-1]
-R STR Merge file in the specified region STR [all]
-h FILE Copy the header in FILE to <out.bam> [in1.bam]
-c Combine @RG headers with colliding IDs [alter IDs to be distinct]
-p Combine @PG headers with colliding IDs [alter IDs to be distinct]
-s VALUE Override random seed
-b FILE List of input BAM filenames, one per line [null]
-@, --threads INT
Number of BAM/CRAM compression threads [0]
--input-fmt-option OPT[=VAL]
Specify a single input file format option in the form
of OPTION or OPTION=VALUE
-O, --output-fmt FORMAT[,OPT[=VAL]]...
Specify output format (SAM, BAM, CRAM)
--output-fmt-option OPT[=VAL]
Specify a single output file format option in the form
of OPTION or OPTION=VALUE
--reference FILE
Reference sequence FASTA FILE [null]
Program: samtools (Tools for alignments in the SAM format)
Version: 1.3.1 (using htslib 1.3.1)
Stop copy-pasting and type out the entire command including the filenames very carefully ensuring you don't have typos. If that doesn't work, please contact a linux pro near you and direct them to this thread. We can no longer help you.
https://meta.stackexchange.com/questions/147616
This is the route I use
and the error is this
Looks like you have not indexed your BAM files. Are they co-ordinated sorted? If not you should do that first. If you have
samtools
installed you can use that or useigvtools
included in IGV. You can also usesamtools merge
to merge the BAM files. See help page here.Yes, I'm doing what you tell me, but I'm wrong with the syntax
Thank you
It should be
merge
notmergue
.This may be language related but the command is
samtools merge
notmergue
.When you get the files merged, you will want to
samtools sort --write-index -o sorted.bam merged.bam
to get final merged/sorted/indexed file. Final file can then be visualized using IGV.I am doing this but it gives me this error.
Will the files be fine or is it a problem with the syntax?
Looks like you BAM files are missing headers. How were they generated? What shows up in the output of
samtools view -H V350019555_L03_B5GHUMqcnrRAABA-554.bam | head -5
?I use
samtools view -bS file.sam> file.bam
I can turn them sam in a moment, back to bam
But what should I do? Why has this happened?
Did you SAM file have headers?
head -5 file.sam
I enter this and nothing appears
How did you generate the alignment files? All aligners should write headers in whichever first alignment file (SAM or BAM) that they produce.
I had two fastq files (read in a different direction), and through bwa, I made a sam file, but I understand well what you mean by ls headers
Always provide as much information as you can. Show us the bwa command you used.
I use this command, I think that this is good, but I don t where is the wrong
I AM USING THIS SYNTAX TO JOIN FILES BAM But EXIST WRONG, COULD SOMEONE INDICATE THE CORRECT SYNTAx
Correct syntax is
You may simply be able to do following in one step to get a sorted/indexed final file. Last
-
at end of command is needed.You can add more threads to both commands (
-@ N
) depending on how many cores you have available to speed the process up.Thank you very much for what you are telling me, but I have entered the previous command and it gives me this error
A current version of
samtools
has the-o
option formerge
. BAM files to be merged should be on the same command line one after the other like in usage statement below.Which version are you using? Find out by doing following (example output from latest samtools)
Since you are using a mac make sure you turn off
smart quotes and dashes
in system preferences. If you are copying and pasting commands.Please use
ADD REPLY
when responding to existing comments to keep the thread logically organized.Since you appear to be confused about the samtools versions (I responded to you on SeqAnswers) I will also post this here. Samtools versions went incrementally after the first decimal: 1.1,1.2,1.3 .... 1.10,1.11 .. on to current version 1.14.
See: https://github.com/samtools/samtools/releases/