How to change SM tag in bam file
1
0
Entering edit mode
5.7 years ago
ddzhangzz ▴ 90

I have a bam file with header such like this:

@RG ID:S1-L001  LB:L001 PL:Illumina SM:L001 PU:novaSeq
@RG ID:S1-L002  LB:L002 PL:Illumina SM:L002 PU:novaSeq

This bam file was generated by picard MergeSamFiles where one sample library was sequenced in two lanes (L001, L002) but I need to correct the SM tag to a single library name such like:

@RG ID:S1-L001  LB:L001 PL:Illumina SM:S1   PU:novaSeq
@RG ID:S1-L002  LB:L002 PL:Illumina SM:S1   PU:novaSeq

What I tried

samtools view -H abc.bam > header.sam

and manually edit the SM tages in header.sam and reheader using samtools:

samtools reheader header.sam abc.bam

But the terminal printed out unrecogniziable characters and I thought something went wrong. Any suggestions?

next-gen • 6.1k views
ADD COMMENT
1
Entering edit mode
5.7 years ago
ATpoint 81k

reheader produces a new bam file with the altered header. In your command, it is send to stdout, and as bam is a compressed/non human-readable format, it looks weird on screen.

samtools reheader header.sam abc.bam > abc_reheadered.bam
ADD COMMENT

Login before adding your answer.

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