COMBINE-lab / simpleaf

A rust framework to make using alevin-fry even simpler
BSD 3-Clause "New" or "Revised" License
45 stars 3 forks source link

numpy has no attribute long #91

Closed thisisamirv closed 1 year ago

thisisamirv commented 1 year ago

Hi, when I run simpleaf index i get the following error

2023-05-26T14:34:54.738764Z ERROR simpleaf::utils::prog_utils: command unsuccessful (exit status: 1): "/Users/amirvalizadeh/miniconda3/envs/simpleaf/bin/pyroe" "make-splici" "ref_dir/fasta/genome.fa" "ref_dir/genes/genes.gtf" "90" "simpleaf_index/ref"
2023-05-26T14:34:54.739356Z ERROR simpleaf::utils::prog_utils: stderr :
====
Traceback (most recent call last):
  File "/Users/amirvalizadeh/miniconda3/envs/simpleaf/bin/pyroe", line 259, in <module>
    make_splici_txome(
  File "/Users/amirvalizadeh/miniconda3/envs/simpleaf/lib/python3.10/site-packages/pyroe/make_txome.py", line 638, in make_splici_txome
    introns = gr.features.introns(by="transcript")
  File "/Users/amirvalizadeh/miniconda3/envs/simpleaf/lib/python3.10/site-packages/pyranges/genomicfeatures.py", line 250, in introns
    exons = exons.merge(by=id_column)
  File "/Users/amirvalizadeh/miniconda3/envs/simpleaf/lib/python3.10/site-packages/pyranges/pyranges.py", line 3015, in merge
    df = pyrange_apply_single(_merge_by, self, **kwargs)
  File "/Users/amirvalizadeh/miniconda3/envs/simpleaf/lib/python3.10/site-packages/pyranges/multithreaded.py", line 348, in pyrange_apply_single
    result = call_f_single(function, nparams, df, **kwargs)
  File "/Users/amirvalizadeh/miniconda3/envs/simpleaf/lib/python3.10/site-packages/pyranges/multithreaded.py", line 31, in call_f_single
    return f.remote(df, **kwargs)
  File "/Users/amirvalizadeh/miniconda3/envs/simpleaf/lib/python3.10/site-packages/pyranges/methods/merge.py", line 71, in _merge_by
    ids, starts, ends, number = merge_by(cdf.Start.values, cdf.End.values, cdf.ClusterBy.values, slack)
  File "sorted_nearest/src/merge_by.pyx", line 9, in sorted_nearest.src.merge_by.merge_by
  File "/Users/amirvalizadeh/miniconda3/envs/simpleaf/lib/python3.10/site-packages/numpy/__init__.py", line 320, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'long'
====
Error: pyroe failed to return succesfully ExitStatus(unix_wait_status(256))
rob-p commented 1 year ago

Hi @thisisamirv,

Thanks for reporting this. Can you say what version of simpleaf you are using, and what version of pyroe is installed? Recently, the pyranges package upon which pyroe relies made a breaking update. We fixed this by pinning the required pyranges version in the conda recipe, but you'll have to ensure you have the latest version of pyroe for that change to be reflected. cc @DongzeHE.

Best, Rob

thisisamirv commented 1 year ago

Thanks for the response. I have pyroe 0.9.2 and simpleaf 0.13.0 and pyranges 0.0.120

rob-p commented 1 year ago

Thanks. Could you also let us know your numpy and pandas versions? It may be necessary to pin them within the conda env.

thisisamirv commented 1 year ago

numpy is 1.24.3 and pandas is 1.5.3

rob-p commented 1 year ago

Hi @thisisamirv,

This seems to be the underlying pyranges issue (https://github.com/pyranges/pyranges/issues/258).

One thought would be to ensure you have the latest sorted_nearest:

conda install sorted_nearest=0.39

Alternatively, if that doesn't work, perhaps you could try to force numpy 1.23:

conda install numpy=1.23

we are working on dropping the pyranges dependency to hopefully avoid such issues in the future.

Best, Rob

thisisamirv commented 1 year ago

Thanks it fixed the issue.

wmacnair commented 1 year ago

Hi, I had this same problem. Perhaps the issue should be reopened until it is fixed?

I had the following versions:

numpy 1.24.3
pandas == 1.5.3
pyranges 0.0.120
pyroe 0.9.2
simpleaf 0.13.0

conda install sorted_nearest=0.39 didn't work for me, but conda install numpy=1.23 did. Well, it worked in the sense of getting a new error message... 😅

I now get:

Error: The construction of a piscem index was requested, but a valid piscem executable was not available.
Please either set a path using the `set-paths` command, or ensure the `PISCEM` environment variable is set properly.

If I do simpleaf set-paths, I get:

2023-06-01T10:45:16.086852Z  INFO simpleaf::utils::prog_utils: could not find piscem executable, so salmon will be required.
found `salmon` in the PATH at /home/macnairw/scratch/conda/envs/af/bin/salmon
found `alevin-fry` in the PATH at /home/macnairw/scratch/conda/envs/af/bin/alevin-fry
found `pyroe` in the PATH at /home/macnairw/scratch/conda/envs/af/bin/pyroe

Is piscem installed by default along with simpleaf?

Thanks! Will

(Also, as an aside, is there a reason to require python 3.10 rather than python 3.11? Do you have to wait for some dependencies to be updated?)

wmacnair commented 1 year ago

It seems like the default installation of simpleaf includes alevin-fry, pyroe and salmon as dependencies, but not piscem. But then the tutorial recommends --use-piscem. Or am I missing something?

rob-p commented 1 year ago

cc @DongzeHE.

@wmacnair : That's correct. The reason for this is that bioconda does not currently allow for builds on Apple silicon (and piscem doesn't work under rosetta 2). Therefore, we recommend to install piscem separately; either via conda if you are on x86, or directly from the github release if you are on apple silicon.

rob-p commented 1 year ago

P.S. Thanks to @DongzeHE's herculean effort, we are very close to completely replacing pyranges with a fully rust solution of our own construction. At that point, the perpetual pyrange-induced issues should go away.

wmacnair commented 1 year ago

Turns out that my problem was missing the piscem package off the end of my conda install ... call... 🤦‍♂️ Apologies for the confusion!

One other v small comment / Q. In the simpleaf tutorial (here) you specify --rlen 91, while in the sc-best-practices page (here), which seems to be based on your tutorial, they specify -r 90.

Does this matter? Perhaps not, and I guess the other one is not directly your page, but would be good to make things consistent :)

Will

rob-p commented 1 year ago

Hi Will,

Thanks for the feedback. No, the -r should have almost no effect (we did a sensitivity analysis in the alevin-fry paper). I agree we should aim to make these as uniform as possible unless there are reasons the parameters should be different (cc @DongzeHE).

Best, Rob

wmacnair commented 1 year ago

Ok, good to know. Perhaps an easy fix would be to add a comment in the tutorial / documentation mentioning exactly this - that -r has very little effect, and users shouldn't worry about it :)

Thanks Will