MicrobialDarkMatter / nanomotif

Nanomotif - a tool for identifying methylated motifs in metagenomic samples
MIT License
23 stars 1 forks source link

ComputeError in motif discovery #77

Open Ge0rges opened 1 month ago

Ge0rges commented 1 month ago

Hello,

I wanted to report this error when running motif discovery.

Traceback (most recent call last):
  File "/Accounts/gkanaan/miniconda3/nanomotif/bin/nanomotif", line 8, in <module>
    sys.exit(main())
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/main.py", line 563, in main
    motif_discovery(args)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/main.py", line 361, in motif_discovery
    bin_consensus(args, pileup=pileup, assembly=assembly, motifs=motifs, motifs_scored=scored_all)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/main.py", line 315, in bin_consensus
    output = nm.bin_consensus.within_bin_motifs_consensus(pileup.pileup, assembly, motifs, motifs_scored, bins)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/bin_consensus.py", line 49, in within_bin_motifs_consensus
    bin_motifs = contig_motifs.groupby("bin", "motif", "mod_position", "mod_type") \
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/polars/dataframe/frame.py", line 8054, in with_columns
    return self.lazy().with_columns(*exprs, **named_exprs).collect(_eager=True)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/polars/lazyframe/frame.py", line 1810, in collect
    return wrap_df(ldf.collect())
polars.exceptions.ComputeError: ComputeError: The output type of the 'apply' function cannot be determined.
The function was never called because 'skip_nulls=True' and all values are null.
Consider setting 'skip_nulls=False' or setting the 'return_dtype'.
SorenHeidelbach commented 1 month ago

Can you provide the freeze of the enviroment you are using (pip freeze or conda list if using conda)? And possibly the output in motif.tsv in the nanomotif output folder?

Thank you!

Ge0rges commented 1 month ago

Sure here they are. conda_list.txt motifs.txt pip_freeze.txt

Ge0rges commented 4 weeks ago

Setting return,dtype=pl.String fixes this, I then run into:

Traceback (most recent call last):
  File "/Accounts/gkanaan/miniconda3/nanomotif/bin/nanomotif", line 8, in <module>
    sys.exit(main())
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/main.py", line 563, in main
    motif_discovery(args)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/main.py", line 360, in motif_discovery
    bin_consensus(args, pileup=pileup, assembly=assembly, motifs=motifs, motifs_scored=scored_all)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/main.py", line 315, in bin_consensus
    output = nm.bin_consensus.merge_bin_motifs(output, bins, pileup, assembly)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/bin_consensus.py", line 119, in merge_bin_motifs
    return new_bin_motifs

Because the bin_motifs dataframe was empty. Fixed by assigning new_bin_motifs = bin_motifs outside the loop.

Then again a similar error:

Traceback (most recent call last):
  File "/Accounts/gkanaan/miniconda3/nanomotif/bin/nanomotif", line 8, in <module>
    sys.exit(main())
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/main.py", line 563, in main
    motif_discovery(args)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/main.py", line 360, in motif_discovery
    bin_consensus(args, pileup=pileup, assembly=assembly, motifs=motifs, motifs_scored=scored_all)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/main.py", line 319, in bin_consensus
    output = nm.postprocess.join_motif_complements(output)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/nanomotif/postprocess.py", line 132, in join_motif_complements
    motif_df = motif_df.with_columns([
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/polars/dataframe/frame.py", line 8054, in with_columns
    return self.lazy().with_columns(*exprs, **named_exprs).collect(_eager=True)
  File "/Accounts/gkanaan/miniconda3/nanomotif/lib/python3.9/site-packages/polars/lazyframe/frame.py", line 1810, in collect
    return wrap_df(ldf.collect())
polars.exceptions.ComputeError: ComputeError: The output type of the 'apply' function cannot be determined.
The function was never called because 'skip_nulls=True' and all values are null.
Consider setting 'skip_nulls=False' or setting the 'return_dtype'.

I specified the return_dtype=pl.String, and the program completed.