mergue bam itv
1
0
Entering edit mode
2.9 years ago
Javier • 0

I am trying to create a combined file b m, to enter all the readings, but it gives me an error when loading

In a Mac text editor, I enter the path of the three files, and save it with the extension bam.list

I introduce HARD DISK / NAME FILE / NAME ARCHIVE as path

What am I doing wrong?

morgue bam itv • 4.3k views
ADD COMMENT
1
Entering edit mode

but it gives me an error when loading

https://meta.stackexchange.com/questions/147616

ADD REPLY
0
Entering edit mode

This is the route I use

GENOMA/BWA/V350019555_L03_B5GHUMqcnrRAABA-549.bam


GENOMA/BWA/V350019555_L03_B5GHUMqcnrRAABA-550.bam


GENOMA/BWA/V350019555_L03_B5GHUMqcnrRAABA-551.bam

and the error is this

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
ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

Yes, I'm doing what you tell me, but I'm wrong with the syntax

(base) javier@iMac-de-JAVIER BWA % samtools mergue 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

[main] unrecognized command 'mergue'

Thank you

ADD REPLY
0
Entering edit mode

It should be merge not mergue.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

I am doing this but it gives me this error.

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 % 
ADD REPLY
0
Entering edit mode

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 ?

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

Did you SAM file have headers? head -5 file.sam

ADD REPLY
0
Entering edit mode

I enter this and nothing appears

(base) javier@iMac-de-JAVIER BWA % samtools view -H V350019555_L03_B5GHUMqcnrRAABA-554.bam | head -5
(base) javier@iMac-de-JAVIER BWA % samtools view -H V350019555_L03_B5GHUMqcnrRAABA-554.sam | head -5
(base) javier@iMac-de-JAVIER BWA % 
ADD REPLY
0
Entering edit mode

How did you generate the alignment files? All aligners should write headers in whichever first alignment file (SAM or BAM) that they produce.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Always provide as much information as you can. Show us the bwa command you used.

ADD REPLY
0
Entering edit mode

I use this command, I think that this is good, but I don t where is the wrong

bwa mem -t 8 -R "@RG\tID:XXXX\tSM:YYYY\tPL:Illumina\tLB:ZZZZ" GRCh38.primary_assembly.genome.fa.gz file_1.fastq.gz file_2.fastq.gz > file.sam
ADD REPLY
0
Entering edit mode

I AM USING THIS SYNTAX TO JOIN FILES BAM But EXIST WRONG, COULD SOMEONE INDICATE THE CORRECT SYNTAx

samtools merge 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
ADD REPLY
0
Entering edit mode

Correct syntax is

samtools merge -o merged.bam file1.bam file2.bam ... fileN.bam

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.

samtools merge file1.bam file2.bam ... fileN.bam | samtools sort --write-index -o sorted.bam -

You can add more threads to both commands (-@ N) depending on how many cores you have available to speed the process up.

ADD REPLY
0
Entering edit mode

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 %
ADD REPLY
0
Entering edit mode

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.

$ samtools merge
Usage: samtools merge [options] -o <out.bam> [options] <in1.bam> ... <inN.bam>
   or: samtools merge [options] <out.bam> <in1.bam> ... <inN.bam>

Which version are you using? Find out by doing following (example output from latest samtools)

$ samtools --version
samtools 1.14
Using htslib 1.14
Copyright (C) 2021 Genome Research Ltd.

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.

ADD REPLY
0
Entering edit mode

Please use ADD REPLY when responding to existing comments to keep the thread logically organized.

ADD REPLY
0
Entering edit mode

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/

ADD REPLY
0
Entering edit mode
2.9 years ago
Ram 44k

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:

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

See how everything is on the same line? Your command has multiple lines.

ADD COMMENT
0
Entering edit mode

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)
ADD REPLY
0
Entering edit mode

So you are using a pretty old version (v.1.3.1). For that old version you should remove -o from the command.

samtools merge 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

Current version of samtools is 1.14. If you can upgrade to latest samtools then use the example shown by @Ram.

ADD REPLY
0
Entering edit mode

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.

ADD REPLY

Login before adding your answer.

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