bcftools mpileup does not use the correct chromosome when using multiple BAM files which have a different chromosome

Open
#1,412 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
c

Research direction

Start by reproducing the issue with the provided bcftools mpileup command using BAM files whose chromosome orders differ, then inspect the mpileup entry point and the handling of chromosome IDs. Compare whole-file and -r chrM runs. Done means reads are associated with the correct chromosome for every BAM file without the reported out-of-range skips.

Written by the indexing model from the issue text.

Description

D3: Easy P2: Desirable

bcftools mpileup does not use the correct chromosome when using multiple BAM files which have a different chromosome order.

# List of BAM files with BAM files with 2 differn chromosome orders:
#   - chr1 chr2 chr3 chr4 chr5 chr6 chr7 chr8 chr9 chr10 chr11 chr12 chr13 chr14 chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22 chrX chrY chrM
#   - chrM chr1 chr2 chr3 chr4 chr5 chr6 chr7 chr8 chr9 chr10 chr11 chr12 chr13 chr14 chr15 chr16 chr17 chr18 chr19 chr20 chr21 chr22 chrX chrY
bam_filenames=*.bam

bcftools mpileup \
    --threads 30 \
    --output-type u \
    --fasta-ref "${fasta_filename}" \
    --max-depth 8000 \
    --skip-indels \
    ${bam_filenames} \
  | bcftools call \
        --threads 4 \
        --multiallelic-caller \
        --variants-only \
        --skip-variants indels \
        --output-type b \
        --output test.bcf

stderr

[mpileup] 30 samples in 30 input files
[mpileup] maximum number of reads per input file set to -d 8000
[mplp_func] Skipping because 17426 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17442 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17449 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17464 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17464 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17464 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17469 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17473 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17486 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17493 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17503 is outside of 16571 [ref:0]
[mplp_func] Skipping because 17532 is outside of 16571 [ref:0]
[mplp_func] Skipping because 19206 is outside of 16571 [ref:0]
...

I also tried with a specific region like: chrM

bcftools mpileup \
    -r chrM \
    --output-type v \
    --fasta-ref "${fasta_filename}" \
    --max-depth 8000 \
    --skip-indels \
    ${bam_filenames} 
[mpileup] maximum number of reads per input file set to -d 8000
[mplp_func] Skipping because 2756366 is outside of 16571 [ref:24]
[mplp_func] Skipping because 2781409 is outside of 16571 [ref:24]
[mplp_func] Skipping because 2804105 is outside of 16571 [ref:24]
[mplp_func] Skipping because 2806176 is outside of 16571 [ref:24]
[mplp_func] Skipping because 2819751 is outside of 16571 [ref:24]
[mplp_func] Skipping because 3490449 is outside of 16571 [ref:24]
[mplp_func] Skipping because 3550603 is outside of 16571 [ref:24]
[mplp_func] Skipping because 3863042 is outside of 16571 [ref:24]
[mplp_func] Skipping because 3903940 is outside of 16571 [ref:24]
[mplp_func] Skipping because 3903941 is outside of 16571 [ref:24]
[mplp_func] Skipping because 3903945 is outside of 16571 [ref:24]
[mplp_func] Skipping because 3903951 is outside of 16571 [ref:24]
[mplp_func] Skipping because 3931577 is outside of 16571 [ref:24]

So I think bcftools mpileup needs to have a per BAM file chromosome name to tid mapping, so it get the data from the correct chromosome for each BAM file.

Dominant language
C
Stars
891
Forks
277
Avg merge
2d 23h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from samtools/bcftools

All issues in samtools/bcftools

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.