Skip to content

fasta file in polarize command #6

Description

@smallfishcui

Hi Andrew,

I would like to add Ancestral allele info to my vcf file, so I would be able to get the derived allele for my site frequency spectrum. I was running a command:
python /homeappl/home/cuiwang/.local/bin/vcfdo polarize -i SNP_NOmissing_withOG.recode.vcf.gz -f SNP_NOmissing_withOG.recode.min4.fasta -n 10
INFO:vcfutils:Task: polarize
INFO:polarize:Connecting to VCF file <SNP_NOmissing_withOG.recode.vcf.gz>
INFO:polarize:Ancestral genome: <Y56.Nomissing.snps.fasta>
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##fileDate=20190605
##source="Stacks v2.3e"
##INFO=<ID=AD,Number=R,Type=Integer,Description="Total Depth for Each Allele">
##INFO=<ID=AF,Number=A,Type=Float,Description="Allele Frequency">
##INFO=<ID=DP,Number=1,Type=Integer,Description="Total Depth">
##INFO=<ID=NS,Number=1,Type=Integer,Description="Number of Samples With Data">
##FORMAT=<ID=AD,Number=R,Type=Integer,Description="Allele Depth">
##FORMAT=<ID=DP,Number=1,Type=Integer,Description="Read Depth">
##FORMAT=<ID=HQ,Number=2,Type=Integer,Description="Haplotype Quality">
##FORMAT=<ID=GL,Number=G,Type=Float,Description="Genotype Likelihood">
##FORMAT=<ID=GQ,Number=1,Type=Integer,Description="Genotype Quality">
##FORMAT=<ID=GT,Number=1,Type=String,Description="Genotype">
##INFO=<ID=loc_strand,Number=1,Type=Character,Description="Genomic strand the corresponding Stacks locus aligns on">
##contig=<ID=36240>
##contig=<ID=36608>
##contig=<ID=36676>
##contig=<ID=38047>
##contig=<ID=42142>
##contig=<ID=55999>
##contig=<ID=57521>
##contig=<ID=59460>
##contig=<ID=68348>
##contig=<ID=77537>
##contig=<ID=78266>
##contig=<ID=79842>
##contig=<ID=88637>
##contig=<ID=91051>
##contig=<ID=101109>
##contig=<ID=109425>
##contig=<ID=109947>
##contig=<ID=133565>
##contig=<ID=145117>
##contig=<ID=150642>
##contig=<ID=152613>
##contig=<ID=176997>
##contig=<ID=180466>
##contig=<ID=180823>
##contig=<ID=187069>
##contig=<ID=192399>
##contig=<ID=194525>
##contig=<ID=205540>
##contig=<ID=207712>
##contig=<ID=221630>
##contig=<ID=226714>
##contig=<ID=231824>
##contig=<ID=245655>
##contig=<ID=251295>
##contig=<ID=279854>
##contig=<ID=280550>
##contig=<ID=290678>
##contig=<ID=299392>
##contig=<ID=313458>
##contig=<ID=331289>
##contig=<ID=342201>
##contig=<ID=353296>
##contig=<ID=358991>
##contig=<ID=370919>
##contig=<ID=379970>
##contig=<ID=387164>
##contig=<ID=401049>
##contig=<ID=413420>
##contig=<ID=419404>
##contig=<ID=427387>
##contig=<ID=430678>
##contig=<ID=430954>
##contig=<ID=431130>
##contig=<ID=443976>
##contig=<ID=446500>
##contig=<ID=452581>
##contig=<ID=456380>
##contig=<ID=459837>
##contig=<ID=466950>
##contig=<ID=2326531>
##vcfdo_command=polarize -i SNP_NOmissing_withOG.recode.vcf.gz -f Y56.Nomissing.snps.fasta -n 10; pwd=/wrk/cuiwang/DONOTREMOVE/Phrag_RAD/denovo/ustacks/M4m4/popu_K6; timestamp=2019-10-16 03:29:11
##INFO=<ID=AA,Number=1,Type=String,Description="Ancestral allele inferred from outgroup">
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Y1 Y3 Y4 Y6 Y7 Y9 Y10 Y11 Y12 Y13 Y14 Y15 Y16 Y17_1 Y18 Y19 Y20 Y21 Y22 Y23 Y24 Y25 Y26 Y27 Y28 Y30 Y31 Y32 Y33 Y34 Y35 Y36 Y37 Y38 Y39 Y40 Y41 Y43 Y44 Y45 Y46 Y47 Y48 Y49 Y51_1 Y53 Y55 Y56 Y57
However I get a error message:
INFO:polarize:Processing VCF file ...
Traceback (most recent call last):
File "/homeappl/home/cuiwang/.local/lib/python3.6/site-packages/pyfaidx/init.py", line 1014, in getitem
return self.records[rname]
KeyError: '36240'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/homeappl/home/cuiwang/.local/bin/vcfdo", line 2152, in
args.func(vcf = vcf, **vars(args))
File "/homeappl/home/cuiwang/.local/bin/vcfdo", line 810, in polarize_anc_vs_der
og = str(genome[site.CHROM][start:end])
File "/homeappl/home/cuiwang/.local/lib/python3.6/site-packages/pyfaidx/init.py", line 1016, in getitem
raise KeyError("{0} not in {1}.".format(rname, self.filename))
KeyError: '36240 not in Y56.Nomissing.snps.fasta.'

I set the fasta file to be the outgroup sequence, and 36240 was a name of a cotig, why the package is complaining the contig is not in the fasta file? Could you please give a hint how should I format the fasta file here?

Thanks,
Cui

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions