記錄運(yùn)行scvelo過程中的報(bào)錯(cuò)

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.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容