Adding CB tag to bam file
1
0
Entering edit mode
4 weeks ago
Maria • 0

Hello,

I need to add CB tags to my bam files. Below is what I'm doing. I see the tags when I pipe to stdout but the tag is not written to the new bam. What is it that I'm missing? Thanks!

# $LINE is the path to the  original input bam, there is one bam for each $cell
samtools view -h -b -o ${cell}.bam ${LINE} | sed -e "/^@/! s/$/ CB:Z:${cell}/"
# or
samtools view -h -b ${LINE} | sed -e "/^@/! s/$/ CB:Z:${cell}/" > ${cell}.bam
# or
samtools view -h ${LINE} | sed -e "/^@/! s/$/ CB:Z:${cell}/" | samtools view -hb -o {cell}.bam -
samtools bam • 967 views
ADD COMMENT
1
Entering edit mode
ADD REPLY
0
Entering edit mode
4 weeks ago

Shouldn't you use PicardTools for this?

ADD COMMENT
0
Entering edit mode

I checked Picard AddOrReplaceReadsGroups and AddOATag. Is that what you're referring to?

ADD REPLY
0
Entering edit mode

Yes. Why wouldn't you use, say, AddOrReplaceReadsGroups?

ADD REPLY
0
Entering edit mode

Sorry for the delay in my answer, I got sidetracked. I am using samtools addreplacerg -r "@RG\tID:$cell" -o $cell.bam -h $LINE but I just don't see how I go from RG to CB. I need the CB tag as that is what vartrix is picking Thanks!

ADD REPLY
0
Entering edit mode

I think both these programs are just adding the same tag to every line. I don't think either cares whether it's called RG or CB

ADD REPLY
0
Entering edit mode

When I try samtools addreplacerg -r "@CB\tID:$cell" -o $cell.bam $LINE the CB tag gets add to the header, but the tag in every line gets reversed to RG (I'm attaching a screenshot of the output I get). Is there anything I'm missing?

enter image description here

ADD REPLY
0
Entering edit mode

samtools addreplacerg is for read groups. This is not what OP asked.

ADD REPLY

Login before adding your answer.

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