Merge two BAM files with different but overlapping reference sequences?
1
0
Entering edit mode
7.6 years ago
dmathog ▴ 40

Situation:

refA.fasta   one reference sequence
refB.fasta   a different reference sequence
A.bam        one type of reads mapped against the first reference
B.bam        another type of reads mapped against the 2nd ref

Some time after these are constructed one discovers that the sequences in refA and refB overlap and can be merged to refC, with one or at most two cut and splice operations. For the sake of a specific example, let's say that refA is 10kb long, refB is 12kb long, and base 1 of refA is the same as base 1000 of refB, with refA in the opposite orientation (because it will be, half the time) and that there are no base changes in the shared region.

refC.fasta can be constructed with any number of tools.

How though, does one merge the bam files? It would seem to require the application of "invert" and "offset" operators to one of the bam files, and only then the use of the existing "merge". However neither "invert" nor "offset" seem to exist in samtools, notably, they are not in "view" which is where I would have put them.

Does some other piece of software have this option?

Assembly • 2.4k views
ADD COMMENT
3
Entering edit mode

You would be better off by 1) first get the fastq from individual bams, say A.fastq and B.fastq 2) merge and align these fastq to the new reference refC.fasta

ADD REPLY
5
Entering edit mode
7.6 years ago

The simplest solution, as Santosh Anand quite rightly pointed out, is to remap them to the same reference.

If you really don't want to do that, then I would recommend using CrossMap to convert the BAM file to the same coordinate system. If the conversion between the genomes is really as simple as you're saying then you could make the liftOver file by hand.

ADD COMMENT
0
Entering edit mode

CrossMap looks like it should do the trick. Thanks.

ADD REPLY
0
Entering edit mode

If this answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.

ADD REPLY

Login before adding your answer.

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