Question: filter reads in BAM having a tag
0
gravatar for aebmad
7 weeks ago by
aebmad30
United States
aebmad30 wrote:

Anyone has a simple solution for filtering reads in a BAM/SAM file having a certain TAG? This came up trying to filter out reads from 10x without a proper CB tag defined (which is causing troubles in downstream analysis tools).

I'm surprised there is no built-in command in samtools for doing this (I opened an issue here). There is the -d TAG:VALUE argument to filter in reads having a specific tag value, but no command to simply filter reads having the tag TAG. I will keep grep-ing my way for the time being, but I wonder if I'm missing a more robust and still simple solution.

samtools alignment • 146 views
ADD COMMENTlink modified 7 weeks ago by jkbonfield470 • written 7 weeks ago by aebmad30
1
gravatar for aebmad
7 weeks ago by
aebmad30
United States
aebmad30 wrote:

It turns out the samtools dev team was already working on this feature, which will be available in the next release (in the meantime it can be used pulling the develop branch). samtools view -d TAG does the trick.

ADD COMMENTlink modified 7 weeks ago • written 7 weeks ago by aebmad30
1
gravatar for jkbonfield
7 weeks ago by
jkbonfield470
jkbonfield470 wrote:

The samtools view -d TAG in.bam option will fix this for the next release. More generally we are also working on a generic filtering expression language which includes the same capability. Eg `samtools view -e '[SA] && rlen>qlen' would report reads only having an SA tag and where the size of the reference sequence is larger than the query length (so has more deletions than insertions/clips).

Meanwhile, sambamba and samsift both offer this functionality too.

ADD COMMENTlink written 7 weeks ago by jkbonfield470

Thanks for mentioning sambamba and samsift, I will take a look.

ADD REPLYlink written 7 weeks ago by aebmad30
0
gravatar for Pierre Lindenbaum
7 weeks ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum133k wrote:

using samjdk see another example here: Filter bam, EXCLUDING specific tagged reads

ADD COMMENTlink written 7 weeks ago by Pierre Lindenbaum133k
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: 1680 users visited in the last hour
_