alexcritschristoph / soil_popgen

Reproducible scripts and notebooks for 2019 paper on population genetics in metagenomes
GNU General Public License v3.0
14 stars 0 forks source link

KeyError: 'fst' #6

Closed neel404 closed 2 years ago

neel404 commented 2 years ago

Hi Alex,

I am getting KeyError: 'fst' when I run fst.py. Any help would be greatly appreciated.

python fst.py -g bin187_ref_gene.fa -o test bin187 bin89 loading bin187 loading bin89 Calling new SNVs...: 100%|█████████████████████████████████████████████████████████████████| 3524/3524 [00:06<00:00, 544.77it/s] Notice: 11% of genes were incomplete and snps in these genes were marked I. Pi is not calculated for incomplete genes. calculating fst: 100%|████████████████████████████████████████████████████████████████████| 3149/3149 [00:02<00:00, 1375.92it/s] Traceback (most recent call last): File "/cm/shared/apps/soil_popgen/python3/0.0.1/conda/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3361, in get_loc return self._engine.get_loc(casted_key) File "pandas/_libs/index.pyx", line 76, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/index.pyx", line 108, in pandas._libs.index.IndexEngine.get_loc File "pandas/_libs/hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas/_libs/hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'fst'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/cm/shared/apps/soil_popgen/python3/soil_popgen/inStrain_lite/inStrain_lite/fst.py", line 159, in main(args) File "/cm/shared/apps/soil_popgen/python3/soil_popgen/inStrain_lite/inStrain_lite/fst.py", line 141, in main print(np.mean(FstTable['fst'])) File "/cm/shared/apps/soil_popgen/python3/0.0.1/conda/lib/python3.9/site-packages/pandas/core/frame.py", line 3455, in getitem indexer = self.columns.get_loc(key) File "/cm/shared/apps/soil_popgen/python3/0.0.1/conda/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3363, in get_loc raise KeyError(key) from err KeyError: 'fst'

alexcritschristoph commented 2 years ago

Hello, You might get that error if your Fst table was empty. This could be because there were no SNPs called, because the genomes compared are highly clonal, or low coverage in one or both samples. Try it on a few different sample -genome pairs to test. You'll probably want to dive into the python for this script yourself as well. In the future we hope to support Fst in the actual inStrain package but this is probably months away. Thanks! Alex