Thanks all, the problem is solved. it appears that the warning message is not related to the bam header and the header is there already.
Hi everyone, I hope you are all great, I'm trying to convert my sam files into bam using the below command
samtools view -h -b -o file.bam file.sam
it worked fine but the output file has no header. I also tried to add the header using the two steps below
samtools view -H file.bam > header.sam # extract header only
samtools reheader header.sam file.unique.bam
but the file still has no header.
ps: when I run samtools view -h file.bam
the output has a header, however, I'm getting an error message with each command that requires the header to be in the bam file.
(for example, running bedintersect:
bedtools intersect -s -header -a file.bam -b file.bed > file2.bam
I got the error message below
WARNING: -header option is not valid for BAM input)
any advice, please? your help is much appreciated. Surar
and
Then the bam file does have a header, samtools cannot just make one up. It could just be that
bedtools interact -header
option does not work with bam files.