Skip to content

Commit

Permalink
Update graph_construct.py
Browse files Browse the repository at this point in the history
  • Loading branch information
xingzhongyu committed Nov 5, 2023
1 parent 46459b8 commit 2a2283c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion dance/transforms/graph_construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import sklearn
import torch
from dgl import nn as dglnn
import scipy.stats
from scipy import sparse as sp
from scipy.sparse import csc_matrix
from scipy.spatial import distance, distance_matrix, minkowski_distance
Expand Down Expand Up @@ -276,7 +277,18 @@ def construct_pathway_graph(gex_data, **kwargs):
if j != k:
uu.append(j)
vv.append(k)
ee.append(corr[j][k])
ee.append(1-corr[j][k])
elif pww == 'spearman':
spe=scipy.stats.spearmanr(gex_features.toarray())[0]
if gex_features.toarray().shape[0]==2:
spe=np.array([[1,spe],[spe,1]])
for i in new_pw:
for j in i:
for k in i:
if j != k:
uu.append(j)
vv.append(k)
ee.append(1-spe[j][k])

pickle.dump([uu, vv, ee], open(pk_path, 'wb'))

Expand Down

0 comments on commit 2a2283c

Please sign in to comment.