Question: How to change SM tag in bam file
0
gravatar for ddzhangzz
9 months ago by
ddzhangzz90
United States
ddzhangzz90 wrote:

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 • 822 views
ADD COMMENTlink modified 9 months ago by ATpoint15k • written 9 months ago by ddzhangzz90
1
gravatar for ATpoint
9 months ago by
ATpoint15k
Germany
ATpoint15k wrote:

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 COMMENTlink modified 9 months ago • written 9 months ago by ATpoint15k
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: 911 users visited in the last hour