graph
navis.graph.classify_nodes
#
Classify neuron's nodes into end nodes, branches, slabs or root.
Adds a 'type'
column to x.nodes
table.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
categorical |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
TreeNeuron / List | |
Examples:
>>> import navis
>>> nl = navis.example_neurons(2)
>>> _ = navis.graph.classify_nodes(nl, inplace=True)
Source code in navis/graph/graph_utils.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
|
navis.graph.connected_subgraph
#
Return set of nodes necessary to connect all nodes in subset ss
.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
ss |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
np.ndarray | Node IDs of connected subgraph. |
root ID | ID of the node most proximal to the old root in the connected subgraph. |
Examples:
>>> import navis
>>> n = navis.example_neurons(1)
>>> ends = n.nodes[n.nodes.type.isin(['end', 'root'])].node_id.values
>>> sg, root = navis.graph.graph_utils.connected_subgraph(n, ends)
>>> # Since we asked for a subgraph connecting all terminals + root,
>>> # we expect to see all nodes in the subgraph
>>> sg.shape[0] == n.nodes.shape[0]
True
Source code in navis/graph/graph_utils.py
1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 |
|
navis.graph.generate_list_of_childs
#
Return list of childs.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
dict |
|
Source code in navis/graph/graph_utils.py
1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 |
|
navis.graph.node_label_sorting
#
Return nodes ordered by node label sorting according to Cuntz et al., PLoS Computational Biology (2010).
PARAMETER | DESCRIPTION |
---|---|
x | TYPE: |
weighted |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
list |
|
Source code in navis/graph/graph_utils.py
1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 |
|
navis.graph.simplify_graph
#
Simplify skeleton graph (networkX or igraph).
This function will simplify the graph by keeping only roots, leafs and branch points. Preserves branch lengths (i.e. weights)!
PARAMETER | DESCRIPTION |
---|---|
G |
TYPE: |
inplace |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
G | Simplified graph. TYPE: |
Examples:
>>> import navis
>>> n = navis.example_neurons(1, kind='skeleton')
>>> # Simplify skeleton's NetworkX graph representation
>>> G_simp_nx = navis.graph.simplify_graph(n.graph)
>>> # Check that we have the expected number of nodes
>>> assert len(G_simp_nx.nodes) == (n.n_branches + n.n_root + n.n_leafs)
>>> # Simplify skeleton's iGraph graph representation
>>> G_simp_ig = navis.graph.simplify_graph(n.igraph)
>>> # Check that we have the expected number of nodes
>>> assert len(G_simp_ig.vs) == (n.n_branches + n.n_root + n.n_leafs)
Source code in navis/graph/converters.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
navis.graph.skeleton_adjacency_matrix
#
Generate adjacency matrix for a skeleton.
PARAMETER | DESCRIPTION |
---|---|
x |
TYPE: |
sort |
TYPE: |
RETURNS | DESCRIPTION |
---|---|
pd.DataFrame | Adjacency matrix where rows are nodes and columns are their parents. |
See Also
navis.geodesic_matrix
For distances between all points. navis.distal_to
Check if a node A is distal to node B. navis.dist_between
Get point-to-point geodesic ("along-the-arbor") distances.
Source code in navis/graph/graph_utils.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
|