cellchat分析时,cellchat netEmbedding 运行出错解决方案

运行cellchat <- netEmbedding(cellchat,type = “functional”) 报错如下: 

Error in runUMAP(Similarity, min.dist = 0.3, n.neighbors = k) : Cannot find UMAP, please install through pip (e.g. pip install umap-learn or reticulate::py_install(packages = 'umap-learn')).

因为没有安装umap实现,按提示在终端使用pip install umap-learn,直接运行后报错还是一样,因为你没有指定R使用的python版本:

重启Rstudio后:

library(reticulate)
use_python('/usr/bin/python3',required = T) #指定安装umap-learn那个版本的python位置
py_version() #看看是不是指定正确

最后运行后报错:

>cellchat <- netEmbedding(cellchat, type = "functional") 
 Manifold learning of the signaling networks for a single dataset 
/Users/yangl/Library/Python/3.8/lib/python/site-packages/umap/umap_.py:132: UserWarning: A large number of your vertices were disconnected from the manifold. 
Disconnection_distance = 1 has removed 142 edges. 
It has fully disconnected 3 vertices. You might consider using find_disconnected_points() to find and remove these points from your data. 
Use umap.utils.disconnected_vertices() to identify them. 
warn(

或者直接通过运行:reticulate::py_install(packages = ‘umap-learn’)。但也依然报错:

>cellchat <- netEmbedding(cellchat, type = "functional")
Manifold learning of the signaling networks for a single dataset 
C:\Users\zzu\AppData\Local\R-MINI~1\envs\R-RETI~1\lib\site-packages\umap\umap_.py:133: UserWarning: A large number of your vertices were disconnected from the manifold.
Disconnection_distance = 1 has removed 142 edges.
It has fully disconnected 3 vertices.
You might consider using find_disconnected_points() to find and remove these points from your data.
Use umap.utils.disconnected_vertices() to identify them.
f"A large number of your vertices were disconnected from the manifold.\n"

通过google搜索find_disconnected_points(),GitHub issue中有人提问并得到解决方法:https://github.com/sqjin/CellChat/issues/167(即 source(file = ‘CellChat_issue167_netClusteringFix.R’) #使用外部导入修改的函数),但依然报错如旧。

最后我通过查看GitHub issue中所有与netEmbedding函数相关的issue,最终找到了解决办法:https://github.com/sqjin/CellChat/issues/196 (换个umap算法实现,结果也会有些许差异)

install.packages("uwot")
library(uwot)
cellchat <- netEmbedding(cellchat, umap.method = 'uwot',type = "functional") #调用uwot实现umap, 程序自带,只需使用参数umap.method = 'uwot',无需修改对应的netEmbedding函数源码

本文引用自:cellchat netEmbedding 运行出错-Bluesky's blog (yangl.net)icon-default.png?t=M276http://yangl.net/2021/09/09/cellchat-netembedding-error/

  • 11
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值