问题描述
我正在使用 stats.pearsonr 来查找 r 值,该值可用于计算数字的两个向量(列表)之间的相似性,例如基因表达值。 dic[gene[i]] 和 dic[gene[j]] 都是列表
dic[gene[j]] = ['145.544','135.24','56.5138','135.826','100.222','67.9036','71.9729','64.8282','98.5264','8.81885','74.5485','36.8456','165.306','137.346']
dic[gene[i]] =['157.156','431.292','401.941','243.974','196.058','8.54743','527.666','603.364','189.298','165.956','81.9865','214.528','511.015','431.634']
但是,即使列表包含浮点数,我似乎也无法运行代码
network = []
for i in range(len(gene)):
for j in range(i):
r,p = stats.pearsonr(dic[gene[i]],dic[gene[j]])
if r>0.99:
network.append([gene[i],gene[j]])
print(len(network))
这是我的错误
/usr/local/lib/python3.7/dist-packages/scipy/stats/stats.py in pearsonr(x,y)
3512 # that the data type is at least 64 bit floating point. It might have
3513 # more precision if the input is,for example,np.longdouble.
-> 3514 dtype = type(1.0 + x[0] + y[0])
3515
3516 if n == 2:
TypeError: unsupported operand type(s) for +: 'float' and 'numpy.str_'
知道怎么做吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)