Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_standardize(x):
w = thresholding.standardize(x)
assert w is not None
from pynets.stats.netmotifs import adaptivethresh
from pynets.core.thresholding import standardize
from scipy import spatial
import pandas as pd
from py3plex.core import multinet
# Structural graph threshold window
struct_mat = standardize(struct_mat)
dims_struct = struct_mat.shape[0]
struct_mat[range(dims_struct), range(dims_struct)] = 0
tmin_struct = struct_mat.min()
tmax_struct = struct_mat.max()
threshes_struct = np.linspace(tmin_struct, tmax_struct, bins)
# Functional graph threshold window
func_mat = standardize(func_mat)
dims_func = func_mat.shape[0]
func_mat[range(dims_func), range(dims_func)] = 0
tmin_func = func_mat.min()
tmax_func = func_mat.max()
threshes_func = np.linspace(tmin_func, tmax_func, bins)
assert np.all(struct_mat == struct_mat.T), "Structural Matrix must be symmetric"
assert np.all(func_mat == func_mat.T), "Functional Matrix must be symmetric"
# list of
mlib = ['1113', '1122', '1223', '2222', '2233', '3333']
# Count motifs
print("%s%s%s%s" % ('Mining ', N, '-node motifs: ', mlib))
motif_dict = {}
for thr_struct, thr_func in list(itertools.product(threshes_struct, threshes_func)):
def compare_motifs(struct_mat, func_mat, name, bins=50, N=4):
from pynets.stats.netmotifs import adaptivethresh
from pynets.core.thresholding import standardize
from scipy import spatial
import pandas as pd
from py3plex.core import multinet
# Structural graph threshold window
struct_mat = standardize(struct_mat)
dims_struct = struct_mat.shape[0]
struct_mat[range(dims_struct), range(dims_struct)] = 0
tmin_struct = struct_mat.min()
tmax_struct = struct_mat.max()
threshes_struct = np.linspace(tmin_struct, tmax_struct, bins)
# Functional graph threshold window
func_mat = standardize(func_mat)
dims_func = func_mat.shape[0]
func_mat[range(dims_func), range(dims_func)] = 0
tmin_func = func_mat.min()
tmax_func = func_mat.max()
threshes_func = np.linspace(tmin_func, tmax_func, bins)
assert np.all(struct_mat == struct_mat.T), "Structural Matrix must be symmetric"
assert np.all(func_mat == func_mat.T), "Functional Matrix must be symmetric"
self.in_mat = thresholding.normalize(self.in_mat)
# Apply log10
elif self.norm == 2:
self.in_mat = np.log10(self.in_mat)
# Apply PTR simple-nonzero
elif self.norm == 3:
self.in_mat = pass_to_ranks(self.in_mat, method="simple-nonzero")
# Apply PTR simple-all
elif self.norm == 4:
self.in_mat = pass_to_ranks(self.in_mat, method="simple-all")
# Apply PTR zero-boost
elif self.norm == 5:
self.in_mat = pass_to_ranks(self.in_mat, method="zero-boost")
# Apply standardization [0, 1]
elif self.norm == 6:
self.in_mat = thresholding.standardize(self.in_mat)
else:
pass
self.G = nx.from_numpy_matrix(self.in_mat)
return self.G
self.in_mat = thresholding.normalize(self.in_mat)
# Apply log10
elif self.norm == 2:
self.in_mat = np.log10(self.in_mat)
# Apply PTR simple-nonzero
elif self.norm == 3:
self.in_mat = pass_to_ranks(self.in_mat, method="simple-nonzero")
# Apply PTR simple-all
elif self.norm == 4:
self.in_mat = pass_to_ranks(self.in_mat, method="simple-all")
# Apply PTR zero-boost
elif self.norm == 5:
self.in_mat = pass_to_ranks(self.in_mat, method="zero-boost")
# Apply standardization [0, 1]
elif self.norm == 6:
self.in_mat = thresholding.standardize(self.in_mat)
else:
pass
self.G = nx.from_numpy_matrix(self.in_mat)
return self.G