<p>The main issue here is that your bam files have different chromosome labels. (i.e. 1,2,3 vs. chr1,chr2,chr3) as you mentioned.</p>

<p>This suggests that the data was mapped to a slightly different version of the reference genome. As a first layer, you might want to double check that these reference chromosomes are cross compatible (e.g. both correspond to hg19 for instance). To find more information on the reference genome used, you can check the header information using "samtools view -H "</p>

<p>Assuming that the reference genomes are cross compatible, you can try converting it to sam, adding the missing "chr" label in a pipe, and converting it back to a bam file. However, this will also require modification of the header file which can be challenging in itself.</p>

<p>The easiest (and more rigorous) approach is probably just to convert the batch of bam files with the wrong chromosome labels back into fastq files. You will then want to remap them using the exact same reference genome as the other batch of bam files. After which, you should be able to perform variant calling on the combined batch of bam files.</p>

CC BY-SA 4.0
2020-04-23T15:00:25.727Z
To add to this very correct answer, here are a couple of documentation articles that explain the key points in greater detail: https://gatk.broadinstitute.org/hc/en-us/articles/360035891071-Reference-genome and 
https://gatk.broadinstitute.org/hc/en-us/articles/360035531652-FASTA-Reference-genome-format
Geraldine_VdAuwera
CC BY-SA 4.0
2020-04-22T23:24:52.333Z
2020-04-22T23:24:52.333Z
KT8
<p>I am not familiar with getting variants from bam files, so I will just answer the second part. From the error message, it seems that it is necessary to have consistent chromosome labels across datasets. It is also a good idea to do so because this keeps your datasets consistent and makes things a lot easier. To change the chromosomes labels, you can write your own scripts (I use Python, for example). You can also find several solutions on BioStars (<a href="https://www.biostars.org/p/98582/" rel="nofollow noreferrer">https://www.biostars.org/p/98582/</a>).</p>

CC BY-SA 4.0
2020-04-23T16:00:46.460Z
Editing BAMs or VCFs to change chromosome names is really dangerous if you're not 100% sure you know what you're doing. I've seen scripts that screwed up the file contents in subtle enough ways to mess up downstream analyses. Even if you avoid that, you can end up combining data aligned to different genome reference builds, which also ends up affecting analysis results. It's much safer to realign from scratch like KT8 describes.
Geraldine_VdAuwera
CC BY-SA 4.0
2020-03-23T22:54:14.047Z
2020-03-23T22:54:14.047Z
Phoenix Mu
<p>I have two resources of .bam files. One is generated by our lab (1 sample = 1 bam). One is downloaded online (again 1 sample = 1 bam). For the downloaded samples the chromosomes are labelled: chr1, chr2, chr3 etc For our lab samples, the chromosomes are labelled: 1, 2, 3 etc. I want to generate a single VCF file of variants across all samples.</p>

<p>I'm using bcftools:</p>

<pre><code>bcftools mpileup -Ov -f ref.fasta -b samples.txt | bcftools call -mv -o bamMge.vcf
</code></pre>

<p>However, I get no calls and the repeated error: <strong>[E::faidx_adjust_position] The sequence "1" was not found</strong></p>

<p>I have two questions:</p>

<ol>
<li><p>Is my strategy correct (i.e. bcftools mpileup)? Do I need to incorporate extra steps (NB I also have matching gVCF files)</p></li>
<li><p>How can I either (i) alter the chromosome labeling of one of the subsets of bam files, or, (ii) use a mapping file to match chromosome labels during the mpileup run?</p></li>
</ol>

<p>Thanks</p>

<vcf><ngs><mpileup><bcftools>
Generate VCF from different .bam files with different chromosome names
# Generate VCF from different .bam files with different chromosome names

(Asked by: username_0 on 2020-03-23)

I have two resources of .bam files. One is generated by our lab (1 sample = 1 bam). One is downloaded online (again 1 sample = 1 bam). For the downloaded samples the chromosomes are labelled: chr1, chr2, chr3 etc For our lab samples, the chromosomes are labelled: 1, 2, 3 etc. I want to generate a single VCF file of variants across all samples.
I'm using bcftools:
bcftools mpileup -Ov -f ref.fasta -b samples.txt | bcftools call -mv -o bamMge.vcf

However, I get no calls and the repeated error: [E::faidx_adjust_position] The sequence "1" was not found
I have two questions:

Is my strategy correct (i.e. bcftools mpileup)? Do I need to incorporate extra steps (NB I also have matching gVCF files)
How can I either (i) alter the chromosome labeling of one of the subsets of bam files, or, (ii) use a mapping file to match chromosome labels during the mpileup run?

Thanks

**Tags:** vcf, ngs, mpileup, bcftools

---

## 2 answers

### Answer by username_1 on 2020-04-22. Score: 3

The main issue here is that your bam files have different chromosome labels. (i.e. 1,2,3 vs. chr1,chr2,chr3) as you mentioned.

This suggests that the data was mapped to a slightly different version of the reference genome. As a first layer, you might want to double check that these reference chromosomes are cross compatible (e.g. both correspond to hg19 for instance). To find more information on the reference genome used, you can check the header information using "samtools view -H "

Assuming that the reference genomes are cross compatible, you can try converting it to sam, adding the missing "chr" label in a pipe, and converting it back to a bam file. However, this will also require modification of the header file which can be challenging in itself.

The easiest (and more rigorous) approach is probably just to convert the batch of bam files with the wrong chromosome labels back into fastq files. You will then want to remap them using the exact same reference genome as the other batch of bam files. After which, you should be able to perform variant calling on the combined batch of bam files.

> **Comments:**
> **username_2**: To add to this very correct answer, here are a couple of documentation articles that explain the key points in greater detail: https://gatk.broadinstitute.org/hc/en-us/articles/360035891071-Reference-genome and  https://gatk.broadinstitute.org/hc/en-us/articles/360035531652-FASTA-Reference-genome-format  

---

### Answer by username_3 on 2020-03-23. Score: 1

I am not familiar with getting variants from bam files, so I will just answer the second part. From the error message, it seems that it is necessary to have consistent chromosome labels across datasets. It is also a good idea to do so because this keeps your datasets consistent and makes things a lot easier. To change the chromosomes labels, you can write your own scripts (I use Python, for example). You can also find several solutions on BioStars (<https://www.biostars.org/p/98582/>).

> **Comments:**
> **username_2**: Editing BAMs or VCFs to change chromosome names is really dangerous if you're not 100% sure you know what you're doing. I've seen scripts that screwed up the file contents in subtle enough ways to mess up downstream analyses. Even if you avoid that, you can end up combining data aligned to different genome reference builds, which also ends up affecting analysis results. It's much safer to realign from scratch like KT8 describes.  

---

