TypeError: Neighbors.compute_neighbors() got an unexpected keyword argument 'write_knn_indices'
報(bào)錯(cuò)命令:
scv.pp.moments(adata)
參考了github上的信息:
Neighbors.compute_neighbors() got an unexpected keyword argument 'write_knn_indices' · Issue #1212 · theislab/scvelo
解決辦法:

將上面代碼改為:
scv.pp.moments(adata, n_neighbors=None, n_pcs=None)
最好的方法還是安裝scvelo的development版本,開發(fā)者團(tuán)隊(duì)已經(jīng)修復(fù)了這個(gè)bug
而且將參數(shù)改為n_neighbors=None, n_pcs=None后雖然不報(bào)錯(cuò),但結(jié)果相差很大。
git clone https://github.com/theislab/scvelo
cd scvelo
pip install .
這里安裝的時(shí)候按照官網(wǎng)教程會(huì)報(bào)下面的錯(cuò)誤,所以直接用pip install就行了
git checkout --track origin/main
fatal: A branch named 'main' already exists.
或者使用下面的命令,我沒試過好不好用
pip install git+https://github.com/theislab/scvelo@main
ValueError: mismatching number of index arrays for shape; got 0, expected 2
報(bào)錯(cuò)命令:
scv.tl.paga(adata, groups='cell_type')
解決辦法:
修改源代碼!
問題來了,怎么知道源代碼在哪兒呢?
需要找到 scvelo 庫的安裝位置,代碼如下:
python -c "import scvelo; print(scvelo.__file__)"
通常長(zhǎng)這個(gè)樣子:/path/to/your/python/site-packages/scvelo/init.py
scv.tl.paga 函數(shù)的實(shí)現(xiàn)通常在 scvelo/tools 目錄下,文件名是 paga.py。
進(jìn)入該目錄并找到 paga.py 文件,把下面的代碼
if len(edges) > 0:
return csr_matrix((weights, zip(*edges)), shape=shape)
改成下面這樣子:
rows, cols = zip(*edges)
if len(edges) > 0:
return csr_matrix((weights, (rows, cols)), shape=shape)
當(dāng)然,github上也有人用別的方法,比如:
I install scipy==1.11.4 to avoid the self._check() error, and solve this problem.