rvalieris / LCS

9 stars 4 forks source link

Error in rule decompose #16

Closed Gagi1993 closed 1 year ago

Gagi1993 commented 1 year ago

hello , i am trying to check ww sample with your program but i'm stuck here. I was wondering if You can help

warning: dropping 22 markers because they are not present on the pools using 261 markers to estimate 20 variant groups Traceback (most recent call last): File "/home/mikra/LCS/scripts/vg-decompose.py", line 185, in main() File "/home/mikra/LCS/scripts/vg-decompose.py", line 182, in main solve_samples(markers_df, pools, marker_snps_list, tags, pool_tags) File "/home/mikra/LCS/scripts/vg-decompose.py", line 140, in solve_samples print("\t".join([ s, prob.status, str(result), str(prob.solver_stats.solve_time), str(len(vs))]), file=status) TypeError: sequence item 0: expected str instance, numpy.int64 found [Mon Apr 10 15:24:23 2023] Error in rule decompose: jobid: 1 input: outputs/variants_table/pango-markers-table.tsv, outputs/variants_table/pool_samples_data/tags_pool_mypool.tsv output: outputs/decompose/data/tags_pool_mypool.status, outputs/decompose/data/tags_pool_mypool.out shell: python scripts/vg-decompose.py -m outputs/variants_table/pango-markers-table.tsv -p outputs/variants_table/pool_samples_data/tags_pool_mypool.tsv -o outputs/decompose/data/tags_pool_mypool.out -s outputs/decompose/data/tags_pool_mypool.status --threads 8 (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

Removing output files of failed job decompose since they might be corrupted: outputs/decompose/data/tags_pool_mypool.status, outputs/decompose/data/tags_pool_mypool.out Shutting down, this might take some time. Exiting because a job execution failed. Look above for error message

rvalieris commented 1 year ago

hello, are your sample names numbers by any chance ?

print("\t".join([ s, prob.status, str(result), str(prob.solver_stats.solve_time), str(len(vs))]), file=status)
TypeError: sequence item 0: expected str instance, numpy.int64 found

if so, this patch on the scripts/vg-decompose.py file could fix the issue:

diff --git a/scripts/vg-decompose.py b/scripts/vg-decompose.py
--- a/scripts/vg-decompose.py
+++ b/scripts/vg-decompose.py
@@ -159,7 +159,7 @@ def main():

        # pool data
        pools = pandas.read_csv(args.pools, sep='\t')
-       pool_tags = sorted(pools['sample'].unique())
+       pool_tags = sorted(map(str, pools['sample'].unique()))
        pools['mut'] = pools.apply(lambda r: str(r['pos'])+":"+r['ref']+">"+r["alt"], axis=1)
        pools['af'] = pools['adalt']/pools['dp']

@@ -169,7 +169,7 @@ def main():
        if len(zero_cov_samples) > 0:
                print('warning: dropping samples with zero coverage: '+str(zero_cov_samples))
                pools = pools[ ~( pools['sample'].isin(zero_cov_samples) ) ]
-               pool_tags = sorted(pools['sample'].unique())
+               pool_tags = sorted(map(str, pools['sample'].unique()))

        # check missing muts
        missing_muts = set(marker_snps_list) - set(pools.mut)
Gagi1993 commented 1 year ago

Yes they were. I renamed them to string and the program run perfectly. Thank you a lot for Your fast response and help !

rvalieris commented 1 year ago

no problem !, I updated the code to add this patch.