Is there an API that I can use to accomplish the task to renaming the sample in the header?
Merging Bam Files
3 answers
Try this command on bam file where you want to change the sample name. Oldname is the present sample name and the Newname is the correct sample name. Once done with this step then you can use Picard MergeSam to merge your files. This command is similar to Pierre but is a single step process.
samtools view -H $BAM | sed "s/SM:Oldname/SM:Newname/" | samtools reheader - $BAM
• 56 views
•
link
I would dump the header
samtools view -H the1.bam > header.txt
edit the header and change the sample in the header for each group-id
and re-insert the header:
samtools reheader header.txt the1.bam
and then merge the1.bam and the2.bam with picard MergeSamFiles
• 0 views
•
link
• 0 views
•
link
just use awk ?
• 0 views
•
link
Use picard tools AddOrReplaceReadGroups
• 0 views
•
link
I attempted that. It replaces all the headers with a single header. I only want to map the sample to a constant sample.
• 0 views
•
link
Log in to answer this question.