In [1]:
import pymaid
rm = pymaid.CatmaidInstance('server_url', 'api_token', 'http_user', 'http_password')
In [2]:
pns = pymaid.get_skids_by_annotation('glomerulus DA1 right excitatory')
cn_table = pymaid.get_partners(pns)
cn_table.head()
Out[2]:
In [3]:
downstream_only = cn_table[cn_table.relation == 'downstream']
strong_only = cn_table[cn_table.total >= 10]
large_only = cn_table[cn_table.num_nodes >= 2000]
connected_to_all = cn_table[cn_table[['755022', '2863104', '27295', '61221', '57353', '57323', '57381', '57311']].min(axis=1) != 0]
In [4]:
adj_mat = pymaid.adjacency_matrix(pns, downstream_only[downstream_only.total >= 10])
adj_mat.head()
Out[4]:
In [5]:
import seaborn as sns
import matplotlib.pyplot as plt
cm = sns.clustermap(adj_mat,
cmap='Greys')
plt.show()
In [6]:
import networkx as nx
# Turn the adjacency matrix into a networkX Graph
g = pymaid.network2nx(adj_mat)
# As example: get the degree centrality for each node
dc = nx.degree_centrality(g)
print('Node centrality for some of the nodes in the network: ', dc['755022'], dc['2863104'], dc['27295'])
In [7]:
nx.write_graphml(g, 'graph.graphml')