andersen-lab / Freyja

Depth-weighted De-Mixing
BSD 2-Clause "Simplified" License
100 stars 29 forks source link

freyja covariants KeyError #172

Closed djfeistel closed 11 months ago

djfeistel commented 11 months ago

I was still using V1.4.3 and when i used freyja covariants everything seemed to work except the heat map was slightly different. Now, Im using V1.4.5 and im getting this error when i use the following code:

freyja covariants sorted_.bam 22000 25000 --output sorted_bam.tsv --ref-genome NC_045512.2_reference.fasta

main error is here: Traceback (most recent call last): File "/scicomp/home-pure/ofx5/.conda/envs/freyja-1.4.5/bin/freyja", line 10, in sys.exit(cli()) File "/scicomp/home-pure/ofx5/.conda/envs/freyja-1.4.5/lib/python3.10/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/scicomp/home-pure/ofx5/.conda/envs/freyja-1.4.5/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/scicomp/home-pure/ofx5/.conda/envs/freyja-1.4.5/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/scicomp/home-pure/ofx5/.conda/envs/freyja-1.4.5/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/scicomp/home-pure/ofx5/.conda/envs/freyja-1.4.5/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(args, **kwargs) File "/scicomp/home-pure/ofx5/.conda/envs/freyja-1.4.5/lib/python3.10/site-packages/freyja/_cli.py", line 597, in covariants _covariants(input_bam, min_site, max_site, output, File "/scicomp/home-pure/ofx5/.conda/envs/freyja-1.4.5/lib/python3.10/site-packages/freyja/read_analysis_tools.py", line 708, in covariants df['Max_count'] = [co_muts_max_reads[k] for k in co_muts] File "/scicomp/home-pure/ofx5/.conda/envs/freyja-1.4.5/lib/python3.10/site-packages/freyja/read_analysis_tools.py", line 708, in df['Max_count'] = [co_muts_max_reads[k] for k in co_muts] KeyError: 'G21941T G21987A (21990,3) T22032C C22033A A22034G A22194T'

Any advice?

update: i changed the min and max to 200 and 10000 and i was able to generate an output file. Not sure if this helps

dylanpilz commented 11 months ago

Hey,

We're aware of this issue and will include a fix in the next Freyja release. It has to to do with co_muts_max_reads missing some of the keys present in co_muts (usually just one or two). It seems by changing the min and max params you were able to avoid the cluster that resulted in the KeyError.

-Dylan

djfeistel commented 11 months ago

ok great to hear! thanks

djfeistel commented 11 months ago

If i can add too, when i generate the covariants plot, i do not get a log scale heatmap, i only get a legend with alternate, reference and no coverage (thus the plot i generate is different from the one on the main github page). there is not level of intensity in color, its either red, gray or white. I will not that i am working with in silico data i generate for some test, but i have create the data set with 5 different yet closely related GISAD sequences at varying proportions.

wutron commented 11 months ago

Try #164, which should include the missing keys (rather than dropping them in #176).