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
10 changes: 5 additions & 5 deletions netZooPy/sambar/sambar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import networkx as nx
from scipy.spatial.distance import pdist,cosine,squareform
from scipy.cluster.hierarchy import linkage,cut_tree
import pkg_resources
"""
Description:
Python implementation of the Subtyping Agglomerated Mutations By Annotation Relations (SAMBAR) method as implemented in R https://github.com/mararie/SAMBAR.
Expand Down Expand Up @@ -40,10 +39,11 @@
This package includes the functions ```sambar```,```desparsify```,```corgenelength```,```convertgmt```,```clustering``` as well as an implementation of the binomial distance (Millar dissimilarity from the package vegdist from R. To see the full description of each of this functions use ```help(pysambar.function)```.
"""
## Default toydata files
esize = pkg_resources.resource_filename(__name__, 'esizef.csv')
genes = pkg_resources.resource_filename(__name__, 'genes.txt')
sign = pkg_resources.resource_filename(__name__, 'h.all.v6.1.symbols.gmt')
mut = pkg_resources.resource_filename(__name__, 'mut.ucec.csv')
_DATA_DIR = os.path.dirname(__file__)
esize = os.path.join(_DATA_DIR, 'esizef.csv')
genes = os.path.join(_DATA_DIR, 'genes.txt')
sign = os.path.join(_DATA_DIR, 'h.all.v6.1.symbols.gmt')
mut = os.path.join(_DATA_DIR, 'mut.ucec.csv')

def corgenelength(mut,cangenes,esize,normbysample=True,subcangenes=True):
"""
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