jzhoulab / orca

sequence-based prediction of multiscale genome structure from kilobase to whole-chromosome scale
Other
70 stars 21 forks source link

orca_predict 'NoneType' object is not iterable #8

Closed Devalock closed 7 months ago

Devalock commented 7 months ago

Hi Dr. Zhou,

Thanks for your efforts on this user-friendly tool.

However, when I tried to run the examples by using python, I met some problems.

I've configured orca environment as instructed, and then tried to do predition:

import orca_predict 
orca_predict.load_resources(models=['32M', '256M'])
from orca_predict import *
outputs = process_region('chr9', 110404000, 111404000, hg38, window_radius=16000000, file='./chr17_110404000_111404000')

And then I got a warning and a error:

/root/miniconda3/envs/orca_env/lib/python3.9/site-packages/cooltools/lib/numutils.py:1376: RuntimeWarning: invalid value encountered in divide
  val_cur = ar_cur / armask_cur

TypeError                                 Traceback (most recent call last)
Cell In[22], line 1
----> 1 outputs = process_region('chr9', 110404000, 111404000, hg38, window_radius=16000000, file='./chr17_110404000_111404000')

File /mnt/e/WSL/orca/orca_predict.py:1157, in process_region(mchr, mstart, mend, genome, file, custom_models, target, show_genes, show_tracks, window_radius, padding_chr, model_labels, use_cuda)
   1153         genomeplot_256Mb(
   1154             outputs_ref, show_coordinates=True, model_labels=model_labels, file=file + ".256m.pdf",
   1155         )
   1156     else:
-> 1157         genomeplot(
   1158             outputs_ref,
   1159             show_genes=show_genes,
   1160             show_tracks=show_tracks,
   1161             show_coordinates=True,
   1162             model_labels=model_labels,
   1163             file=file + ".pdf",
   1164         )
   1165 return outputs_ref

File /mnt/e/WSL/orca/orca_utils.py:160, in genomeplot(output, show_genes, show_tracks, show_coordinates, unscaled, file, cmap, unscaled_cmap, colorbar, maskpred, vmin, vmax, model_labels)
    158 if output["experiments"] is not None:
    159     current_axis = 0
--> 160     for label in model_labels:
    161         for suffix in [" Pred", " Obs"]:
    162             all_axes[current_axis, 0].set_ylabel(
    163                 label + suffix,
    164                 labelpad=20,
   (...)
    169                 va="center",
    170             )

TypeError: 'NoneType' object is not iterable

Firstly I thought it might caused by specific cooltools version. Results above are based on cooltools 0.5.4. Then I updated cooltools to newest version (0.6.1), the same error occured with different warnings:

/root/miniconda3/envs/orca_env/lib/python3.9/site-packages/cooltools/lib/numutils.py:1376: RuntimeWarning: invalid value encountered in divide
  val_cur = ar_cur / armask_cur
/root/miniconda3/envs/orca_env/lib/python3.9/site-packages/cooltools/lib/numutils.py:1376: RuntimeWarning: invalid value encountered in divide
  val_cur = ar_cur / armask_cur
/root/miniconda3/envs/orca_env/lib/python3.9/site-packages/torch/utils/checkpoint.py:429: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/mnt/e/WSL/orca/orca_predict.py:406: RuntimeWarning: Mean of empty slice
  np.nanmean(
/mnt/e/WSL/orca/orca_predict.py:405: RuntimeWarning: Mean of empty slice
  target_r = np.nanmean(

Then I noticed the error is correlated with model_labels, which seems cannot be set as None? So I tried to set model_lables = ["test"] and this time it worked.

Anyway, the differences in packages versions still could lead to various problems. So could you please specifiy the package versions in config files?

Thank you!