theislab / scib

Benchmarking analysis of data integration tools
MIT License
311 stars 63 forks source link

FileNotFoundError when running ilisi metric #375

Closed katelynxli closed 1 year ago

katelynxli commented 1 year ago

Hello!

I am trying to run the ilisi_graph() function in scib.metrics with the following code

ilisi_output_RSS = scib.metrics.ilisi_graph(adata_int, batch_key ="dataset", type_="embed", use_rep='X_emb', verbose=False)

However, I am encountering this FileNotFoundError

FileNotFoundError                         Traceback (most recent call last)
Cell In[14], line 2
      1 ## trying to run it on just ilisi: https://scib.readthedocs.io/en/latest/api/scib.metrics.ilisi_graph.html
----> 2 ilisi_output_RSS = scib.metrics.ilisi_graph(adata_int, batch_key ="dataset", type_="embed", use_rep='X_emb', verbose=False)

File ~/mambaforge/envs/scib/lib/python3.9/site-packages/scib/metrics/lisi.py:100, in ilisi_graph(adata, batch_key, type_, use_rep, k0, subsample, scale, n_cores, verbose)
     97 check_batch(batch_key, adata.obs)
     99 adata_tmp = recompute_knn(adata, type_, use_rep)
--> 100 ilisi_score = lisi_graph_py(
    101     adata=adata_tmp,
    102     obs_key=batch_key,
    103     n_neighbors=k0,
    104     perplexity=None,
    105     subsample=subsample,
    106     n_cores=n_cores,
    107     verbose=verbose,
    108 )
    110 # iLISI: nbatches good, 1 bad
    111 ilisi = np.nanmedian(ilisi_score)

File ~/mambaforge/envs/scib/lib/python3.9/site-packages/scib/metrics/lisi.py:331, in lisi_graph_py(adata, obs_key, n_neighbors, perplexity, subsample, n_cores, verbose)
    328     simpson_estimate_batch = np.concatenate(results)
    330 else:
--> 331     simpson_estimate_batch = compute_simpson_index_graph(
    332         file_prefix=prefix,
    333         batch_labels=batch,
    334         n_batches=n_batches,
    335         perplexity=perplexity,
    336         n_neighbors=n_neighbors,
    337     )
    339 tmpdir.cleanup()
    341 return 1 / simpson_estimate_batch

File ~/mambaforge/envs/scib/lib/python3.9/site-packages/scib/metrics/lisi.py:445, in compute_simpson_index_graph(file_prefix, batch_labels, n_batches, n_neighbors, perplexity, chunk_no, tol)
    442 logU = np.log(perplexity)
    444 # check if the target file is not empty
--> 445 if os.stat(index_file).st_size == 0:
    446     print("File has no entries. Doing nothing.")
    447     lists = np.zeros(0)

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/lisi_dtw1bowg/graph_lisi_indices_0.txt'

I updated my scib version to the github version, but the error persists still. Could you please advise? Thank you in advance!

mumichae commented 1 year ago

Duplicate of #333, #308

mumichae commented 1 year ago

It reinstalling scib via git doesn't work, try setting the LD_LIBRARY_PATH variable

export LD_LIBRARY_PATH=$HOME/<path-to-conda-installation>/lib
katelynxli commented 1 year ago

Solved by navigating to the scib/knn_graph directory on my system and manually recompiling the knn_graph.o file.

g++ -std=c++11 -O3 knn_graph.cpp -o knn_graph.o