Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions netZooPy/condor/condor.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,14 @@ def matrices(self, c,resolution):
# Computes weighted biadjacency matrix.
A = np.matrix(np.zeros((p, q)))
for edge in self.net.iterrows():
A[gn[edge[1][1]], rg[edge[1][0]]] = edge[1][2]
row = edge[1]
A[gn[row.iloc[1]], rg[row.iloc[0]]] = row.iloc[2]

# Computes node degrees for the nodesets.
ki = A.sum(1)
dj = A.sum(0)
# Computes sum of edges and bimodularity matrix.
m = float(sum(ki))
m = float(ki.sum())
B = A - resolution*((ki @ dj) / m)

# d = self.index_dict
Expand Down
12 changes: 6 additions & 6 deletions netZooPy/lioness/lioness.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,16 +412,16 @@ def __lioness_loop(self, i):
return(np.array([0]))
else:
if self.computing == "gpu" and i == 0:
self.total_lioness_network = np.fromstring(
np.transpose(lioness_network).tostring(), dtype=lioness_network.dtype
self.total_lioness_network = np.frombuffer(
np.transpose(lioness_network).tobytes(), dtype=lioness_network.dtype
)[:,np.newaxis]

elif self.computing == "gpu" and i != 0:
self.total_lioness_network = np.column_stack(
(
self.total_lioness_network,
np.fromstring(
np.transpose(lioness_network).tostring(),
np.frombuffer(
np.transpose(lioness_network).tobytes(),
dtype=lioness_network.dtype,
),
)
Expand Down Expand Up @@ -467,9 +467,9 @@ def __par_lioness_loop(self, i, output, online_coexpression=None):

# TODO: why this? Should we remove it?
# if i == 0:
# self.total_lioness_network = np.fromstring(np.transpose(lioness_network).tostring(),dtype=lioness_network.dtype)
# self.total_lioness_network = np.frombuffer(np.transpose(lioness_network).tobytes(),dtype=lioness_network.dtype)
# else:
# self.total_lioness_network=np.column_stack((self.total_lioness_network ,np.fromstring(np.transpose(lioness_network).tostring(),dtype=lioness_network.dtype)))
# self.total_lioness_network=np.column_stack((self.total_lioness_network ,np.frombuffer(np.transpose(lioness_network).tobytes(),dtype=lioness_network.dtype)))
if self.ignore_final:
return(np.array([0]))
else:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_cobra.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def test_cobra():
pd.testing.assert_frame_equal(G, G_gt, rtol=1e-10, check_exact=False)

q = psi.shape[0]
X_mean = np.mean(X.to_numpy(), axis=0)
for i in range(q):
C = Q.to_numpy().dot(np.mean(X, axis=0)[i] * np.diag(psi.to_numpy()[i, :])).dot(Q.to_numpy().T)
C_gt = Q_gt.to_numpy().dot(np.mean(X, axis=0)[i] * np.diag(psi_gt.to_numpy()[i, :])).dot(Q_gt.to_numpy().T)
C = Q.to_numpy().dot(X_mean[i] * np.diag(psi.to_numpy()[i, :])).dot(Q.to_numpy().T)
C_gt = Q_gt.to_numpy().dot(X_mean[i] * np.diag(psi_gt.to_numpy()[i, :])).dot(Q_gt.to_numpy().T)
pd.testing.assert_frame_equal(pd.DataFrame(C), pd.DataFrame(C_gt), rtol=1e-10, check_exact=False)
Loading