andersen-lab / ivar

iVar is a computational package that contains functions broadly useful for viral amplicon-based sequencing.
https://andersen-lab.github.io/ivar/html/
GNU General Public License v3.0
115 stars 39 forks source link

Header format error in ivar filtervariants #171

Open fshepherd13 opened 7 months ago

fshepherd13 commented 7 months ago

Describe the bug ivar filtervariants produces header format warning in version 1.4 that is not reproducible in older versions of ivar.

To Reproduce Steps to reproduce the behavior:

#Version 1.3.1
module load mamba
mamba create -n ivar_1.3.1 -c bioconda ivar==1.3.1
conda activate ivar_1.3.1

samtools mpileup -A -d 0 -Q 0 sample_a.bam | ivar variants -p test_a -t 0.03 -r AJ30_5_2_SI_MKV1_WG.fa -g AJ30_5_2_SI_MKV1_WG.gff
samtools mpileup -A -d 0 -Q 0 sample_b.bam | ivar variants -p test_b -t 0.03 -r AJ30_5_2_SI_MKV1_WG.fa -g AJ30_5_2_SI_MKV1_WG.gff

ivar filtervariants -p test.filtered test_a.tsv test_b.tsv

head test.filtered.tsv 
REGION  POS     REF     ALT     GFF_FEATURE     REF_CODON       REF_AA  ALT_CODON       ALT_AA  REF_DP_test_a.tsv       REF_RV_test_a.tsv       REF_QUAL_test_a.tsv     ALT_DP_test_a.tsv   ALT_RV_test_a.tsv        ALT_QUAL_test_a.tsv     ALT_FREQ_test_a.tsv     TOTAL_DP_test_a.tsv     PVAL_test_a.tsv PASS_test_a.tsv REF_DP_test_b.tsv       REF_RV_test_b.tsv       REF_QUAL_test_b.tsv  ALT_DP_test_b.tsv       ALT_RV_test_b.tsv       ALT_QUAL_test_b.tsv     ALT_FREQ_test_b.tsv     TOTAL_DP_test_b.tsv     PVAL_test_b.tsv PASS_test_b.tsv
Consensus_AJ30_5_2_SI_MKV1_WG_threshold_0_quality_30    1029    C       T               CTC     L       CTT     L       1528    1       37      2810    6       37      0.647764        43380TRUE    2856    5       37      4708    2       37      0.622422        7564    0       TRUE
Consensus_AJ30_5_2_SI_MKV1_WG_threshold_0_quality_30    1032    A       T               GTA     V       GTT     V       1528    1       37      2810    6       37      0.647764        43380TRUE    2858    5       37      4705    2       37      0.622025        7564    0       TRUE
Consensus_AJ30_5_2_SI_MKV1_WG_threshold_0_quality_30    1113    G       A               AAG     K       AAA     K       1460    1       37      2670    3       37      0.646489        41300TRUE    2677    2       37      4428    2       37      0.623135        7106    0       TRUE
Consensus_AJ30_5_2_SI_MKV1_WG_threshold_0_quality_30    1126    C       T               CTG     L       TTG     L       1532    143     39      2728    166     40      0.640376        42600TRUE    2860    278     40      4585    293     41      0.61585 7445    0       TRUE

This works as expected (this is the version I had been using last).

But if I upgrade to the latest version:

#Version 1.4.2
mamba create -n ivar_1.4.2
conda activate ivar_1.4.2
mamba install ivar==1.4.2 -c defaults -c bioconda -c conda-forge

samtools mpileup -A -d 0 -Q 0 sample_a.bam | ivar variants -p test_a -t 0.03 -r AJ30_5_2_SI_MKV1_WG.fa -g AJ30_5_2_SI_MKV1_WG.gff
samtools mpileup -A -d 0 -Q 0 sample_b.bam | ivar variants -p test_b -t 0.03 -r AJ30_5_2_SI_MKV1_WG.fa -g AJ30_5_2_SI_MKV1_WG.gff
ivar filtervariants -p test.filtered test_a.tsv test_b.tsv

An error reads:

Header format of test_a.tsv did not match! Please use files generated using "ivar variants" command.
Header format of test_b.tsv did not match! Please use files generated using "ivar variants" command.

The resulting filtered tsv file is empty.

I attached sample bam files and reference files to reproduce the issue. Am I missing something obvious here? Thanks in advance! sample_files.zip

cmaceves commented 7 months ago

hi @fshepherd13! thank you for bringing this up and providing the sample data, I'll look into ti!