Question: Using Gatk, Removing Read Contigs On Bam Level
1
gravatar for Mdeng
7.8 years ago by
Mdeng520
Germany
Mdeng520 wrote:

Hey everyone,

ATM I am working with GATK for the first time and a get an error, wich everybody knows:

##### ERROR MESSAGE: Input files reads and reference have incompatible contigs: Order of contigs differences, which is unsafe.
##### ERROR   reads contigs = [chr1, chr2, ..., chrUn_gl000226, chr18_gl000207_random]
##### ERROR   reference contigs = [chr1, chr2, ..., chrY, chrM]

Is there a way to remove the chr18_gl000207_random on the BAM level, I don't wanna go back to SAM level and kick them out. Because if already done some postprocessing now.

With best,

Mario

gatk contigs snp • 4.8k views
ADD COMMENTlink modified 3.5 years ago by Biostar ♦♦ 20 • written 7.8 years ago by Mdeng520

What if you change the reference sequence instead of the alignment?

ADD REPLYlink written 7.8 years ago by lh331k

This would work to, but I am looking for nice and fast why, Istvan Albert posted below.

ADD REPLYlink written 7.7 years ago by Mdeng520
3
gravatar for Istvan Albert
7.8 years ago by
Istvan Albert ♦♦ 80k
University Park, USA
Istvan Albert ♦♦ 80k wrote:

You could list all the valid chromosomes as a query like so:

samtools view  -b old.bam chr1 chr2 chr3 > newbam

(old.bam file needs to be sorted and indexed)

ADD COMMENTlink written 7.8 years ago by Istvan Albert ♦♦ 80k

I guess this does not work because the sequence dictionary is not changed. I think GATK should adopt the faidx strategy.

ADD REPLYlink written 7.8 years ago by lh331k

@lh3 Couldn't this be solved by recreating the SAM header using Picards AddOrReplaceReadGroups?

ADD REPLYlink written 7.7 years ago by Mdeng520

Do you mean ReplaceSamHeader?

ADD REPLYlink written 7.7 years ago by Russh1.2k
1
gravatar for Russh
7.8 years ago by
Russh1.2k
U. Liverpool
Russh1.2k wrote:

I don't quite follow why you don't want to go back to SAM level. Surely making a temporary SAM, grepping that, and converting to BAM is the easiest way to do this, isn't it?

The alternative, is to use picard's ReorderSam tool, which, given that the offending contigs are absent from your reference, will drop any reads that are mapped to those contigs

ADD COMMENTlink written 7.8 years ago by Russh1.2k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1760 users visited in the last hour