Feature request: the inverse of `norm --atomize`

Open
#1,724 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
c

Research direction

Start by reproducing the behavior with the supplied bug.ref.fa and bug.vcf using bcftools norm -f. Review the norm command's atomization and normalization behavior, then determine how the inverse operation should represent the three distinct alleles. Done means the reproduction preserves those allele-specific deletions without producing the unexpected GCTC -> G result.

Written by the indexing model from the issue text.

Description

enhancement

I found normalization will give incorrect result in this case:

                    1
                    |
 a1                 ACGCTCCTCC TCCAGA
 a2                 -------*** ------
 a3                 ---*------ ------
 a4                 ---*---*** ------
sh-5.0# bcftools view bug.vcf
...
#CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT  a1      a2      a3      a4
a1      7       .       CTCC    C       .       .       .       GT      0       1       0       1
a1      3       .       GC      G       .       .       .       GT      0       0       1       1

In this case, TCC is the repeat element right after a deletion GC -> G.
The normalization algorithm will left-align the deletion TCC in position 8-10 to position 5-7 and merge(?) the indel in position 4 at the same time.

VCF

sh-5.0# bcftools norm bug.vcf -f bug.ref.fa
...
##bcftools_normVersion=1.13+htslib-1.13
##bcftools_normCommand=norm -f bug.ref.fa bug.vcf; Date=Fri May 27 08:29:27 2022
#CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT  a1      a2      a3      a4
a1      3       .       GCTC    G       .       .       .       GT      0       1       0       1
a1      3       .       GC      G       .       .       .       GT      0       0       1       1
Lines   total/split/realigned/skipped:  2/0/1/0

However, I don't why, the result become GCTC -> G, which is not a TCC deletion nor CTCC deletion either.

I think this is the multi-allelic case GCTCC -> {G, GC, GTCC} which I would possibly expected like so:

#CHROM  POS     ID      REF     ALT        QUAL    FILTER  INFO    FORMAT  a1      a2      a3      a4
a1      3       .       GCTCC    G         .       .       .       GT      0       0       0       1
a1      3       .       GCTCC    GC        .       .       .       GT      0       1       0       0
a1      3       .       GCTCC    GTCC      .       .       .       GT      0       0       1       0

Reproduce

Fasta

root@5d7310b4d3a0:/app# cat bug.ref.fa
>a1
ACGCTCCTCCTCCAGA

VCF

sh-5.0# bcftools view bug.vcf
##fileformat=VCFv4.1
##FILTER=<ID=PASS,Description="All filters passed">
##fileDate=20220527
##contig=<ID=a1,length=16>
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##bcftools_viewVersion=1.13+htslib-1.13
##bcftools_viewCommand=view bug.vcf; Date=Fri May 27 08:28:17 2022
#CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT  a1      a2      a3      a4
a1      7       .       CTCC    C       .       .       .       GT      0       1       0       1
a1      3       .       GC      G       .       .       .       GT      0       0       1       1

I ran the bcftools in docker with the latest image
quay.io/biocontainers/bcftools:1.13--h3a49de5_0

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.