neuprint_search
searches for bodyids corresponding to a
given name. By default performs regex sensitive matches against neuron
names and returns a data.frame
.
neuprint_ids
provides for flexible search / specification
of neuprint body ids. Use it at the start of any function that accepts body
ids. Queries are by default partial and fixed (i.e. non-regex) against
type. Returns a character vector of bodyids.
neuprint_search(
search,
field = "name",
fixed = FALSE,
exact = NULL,
meta = TRUE,
all_segments = FALSE,
dataset = NULL,
conn = NULL,
...
)
neuprint_ids(
x,
mustWork = TRUE,
unique = TRUE,
fixed = TRUE,
conn = NULL,
dataset = NULL,
...
)
Search query, by default a regular expression that must match
the whole of the neuPrint instance name field. See examples and the
field
, fixed
and exact
for how this can be modified.
the meta data field in which you want a match for your search
query. Defaults to name (or instance, as handled by
neuprintr:::neuprint_name_field
). Other common options include type,
status, cellBodyFiber etc.
if FALSE
(the default), search
is interpreted as a
regular expression (i.e. "Advanced input" in neuPrint Explorer). If
TRUE
, the string search
is interpreted as a simple character
string to be matched (the default search behavior in neuPrint explorer). In
this case partial matches are fine.
Whether the query must match the whole field. This is always
true for regular expression queries while the default (NULL
) implies
false for fixed
queries.
if TRUE
, meta data for found bodyids is also pulled
if TRUE, all bodies are considered, if FALSE, only 'Neurons', i.e. bodies with a status roughly traced status.
optional, a dataset you want to query. If NULL
, the
default specified by your R environ file is used or, failing that the
current connection, is used. See neuprint_login
for details.
optional, a neuprintr connection object, which also specifies the
neuPrint server. If NULL, the defaults set in your
.Rprofile
or .Renviron
are
used. See neuprint_login
for details.
Additional arguments passed to neuprint_search
A set of bodyids or a query
Whether to insist that at least one valid id is returned
(default TRUE
)
Whether to ensure that only unique ids are returned (default
TRUE
)
a vector of body ids, or a data frame with their meta information
For neuprint_ids
, a character vector of bodyids (of length 0
when there are none and mustWork=FALSE
).
It is probably best just to look at the examples, but the query syntax is as follows where square brackets denote optional parts:
[!/][<field>:]<query>
Starting with the optional leading character. An exclamation mark denotes an exact, fixed search. The / denotes a regular expression (exact) search. When both are missing, a partial, fixed search is carried out.
The optional field argument terminated by a colon defines a field other than the default one to use for the query.
Finally the query itself is a plain text (fixed) or regular expression query.
As a stepping stone to writing full CYPHER
queries against Neo4J you can used the special where
keyword to
introduce your queries:
where:<cypher query>
e.g.
"where:exists(n.somaLocation) AND n.post>30000 AND NOT n.cropped"
Note that properties of individual nodes (i.e. neurons) must be prefixed
with n.
as would be typical in a CYPHER query. This feature is still
experimental and details of the interface may still change. If you have
feedback please do so at
https://github.com/natverse/neuprintr/pull/153.
# \donttest{
neuprint_search(".*DA2.*")
#> bodyid pre post upstream downstream status statusLabel voxels
#> 1 1796817841 396 509 509 3275 Traced Roughly traced 726508881
#> 2 1796818119 511 818 818 4111 Traced Roughly traced 917547898
#> 3 1797505019 345 476 476 2932 Traced Roughly traced 450568345
#> 4 1827516355 391 548 548 3263 Traced Roughly traced 741928779
#> 5 818983130 409 562 562 3400 Traced Roughly traced 612641685
#> 6 1669017843 89 106 106 490 Traced Leaves 83607944
#> 7 1669699714 89 95 95 482 Traced Leaves 78128261
#> 8 1669946117 102 118 118 521 Traced Leaves 99214765
#> 9 1670382036 78 102 102 412 Traced Leaves 71552951
#> 10 1670386270 93 94 94 463 Traced Leaves 82834198
#> 11 1670390647 91 127 127 485 Traced Leaves 71396028
#> 12 1669358817 86 107 107 443 Traced Leaves 76911124
#> 13 1671659809 18 17 17 66 Traced Leaves 7008274
#> 14 1702107389 70 86 86 324 Traced Leaves 71342150
#> 15 1702802179 103 110 110 522 Traced Leaves 76354600
#> 16 1701675592 124 156 156 646 Traced Leaves 102503828
#> 17 1701757711 88 86 86 433 Traced Leaves 85122273
#> 18 1700393451 93 137 137 492 Traced Leaves 74038623
#> 19 1732792926 86 114 114 518 Traced Leaves 90045017
#> 20 1732797061 85 87 87 450 Traced Leaves 78823995
#> 21 1733491818 97 109 109 499 Traced Leaves 85400235
#> 22 1733833296 109 141 141 606 Traced Leaves 90844980
#> 23 1796809680 67 69 69 317 Traced Leaves 31604606
#> 24 1796813992 57 63 63 296 Traced Leaves 26856261
#> 25 1796818061 83 95 95 451 Traced Leaves 67833130
#> 26 1796818191 48 69 69 234 Traced Leaves 23328521
#> 27 1796822470 96 98 98 496 Traced Leaves 80017616
#> 28 1826929327 101 126 126 553 Traced Leaves 89671264
#> 29 1858887650 43 54 54 210 Traced Leaves 19559580
#> 30 1858892359 51 58 58 229 Traced Leaves 26021432
#> 31 1859220826 41 35 35 205 Traced Leaves 26734869
#> 32 1859224592 59 67 67 244 Traced Leaves 31014767
#> 33 1859224739 50 44 44 233 Traced Leaves 18505661
#> 34 1859565686 38 36 36 181 Traced Leaves 16301601
#> 35 1889931525 50 50 50 237 Traced Leaves 19397298
#> 36 5901198995 90 108 108 514 Traced Leaves 74962468
#> 37 5901201379 21 2 2 112 Traced Leaves 11362150
#> 38 5901202409 104 128 128 506 Traced Leaves 80877299
#> 39 5813040847 81 77 77 415 Traced Leaves 66608639
#> 40 5812994702 86 102 102 447 Traced Leaves 90239045
#> cropped name type cellBodyFiber notes soma
#> 1 FALSE DA2_lPN_R DA2_lPN AVM02 <NA> TRUE
#> 2 FALSE DA2_lPN_R DA2_lPN AVM02 <NA> TRUE
#> 3 FALSE DA2_lPN_R DA2_lPN AVM02 <NA> FALSE
#> 4 FALSE DA2_lPN_R DA2_lPN AVM02 <NA> TRUE
#> 5 FALSE DA2_lPN_R DA2_lPN AVM02 <NA> FALSE
#> 6 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 7 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 8 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 9 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 10 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 11 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 12 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 13 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 14 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 15 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 16 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 17 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 18 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 19 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 20 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 21 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 22 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 23 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 24 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 25 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 26 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 27 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 28 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 29 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 30 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 31 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 32 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 33 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 34 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 35 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 36 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 37 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 38 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 39 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
#> 40 TRUE ORN_DA2 ORN_DA2 <NA> <NA> FALSE
neuprint_search(".*DA2.*", meta=FALSE)
#> [1] 1796817841 1796818119 1797505019 1827516355 818983130 1669017843
#> [7] 1669699714 1669946117 1670382036 1670386270 1670390647 1669358817
#> [13] 1671659809 1702107389 1702802179 1701675592 1701757711 1700393451
#> [19] 1732792926 1732797061 1733491818 1733833296 1796809680 1796813992
#> [25] 1796818061 1796818191 1796822470 1826929327 1858887650 1858892359
#> [31] 1859220826 1859224592 1859224739 1859565686 1889931525 5901198995
#> [37] 5901201379 5901202409 5813040847 5812994702
# Search the type field
neuprint_search("MBON.*", field = "type", meta=FALSE)
#> [1] 612371421 673509195 424789697 5813022341 487925037 612738462
#> [7] 487925063 613079053 1386512867 799586652 422725634 5813061512
#> [13] 1234386037 611477605 733036127 920470959 1016835041 1048215779
#> [19] 1078693835 613719036 672352543 768555687 424767514 517518166
#> [25] 704466265 861665641 1139667240 300972942 394225044 5813067721
#> [31] 5813068729 642664141 673702721 457175171 579916831 673366098
#> [37] 5812981264 5812981543 457196444 5813020828 423774471 517854468
#> [43] 792368888 5813022896 985813153 5813042659 985131499 423382015
#> [49] 487143497 550081497 612742248 612422902 912951014 895441451
#> [55] 5813061538 5813117385 457196643 5813058048 5813052909 5813022234
#> [61] 5813040205 706948318 894020730 642732835 643847447 518670779
#> [67] 547552266 1173814525 5813033000 518930199 611089775
neuprint_search("MBON[0-9]+", field = "type", meta=FALSE)
#> [1] 612371421 673509195 424789697 5813022341 487925037 612738462
#> [7] 487925063 613079053 1386512867 799586652 422725634 5813061512
#> [13] 1234386037 611477605 733036127 920470959 1016835041 1048215779
#> [19] 1078693835 613719036 672352543 768555687 424767514 517518166
#> [25] 704466265 861665641 1139667240 300972942 394225044 5813067721
#> [31] 5813068729 642664141 673702721 673366098 5812981264 457196444
#> [37] 5813020828 423774471 517854468 792368888 5813022896 985813153
#> [43] 5813042659 985131499 423382015 487143497 550081497 612742248
#> [49] 612422902 912951014 895441451 5813061538 5813117385 457196643
#> [55] 5813058048 5813052909 5813022234 5813040205 706948318 894020730
#> [61] 642732835 643847447 518670779 547552266 1173814525 5813033000
#> [67] 518930199 611089775
# compact specification of field
neuprint_search("type:MBON[0-9]+", meta=FALSE)
#> [1] 612371421 673509195 424789697 5813022341 487925037 612738462
#> [7] 487925063 613079053 1386512867 799586652 422725634 5813061512
#> [13] 1234386037 611477605 733036127 920470959 1016835041 1048215779
#> [19] 1078693835 613719036 672352543 768555687 424767514 517518166
#> [25] 704466265 861665641 1139667240 300972942 394225044 5813067721
#> [31] 5813068729 642664141 673702721 673366098 5812981264 457196444
#> [37] 5813020828 423774471 517854468 792368888 5813022896 985813153
#> [43] 5813042659 985131499 423382015 487143497 550081497 612742248
#> [49] 612422902 912951014 895441451 5813061538 5813117385 457196643
#> [55] 5813058048 5813052909 5813022234 5813040205 706948318 894020730
#> [61] 642732835 643847447 518670779 547552266 1173814525 5813033000
#> [67] 518930199 611089775
# starts with MBON
neuprint_search("type:MBON.*", meta=FALSE)
#> [1] 612371421 673509195 424789697 5813022341 487925037 612738462
#> [7] 487925063 613079053 1386512867 799586652 422725634 5813061512
#> [13] 1234386037 611477605 733036127 920470959 1016835041 1048215779
#> [19] 1078693835 613719036 672352543 768555687 424767514 517518166
#> [25] 704466265 861665641 1139667240 300972942 394225044 5813067721
#> [31] 5813068729 642664141 673702721 457175171 579916831 673366098
#> [37] 5812981264 5812981543 457196444 5813020828 423774471 517854468
#> [43] 792368888 5813022896 985813153 5813042659 985131499 423382015
#> [49] 487143497 550081497 612742248 612422902 912951014 895441451
#> [55] 5813061538 5813117385 457196643 5813058048 5813052909 5813022234
#> [61] 5813040205 706948318 894020730 642732835 643847447 518670779
#> [67] 547552266 1173814525 5813033000 518930199 611089775
# full access to WHERE cypher queries over nodes (i.e. neurons) in neo4j
# NB fields must be prefixed with n. to indicate that they are node properties.
# note also that exists(n.somaLocation) is cypher to ensure soma==TRUE
neuprint_search("where:exists(n.somaLocation) AND n.post>30000 AND NOT n.cropped")
#> bodyid pre post upstream downstream status statusLabel voxels
#> 1 425276848 7088 30007 30007 23734 Traced Roughly traced 6483095365
#> 2 612371421 2208 32544 32544 21759 Traced Traced 6839504360
#> 3 5813105172 17628 77269 77269 52993 Traced Roughly traced 15191654896
#> 4 425790257 16190 127151 127151 121662 Traced Roughly traced 23360457066
#> cropped name type cellBodyFiber notes soma
#> 1 FALSE DPM_L DPM <NA> <NA> TRUE
#> 2 FALSE MBON01(y5B'2a)_R MBON01 ADM07 <NA> TRUE
#> 3 FALSE DPM_R DPM <NA> <NA> TRUE
#> 4 FALSE APL_R APL <NA> <NA> TRUE
# }
if (FALSE) { # \dontrun{
neuprint_search("MBON.*", field = "type")
# fixed=TRUE can be useful when you don't want to worry about special
# characters like brackets
neuprint_search("PEN_a(PEN1)", field="type", fixed=TRUE)
# by default fixed=TRUE returns partial matches
neuprint_search("MBON16", field = "type", fixed=TRUE)
# here the type must exactly match the query i.e. complete match
neuprint_search("MBON16", field = "type", fixed=TRUE, exact = TRUE)
neuprint_search("AVF1", field = "cellBodyFiber")
neuprint_search("cellBodyFiber:AVF1")
} # }
# \donttest{
# exact match against whole type
neuprint_ids("!MBON01")
#> [1] "612371421" "673509195"
# partial match
neuprint_ids("MBON01")
#> [1] "612371421" "673509195"
# partial match against name field rather than type
neuprint_ids("name:MBON01")
#> [1] "673509195" "612371421"
# initial / indicates to use regex search (which must be exact)
neuprint_ids("/MBON01")
#> [1] "612371421" "673509195"
# more interesting regex search
neuprint_ids("/MBON0[1-4]")
#> [1] "612371421" "673509195" "424789697" "5813022341" "487925037"
#> [6] "612738462" "487925063" "613079053"
# partial regex search against the name field (note leading/trailing .*)
neuprint_ids("/name:.*MBON0[1-4].*")
#> [1] "673509195" "612371421" "5813022341" "424789697" "612738462"
#> [6] "487925037" "613079053" "487925063"
# }