brentp / vcfanno

annotate a VCF with other VCFs/BEDs/tabixed files
https://genomebiology.biomedcentral.com/articles/10.1186/s13059-016-0973-5
MIT License
365 stars 56 forks source link

error using AF calc example #31

Closed dwaggott closed 8 years ago

dwaggott commented 8 years ago

If you have encountered an error, please include:

[[postannotation]]
fields=[AC, AN]
op=lua:AC / AN
name=AF
type=Float

QUERY

tmp.vcf

COMMAND

$ vcfanno add_af.toml tmp.vcf > tmp_af.vcf

ERROR

=============================================
vcfanno version 0.0.11-beta [built with devel +5ec87ba Thu Apr 28 15:36:34 2016 +0000]

see: https://github.com/brentp/vcfanno
=============================================
panic: Near line 2 (last key parsed 'postannotation.fields'): Expected value but found 'A' instead.

goroutine 1 [running]:
panic(0x7bee60, 0xc820015d00)
        /usr/local/src/go-git/src/runtime/panic.go:500 +0x18c
main.main()
        /usr/local/src/gocode/src/github.com/brentp/vcfanno/vcfanno.go:81 +0x17f5
brentp commented 8 years ago

Just looking quickly on my phone but looks like you need to quote AC. and AN. and op= and Float etc

On Jul 19, 2016 4:18 PM, "Daryl Waggott" notifications@github.com wrote:

If you have encountered an error, please include:

minimal conf and lua files that you are using. urls or actual files for annotations in conf file. minimal query file. the command you used to invoke vcfanno the full error message CONF

[[postannotation]] fields=[AC, AN] op=lua:AC / AN name=AF type=Float

QUERY

tmp.vcf

COMMAND

$ vcfanno add_af.toml tmp.vcf > tmp_af.vcf

ERROR

============================================= vcfanno version 0.0.11-beta [built with devel +5ec87ba Thu Apr 28 15:36:34 2016 +0000] see: https://github.com/brentp/vcfanno ============================================= panic: Near line 2 (last key parsed 'postannotation.fields'): Expected value but found 'A' instead. goroutine 1 [running]: panic(0x7bee60, 0xc820015d00) /usr/local/src/go-git/src/runtime/panic.go:500 +0x18c main.main() /usr/local/src/gocode/src/github.com/brentp/vcfanno/vcfanno.go:81 +0x17f5

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

dwaggott commented 8 years ago

Right, that worked, they got lost in an echo

Next error: vcfanno.go:102: ERROR: requested lua op without specifying -lua flag

I tried both:

op="lua:AC / AN"

and

op="lua:function AC / AN"

brentp commented 8 years ago

should be op="lua: AC / AN"

but you have to specify -lua on the command-line, e.g

echo "" > empty.lua
vcfanno -lua emtpy.lua add_af.toml tmp.vcf 

I should ease up that check, but that's how to get around it for now.

dwaggott commented 8 years ago

Nice, next...

repeats

api.go:442: lua error in postannotation AF <string>:1: cannot perform div operation between table and number
stack traceback:
        <string>:1: in main chunk
        [G]: ?
api.go:442: lua error in postannotation AF <string>:1: cannot perform div operation between table and number
stack traceback:
        <string>:1: in main chunk
        [G]: ?
api.go:442: lua error in postannotation AF <string>:1: cannot perform div operation between table and number
stack traceback:
        <string>:1: in main chunk
        [G]: ?

header

##INFO=<ID=AC,Number=A,Type=Integer,Description="Allele count in genotypes, for each ALT allele">
##INFO=<ID=AN,Number=1,Type=Integer,Description="Total number of alleles in called genotypes">
dwaggott commented 8 years ago

Oh, I see it's because AC has NUMBER=A. Hmm, I should have run vt / bcftools norm on these so it shouldn't be the case.

brentp commented 8 years ago

So, thats when you have multiple alternate alleles so you get 2 values for AC. if you want to ignore the possibility of multiple alts, you can do:

op="lua: AC[1] / AN"

but you may want to just do:

[[postannotation]]
fields=["AC"]
op="max"
name="AC_max"
type="Float"

[[postannotation]]
fields=["AC_max", "AN"]
op="lua:AC_max / AN"
# op="div2"
name="AF"
type="Float"

also note that there is a builtin op "div2" that will be faster than using lua

brentp commented 8 years ago

yeah, you can also use vt decompose.

dwaggott commented 8 years ago

Excellent!

To summarize... a few requested features (a) relax the check for a lua file when not required (b) add an error check message when computing with arrays (c) flush out the doc a bit on subscripted arrays.

brentp commented 8 years ago

remember, after you decompose, you'll still need AC[1] or just use op="div2"