### Install malecns and set Neuprint token Source: https://natverse.org/malecns/index.html Install malecns via natmanager, then set the Neuprint token in the R environment and verify access with dr_malecns(). The token is pasted into the .Renviron file after browsing to neuprint.janelia.org; ensure a new line at the end of the file. The example then fetches metadata, reads meshes, and plots them. ```r install.packages("natmanager") natmanager::check_pat() natmanager::install(pkgs="natverse/malecns") ``` ```r # Set your Neuprint token # will open your browser # collect token by clicking on your account icon top right and then Account browseURL('https://neuprint.janelia.org') # back in R usethis::edit_r_environ() # paste in this text replacing with your neuprint token # make sure you have a new lined at the end of the file neuprint_token="eyJhbGci..." # check everything's configured ok dr_malecns() # get some data pnmeta=mcns_neuprint_meta('/.+_[adl]+PN') table(pnmeta$type) vm6=read_mcns_meshes('VM6_adPN') plot3d(malecns.surf, alpha=.1) ``` -------------------------------- ### Example: download, register, and transform with xform_brain Source: https://natverse.org/malecns/reference/mcns_register_xforms2.html Example workflow: first download the h5 deformation fields with mcns_download_xforms2(), then register them once per session with mcns_register_xforms2(), and finally transform a coordinate using xform_brain() with sample='malecns' and reference='JRC2018U'. The example is wrapped in \dontrun{} so it is not executed during package checks. ```r if (FALSE) { # \dontrun{ # first time only mcns_download_xforms2() # then once per session mcns_register_xforms2() xform_brain(cbind(100000, 100000, 50000), sample='malecns', reference='JRC2018U') } # } ``` -------------------------------- ### mcns_neuprint example with token and neuprintr queries Source: https://natverse.org/malecns/reference/mcns_neuprint.html Example usage of mcns_neuprint. It shows logging in with the default token, then with a specified token and Force=TRUE, and then querying anchor neurons and plotting cumulative presynapses and postsynapses. The example is wrapped in \dontrun so it is not executed during package checks. ```r if (FALSE) { # \dontrun{ cnsc=mcns_neuprint() # log in using specified token rather than the one in the neuprint_token # environment variable. This should then be cached for the rest of the R # session. cnsc=mcns_neuprint(token="XXX", Force=T) anchorids <- neuprintr::neuprint_ids("status:Anchor", conn=cnsc) # the last connection will be used by default anchormeta <- neuprintr::neuprint_get_meta("status:Anchor") plot(cumsum(sort(anchormeta$pre, decreasing = TRUE)), ylab='Cumulative presynapses') plot(cumsum(sort(anchormeta$post, decreasing = TRUE)), ylab='Cumulative postsynapses') } # } ``` -------------------------------- ### mcns_scene example with open=TRUE and node='neuprint' Source: https://natverse.org/malecns/reference/mcns_scene.html Example usage of mcns_scene with a body ID, opening the scene in the browser, and specifying the 'neuprint' node. This example is wrapped in a dontrun block, so it is not executed by default. ```r if (FALSE) { # \dontrun{ mcns_scene(4060524874, open=TRUE, node='neuprint') } # } ``` -------------------------------- ### Example of annotating a single body Source: https://natverse.org/malecns/reference/mcns_annotate_body.html An example wrapped in `if (FALSE) { # \dontrun{` that calls the function with a data.frame and the test parameter set to TRUE. The example is not run by default. ```R if (FALSE) { # \dontrun{ # note use of test server mcns_annotate_body(data.frame(bodyid=10005, group=10005), test=TRUE) } # } ``` -------------------------------- ### Example: choose_mcns_dataset with v1.0 and production Source: https://natverse.org/malecns/reference/choose_mcns_dataset.html Example usage of choose_mcns_dataset. The first call selects the v1.0 snapshot for the rest of the R session; the second selects the production version. The code is wrapped in \dontrun{} and is not executed. ```r if (FALSE) { # \dontrun{ # use the v1.0 snapshot for the rest of this R session choose_mcns_dataset("male-cns:v1.0") # use production for the rest of this R session choose_mcns_dataset("CNS") } # } ``` -------------------------------- ### mcns_islatest example Source: https://natverse.org/malecns/reference/mcns_islatest.html Example calls to mcns_islatest with a giant fibre neuron (returns TRUE) and an expired body (returns FALSE). The example is wrapped in \donttest. ```r # \donttest{ # giant fibre neuron mcns_islatest(10001) #> [1] TRUE # an expired body mcns_islatest(49891) #> [1] FALSE # } ``` -------------------------------- ### Example: read_mcns_meshes and plot3d Source: https://natverse.org/malecns/reference/read_mcns_meshes.html Example usage wrapped in \dontrun, showing how to read meshes for a body id and plot them with plot3d, or use wire3d for more control. ```r if (FALSE) { # \dontrun{ ml=read_mcns_meshes(1796013202) plot3d(ml) # or if there's just one mesh, you can get more control with the rgl commands # like wire3d wire3d(ml[[1]]) } # } ``` -------------------------------- ### mirror_malecns example with landmarks Source: https://natverse.org/malecns/reference/mirror_malecns.html Example from the documentation (wrapped in \dontrun). It loads the landmark CSV, mirrors the first three columns, and plots the mirrored points (black), original points (green), and a shifted set (red) to visually verify the mirroring. ```r if (FALSE) { # \dontrun{ f3=system.file("landmarks/maleCNS_mirror_landmarks_nm.csv", package = 'malecns') maleCNS_mirror_landmarks_nm <- read.csv(f3)[-1] points3d(mirror_malecns(maleCNS_mirror_landmarks_nm[1:3])) points3d(maleCNS_mirror_landmarks_nm[1:3], col='green') # almost on top of the black points points3d(maleCNS_mirror_landmarks_nm[4:6]+500, col='red') } # } ``` -------------------------------- ### Example: with_mcns with different datasets Source: https://natverse.org/malecns/reference/with_mcns.html Example usage of `with_mcns` with `mcns_body_annotations`. The first call uses the default dataset `male-cns:v1.0`; the second uses `CNS` and prints a message about switching. Outputs show the returned data frame. ```r if (FALSE) { # \dontrun{ with_mcns(malevnc::manc_dvid_node(type = 'clio')) } # } # \donttest{ # This should work for both clio and neuprint calls, here clio: # this body was typed after the v1.0 snapshot with_mcns(mcns_body_annotations(194965), dataset = "male-cns:v1.0") #> bodyid celltype_predicted_nt celltype_predicted_nt_confidence #> 1 194965 acetylcholine 0.9525882 #> celltype_total_nt_predictions consensus_nt flywire_type group instance #> 1 22356 acetylcholine Sm01 29457 Cm2_L #> predicted_nt predicted_nt_confidence soma_side status superclass #> 1 acetylcholine 0.9600185 L Reviewed ol_intrinsic #> total_nt_predictions type user vfb_id auto #> 1 66 Cm2 bergs VFB_jrmc35xh FALSE with_mcns(mcns_body_annotations(194965), dataset = "CNS") #> switching CNS dataset from `male-cns:v1.0` to `CNS` #> bodyid celltype_predicted_nt celltype_predicted_nt_confidence #> 1 194965 acetylcholine 0.9525913 #> celltype_total_nt_predictions consensus_nt flywire_type group instance #> 1 22356 acetylcholine Sm01 29457 Cm2_L #> predicted_nt predicted_nt_confidence soma_side status superclass #> 1 acetylcholine 0.9600217 L Reviewed ol_intrinsic #> total_nt_predictions type user vfb_id auto #> 1 66 Cm2 bergs VFB_jrmc35xh FALSE # } ``` -------------------------------- ### mcns_set_dvid_annotations usage examples Source: https://natverse.org/malecns/reference/mcns_set_dvid_annotations.html Example calls to `mcns_set_dvid_annotations` showing how to set type, side, group, and how to unset a type by passing an empty string. The `if (FALSE)` wrapper indicates these are not run automatically. The last call removes a type and requires caution. ```r if (FALSE) { # \dontrun{ mcns_set_dvid_annotations(10297, type = 'LHAD1g1') mcns_set_dvid_annotations(10977, type='APL', side='L', group = 10540) # only set the LR group mcns_set_dvid_annotations(ids=c(13115, 14424), group = 13115) # unset i.e. remove a type (careful!) mcns_set_dvid_annotations(18987, type = "", user = "becketti") } # } ``` -------------------------------- ### Example: fancier labelling and interactive heatmap Source: https://natverse.org/malecns/reference/mcns_cosine_plot.html Example usage of mcns_cosine_plot with custom row labels, alternative metadata source, interactive mode, and returning an hclust object. This example is wrapped in a dontrun block. ```r if (FALSE) { # \dontrun{ # fancier labelling of rows including soma side of neurons r=mcns_cosine_plot("/name:LAL.+", partners='out', group=TRUE, labRow = '{name}_{group}_{mcns_soma_side(data.frame(bodyid, name, somaLocation))}') r2=mcns_cosine_plot("/name:LAL.+", partners='out', group=TRUE, labRow = '{instance}_{group}_{soma_side}', metadata.source='clio') # interactive version (open in browser) mcns_cosine_plot('/name:Pm2.*R', group=T, interactive = T) # just return an hclust (dendrogram) object without plotting anything pm2.hc=mcns_cosine_plot('/name:Pm2.*R', group=T, heatmap=FALSE) plot(pm2.hc) } # } ``` -------------------------------- ### mcns_body_annotations example with query and output Source: https://natverse.org/malecns/reference/mcns_body_annotations.html Example usage of mcns_body_annotations. The first call queries body ID "AOTU019" and shows the resulting data.frame with metadata columns. The second call (wrapped in if(FALSE) and \dontrun) queries with a list query for superclass existence and counts the superclass column. The example is not run by default. ```r # \donttest{ mcns_body_annotations("AOTU019") #> birthtime bodyid celltype_predicted_nt celltype_predicted_nt_confidence #> 1 early 10005 gaba 0.8305035 #> 2 early 10070 gaba 0.8305035 #> celltype_total_nt_predictions consensus_nt flywire_type group hemibrain_type #> 1 5673 gaba AOTU019 10005 AOTU019 #> 2 5673 gaba AOTU019 10005 AOTU019 #> instance itolee_hl predicted_nt predicted_nt_confidence soma_side #> 1 AOTU019_R putative_primary gaba 0.8350762 R #> 2 AOTU019_L putative_primary gaba 0.8259292 L #> status superclass total_nt_predictions type vfb_id auto #> 1 Roughly traced cb_intrinsic 2837 AOTU019 VFB_jrmc3hk6 FALSE #> 2 Roughly traced cb_intrinsic 2836 AOTU019 VFB_jrmc3hk5 FALSE # } if (FALSE) { # \dontrun{ mcns.superclass=mcns_body_annotations(query=list(superclass="exists/1")) mcns.superclass %>% count(superclass) } # } ``` -------------------------------- ### GNU GPL v3 program notice template Source: https://natverse.org/malecns/LICENSE.html Use this notice to apply the GNU GPL v3 terms to a new program. Attach it to the start of each source file, including the copyright line and a pointer to the full license. The text includes the warranty disclaimer and a link to the license. ```text Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Example: cosine clustering with grouped output partners Source: https://natverse.org/malecns/reference/mcns_cosine_plot.html Example usage of mcns_cosine_plot to cluster based on grouped output partners. The example includes a warning about dropped neurons and synapses, and a warning about non-positive diagonal entries. ```r # \donttest{ # cosine clustering based on grouped output partners (mainly DNs right now) r=mcns_cosine_plot("/name:LAL.+", partners='out', group=TRUE) #> Warning: Dropping: 94/24280 neurons representing 1658/866555 synapses due to missing ids! #> Warning: diag(V) has non-positive or non-finite entries; finite result is doubtful # } ``` -------------------------------- ### Read and visualize neuronal skeletons Source: https://natverse.org/malecns/reference/read_mcns_neurons.html Examples showing how to read a neuron by ID, inspect the resulting neuronlist object, check its bounding box, and visualize the neuron in 3D. ```R # nb convert n30102=read_mcns_neurons(30102) # neuronlist n30102 #> 'neuronlist' containing 1 'neuprintneuron' object and 'data.frame' with 51 vars [165.9 kB] boundingbox(n30102) #> [,1] [,2] [,3] #> [1,] 168448 92160 197632 #> [2,] 279552 169984 274432 #> attr(,"class") #> [1] "boundingbox" # neuron n30102[[1]] #> 'neuron' with 2154 vertices in 1 tree and additional classes 'neuprintneuron', 'catmaidneuron' if (FALSE) { # \dontrun{ nclear3d() plot3d(malecns.surf, alpha=.1) plot3d(n30102, lwd=2, soma=2000) } # } ``` -------------------------------- ### Example: retrieve all DVID annotations and plot type frequencies Source: https://natverse.org/malecns/reference/mcns_dvid_annotations.html Example usage of mcns_dvid_annotations with no ids, showing the returned tibble and a plot of type frequencies. The output is truncated with #> comments. ```r # \donttest{ mda=mcns_dvid_annotations() head(mda) #> # A tibble: 6 × 49 #> bodyid birthtime celltype_predicted_nt celltype_predicted_nt_confidence #> #> 1 10001 early acetylcholine 0.528 #> 2 10002 NA acetylcholine 0.956 #> 3 10003 early gaba 0.875 #> 4 10005 early gaba 0.831 #> 5 10006 NA acetylcholine 0.820 #> 6 10009 NA gaba 0.866 #> # ℹ 45 more variables: celltype_total_nt_predictions , consensus_nt , #> # flywire_type , group , hemibrain_type , instance , #> # itolee_hl , manc_bodyid , manc_group , manc_type , #> # predicted_nt , predicted_nt_confidence , soma_side , #> # status , subclass , superclass , synonyms , #> # total_nt_predictions , type , vfb_id , notes , #> # supertype , user , halfbrain_body , class , … plot(table(mda$type), ylab='Frequency') kcs=mcns_dvid_annotations("/KC.*") mbons=mcns_dvid_annotations("/MBON.+") head(mbons) #> # A tibble: 6 × 49 #> bodyid birthtime celltype_predicted_nt celltype_predicted_nt_confidence #> #> 1 520151 early glutamate 0.713 #> 2 10013 early glutamate 0.713 #> 3 522749 early glutamate 0.740 #> 4 522444 early glutamate 0.740 #> 5 519373 early glutamate 0.767 #> 6 521526 early glutamate 0.767 #> # ℹ 45 more variables: celltype_total_nt_predictions , consensus_nt , #> # flywire_type , group , hemibrain_type , instance , #> # itolee_hl , manc_bodyid , manc_group , manc_type , #> # predicted_nt , predicted_nt_confidence , soma_side , #> # status , subclass , superclass , synonyms , #> # total_nt_predictions , type , vfb_id , notes , #> # supertype , user , halfbrain_body , class , … # } ``` -------------------------------- ### Example usage of mcns_soma_side and mcns_somapos Source: https://natverse.org/malecns/reference/mcns_soma_side.html Example usage of mcns_soma_side and mcns_somapos. The first call predicts sides for a regular expression; the commented block shows comparisons between manual, instance, and predicted sides using mcns_body_annotations and mcns_neuprint_meta. The final lines plot soma positions and return a comma-separated string for a single neuron. ```r # \donttest{ mcns_soma_side('/LAL04.*') #> [1] "R" "L" "R" "L" "R" "L" "L" "R" "L" "R" "R" "L" "R" "L" "L" "R" "R" "L" "R" #> [20] "L" "R" "L" "L" "L" "R" "R" "L" "L" "L" "R" "R" "R" "R" "L" # } if (FALSE) { # \dontrun{ # All neurons with a type table(mcns_soma_side('/.*'), useNA='if') # compare manual with predictions mcnswsoma=mcns_body_annotations(query=list(soma_side="exists/1")) mcnswsoma$pside=mcns_soma_side(mcnswsoma$bodyid) with(mcnswsoma, table(soma_side, pside)) # compare manual with instance mcnswsoma=mcns_body_annotations(query=list(soma_side="exists/1")) mcnswsoma$iside=mcns_soma_side(mcnswsoma$bodyid, method='instance') with(mcnswsoma, table(soma_side, iside, useNA = 'i')) # converse: compare instance with manual mcns_instance=mcns_neuprint_meta('/name:.+') if(!"somaSide" %in% colnames(mcns_instance)) mcns_instance$somaSide=mcns_soma_side(mcns_instance, method='manual') mcns_instance$iside=mcns_soma_side(mcns_instance, method='instance') # many mismatches e.g. due to neurons without a soma including truncated # sensory neurons, ascending neurons etc with(mcns_instance, table(somaSide, iside, useNA = 'i')) # we can parse that a bit by doing mcns_instance %>% filter(soma) %>% with(table(somaSide, iside, useNA = 'i')) } # } sp=mcns_somapos('/LAL04.*', units='um') plot(sp[,1:2]) mcns_somapos('LAL042', units='um', as_character=TRUE) #> [1] "299.768,99.944,128.68" "438.56,87.904,117.6" ``` -------------------------------- ### Update malecns with natmanager::install Source: https://natverse.org/malecns/index.html Update an existing malecns installation by reinstalling from GitHub via natmanager. ```r install.packages("natmanager") natmanager::install(pkgs="natverse/malecns") ``` -------------------------------- ### Configure Clio and DVID credentials in .RProfile Source: https://natverse.org/malecns/index.html Configure Clio and DVID user credentials for write access to the production dataset. Edit your .RProfile with usethis::edit_r_profile() and set malevnc.clio_email and malevnc.dvid_user; the dvid_user example is formatted as surname plus first initial. ```r usethis::edit_r_profile() # paste in this text, appropriately edited, and close the file options(malevnc.clio_email="myuser@gmail.com") # e.g. "jefferisg" options(malevnc.dvid_user="") ``` -------------------------------- ### mcns_xyz2bodyid example with soma positions Source: https://natverse.org/malecns/reference/mcns_xyz2bodyid.html Example usage: maps soma positions from mcns_somapos to body IDs, returning a numeric vector. Also shows a commented-out call for the APL neuron using a raw coordinate offset. ```r # \donttest{ # find the bodyids corresponding to set of soma positions mcns_xyz2bodyid(mcns_somapos("/LAL04[12]", units='raw'), units='raw') #> [1] 34187 512750 # } # the APL if (FALSE) { # \dontrun{ mcns_xyz2bodyid(cbind(24508, 15674, 26116)+4096) } # } ``` -------------------------------- ### Bounding box and plotting for malecns.surf Source: https://natverse.org/malecns/reference/malecns.surf.html Computes the bounding box of the neuropil surface model and shows plotting options in microns, raw voxels, and as a mesh3d object. The bounding box output is shown. The plotting code is wrapped in \dontrun and will not run in examples. ```R # \donttest{ library(nat) boundingbox(malecns.surf) #> [,1] [,2] [,3] #> [1,] 45319.4 38146.7 79817.4 #> [2,] 726917.9 417784.6 341814.2 #> attr(,"class") #> [1] "boundingbox" # } if (FALSE) { # \dontrun{ plot3d(malecns.surf, alpha=.2, col='grey') # in microns plot3d(malecns.surf/1e3, alpha=.2, col='grey') # in raw voxels plot3d(malecns.surf*(8/1e3), alpha=.2, col='grey') # mesh3d gives more flexibility plot3d(as.mesh3d(malecns.surf), alpha=.2, col='grey', type='wire', add=T) } # } ``` -------------------------------- ### Query using coordinates and then get inputs Source: https://natverse.org/malecns/reference/mcns_connection_table.html Finds a neuron by coordinates (joffrey.id) using mcns_xyz2bodyid, then fetches its input partners with and without summary. ```R joffrey.id=mcns_xyz2bodyid(cbind(24590, 13816, 26102)+4096, node = 'neuprint') joffrey.us=mcns_connection_table(joffrey.id, partners = 'in') joffrey.uss=mcns_connection_table(joffrey.id, partners = 'in', summary=TRUE) ``` -------------------------------- ### Bounding box and plotting for malecns_shell.surf Source: https://natverse.org/malecns/reference/malecns.surf.html Computes the bounding box of the cortex surface model and shows plotting options in microns, raw voxels, and as a mesh3d object. The bounding box output is shown. The plotting code is wrapped in \dontrun and will not run in examples. ```R # \donttest{ library(nat) boundingbox(malecns_shell.surf) #> [,1] [,2] [,3] #> [1,] 16898.1 31849.1 26324.4 #> [2,] 750590.0 441841.0 460357.0 #> attr(,"class") #> [1] "boundingbox" # } if (FALSE) { # \dontrun{ plot3d(malecns_shell.surf, alpha=.2, col='grey') # in microns plot3d(malecns_shell.surf/1e3, alpha=.2, col='grey') # in raw voxels plot3d(malecns_shell.surf*(8/1e3), alpha=.2, col='grey') # mesh3d gives more flexibility plot3d(as.mesh3d(malecns_shell.surf), alpha=.2, col='grey', type='wire', add=T) } # } ``` -------------------------------- ### mcns_dvid_annotations Source: https://natverse.org/malecns/reference/mcns_dvid_annotations.html Documentation for the mcns_dvid_annotations function, including usage, arguments, return value, and examples. ```APIDOC ## mcns_dvid_annotations ### Description Returns all DVID body annotations for the specified body ids, or all annotations if no ids are provided. The function can return a parsed data.frame or a raw list, and supports caching of results. ### Usage ```r mcns_dvid_annotations( ids = NULL, node = "neutu", rval = c("data.frame", "list"), columns_show = NULL, cache = FALSE, ... ) ``` ### Arguments - **ids** (character/numeric) - Optional - A set of body ids in any form understandable to `manc_ids`. - **node** (character) - Optional - A DVID node as returned by `manc_dvid_node`. Default is the current active (unlocked) node used through neutu. - **rval** (character) - Optional - Whether to return a fully parsed data.frame (default) or an R list. The data.frame is easier to work with but typically includes NAs for many values that would be missing in the list. - **columns_show** (character) - Optional - Whether to show all columns, or just those with '_user' or '_time' suffix. Accepted options are: 'user', 'time', 'all'. - **cache** (logical) - Optional - Whether to cache the result of this call for 5 minutes. - **...** - Optional - Additional arguments passed to `pblapply`. ### Value A `tibble` containing columns including: - **bodyid** (numeric) - The body id. - **status** (character) - Status of the annotation. - **user** (character) - User who made the annotation. - **naming_user** (character) - User who named the body. - **instance** (character) - Instance name. - **status_user** (character) - User who set the status. - **comment** (character) - Comment associated with the annotation. NB: only one `bodyid` is used regardless of whether the key-value returned has 0, 1 or 2 bodyid fields. When `ids` are specified, missing ids will have a row containing the `bodyid` in question and all other columns will be `NA`. ### Details See the Slack post from Stuart Berg for details. The original API call used `:master`, but this has been changed to `` as returned by `manc_dvid_node` because the range query stopped working on 16 May 2021, probably due to a bad node. ### Examples ```r # \donttest{ mda=mcns_dvid_annotations() head(mda) #> # A tibble: 6 × 49 #> bodyid birthtime celltype_predicted_nt celltype_predicted_nt_confidence #> #> 1 10001 early acetylcholine 0.528 #> 2 10002 NA acetylcholine 0.956 #> 3 10003 early gaba 0.875 #> 4 10005 early gaba 0.831 #> 5 10006 NA acetylcholine 0.820 #> 6 10009 NA gaba 0.866 #> # ℹ 45 more variables: celltype_total_nt_predictions , consensus_nt , #> # flywire_type , group , hemibrain_type , instance , #> # itolee_hl , manc_bodyid , manc_group , manc_type , #> # predicted_nt , predicted_nt_confidence , soma_side , #> # status , subclass , superclass , synonyms , #> # total_nt_predictions , type , vfb_id , notes , #> # supertype , user , halfbrain_body , class , … plot(table(mda$type), ylab='Frequency') kcs=mcns_dvid_annotations("/KC.*") mbons=mcns_dvid_annotations("/MBON.+") head(mbons) #> # A tibble: 6 × 49 #> bodyid birthtime celltype_predicted_nt celltype_predicted_nt_confidence #> #> 1 520151 early glutamate 0.713 #> 2 10013 early glutamate 0.713 #> 3 522749 early glutamate 0.740 #> 4 522444 early glutamate 0.740 #> 5 519373 early glutamate 0.767 #> 6 521526 early glutamate 0.767 #> # ℹ 45 more variables: celltype_total_nt_predictions , consensus_nt , #> # flywire_type , group , hemibrain_type , instance , #> # itolee_hl , manc_bodyid , manc_group , manc_type , #> # predicted_nt , predicted_nt_confidence , soma_side , #> # status , subclass , superclass , synonyms , #> # total_nt_predictions , type , vfb_id , notes , #> # supertype , user , halfbrain_body , class , … # } ``` ``` -------------------------------- ### Bounding box and combined plotting for malecnsvnc_shell.surf Source: https://natverse.org/malecns/reference/malecns.surf.html Computes the bounding box of the ventral nerve cord cortex surface model and shows a combined plot of all four surface models. The bounding box output is shown. The plotting code is wrapped in \dontrun and will not run in examples. ```R # \donttest{ library(nat) boundingbox(malecnsvnc_shell.surf) #> [,1] [,2] [,3] #> [1,] 236909 307526 415488 #> [2,] 551724 574158 1076990 #> attr(,"class") #> [1] "boundingbox" # } if (FALSE) { # \dontrun{ nclear3d() plot3d(malecns.surf, col='blue') wire3d(malecns_shell.surf, col='grey') plot3d(malecnsvnc.surf, col='blue') wire3d(malecnsvnc_shell.surf, alpha=.2, col='green') } # } ``` -------------------------------- ### Query neuprint metadata with mcns_neuprint_meta() Source: https://natverse.org/malecns/reference/mcns_neuprint_meta.html Fetches neuprint metadata for all bodies and for subsets filtered by somaLocation, type/instance, or missing superclass with high synapse weight. The final query returns a data frame sorted by synweight; the displayed output shows the first 29 rows with columns including bodyid, synapse counts, and statusLabel. ```R library(dplyr) # fetch metatada for all bodies in neuprint mnm=mcns_neuprint_meta() # fetch metadata for all bodies with a somaLocation mnm.soma=mcns_neuprint_meta("where:exists(n.somaLocation)") # type or instance present mnm.ti <- mcns_neuprint_meta('where:exists(n.type) OR exists(n.instance)') # neurons without a superclass but quite a few synapses mnm.nc=mcns_neuprint_meta("where:NOT exists(n.superclass) AND n.synweight>2000") mnm.nc %>% arrange(desc(synweight)) #> bodyid post pre downstream upstream synweight assignedOlHex1 #> 1 519161 2401 322 2717 2401 5118 NA #> 2 555297 253 632 4061 253 4314 NA #> 3 806539 202 447 3169 202 3371 NA #> 4 73540 332 322 3016 332 3348 NA #> 5 926152 1134 321 2087 1134 3221 NA #> 6 956675 55 421 3139 55 3194 NA #> 7 92244 1753 222 1426 1753 3179 NA #> 8 942401 351 465 2705 351 3056 NA #> 9 955927 163 401 2644 163 2807 NA #> 10 104626 55 318 2732 55 2787 NA #> 11 559672 1395 247 1385 1395 2780 NA #> 12 110922 62 267 2640 62 2702 NA #> 13 114076 150 300 2529 150 2679 NA #> 14 516174168 128 319 2472 128 2600 NA #> 15 959135 71 364 2507 71 2578 NA #> 16 955615 450 382 2109 450 2559 NA #> 17 118423 101 260 2443 101 2544 NA #> 18 147605 1180 183 1207 1180 2387 NA #> 19 956674 868 281 1506 868 2374 NA #> 20 954995 399 305 1971 399 2370 NA #> 21 555267 64 289 2300 64 2364 NA #> 22 210839 70 268 2294 70 2364 NA #> 23 908376 26 235 2318 26 2344 NA #> 24 809279 107 279 2117 107 2224 NA #> 25 810259 74 256 2039 74 2113 NA #> 26 544325 238 254 1820 238 2058 NA #> 27 147742 257 204 1790 257 2047 NA #> 28 903906 52 327 1983 52 2035 NA #> 29 946550 949 128 1067 949 2016 NA #> assignedOlHex2 flywireType group name somaSide statusLabel #> 1 NA NA KC_L_fragment L Orphan #> 2 NA NA Orphan #> 3 NA NA Orphan-artifact #> 4 NA NA PRT Orphan #> 5 NA NA Orphan-artifact #> 6 NA NA #> 7 NA NA Orphan #> 8 NA NA Orphan-artifact #> 9 NA NA #> 10 NA NA Anchor #> 11 NA NA Orphan #> 12 NA NA Anchor #> 13 NA NA Orphan #> 14 NA NA PRT Orphan #> 15 NA NA #> 16 NA NA #> 17 NA NA Orphan #> 18 NA NA Orphan #> 19 NA NA Partially traced #> 20 NA NA #> 21 NA NA Orphan #> 22 NA NA PRT Orphan #> 23 NA NA Orphan-artifact #> 24 NA NA Orphan-artifact #> 25 NA NA Orphan-artifact #> 26 NA NA RT Hard to trace #> 27 NA NA Orphan #> 28 NA NA Orphan-artifact #> 29 NA NA Orphan ``` -------------------------------- ### Check malecns package options Source: https://natverse.org/malecns/reference/malecns-package.html Shows the current malecns package options, including the default dataset 'male-cns:v1.0'. ```r options()[grepl("^malecns", names(options()))] #> $malecns.dataset #> [1] "male-cns:v1.0" #> ``` -------------------------------- ### mcns_download_xforms2() Source: https://natverse.org/malecns/reference/mcns_register_xforms2.html Downloads JRCFIB2022M_JRC2018M and JRC2018U_JRC2018M h5 deformation fields (~3 GB total) from figshare. Only needs to be run once; the download is resumable and will skip files already present. Calls `mcns_register_xforms2` automatically after downloading. ```APIDOC ## mcns_download_xforms2() ### Description Downloads JRCFIB2022M_JRC2018M and JRC2018U_JRC2018M h5 deformation fields (~3 GB total) from figshare. Only needs to be run once; the download is resumable and will skip files already present. Calls `mcns_register_xforms2` automatically after downloading. ### Usage ```r mcns_download_xforms2() ``` ### Arguments None. ### Value No explicit return value documented. ### Examples ```r if (FALSE) { # \dontrun{ # first time only mcns_download_xforms2() # then once per session mcns_register_xforms2() xform_brain(cbind(100000, 100000, 50000), sample='malecns', reference='JRC2018U') } # } ``` ``` -------------------------------- ### Run malecns functions with dataset selection Source: https://natverse.org/malecns/reference/malecns-package.html Demonstrates using dr_malecns(), with_mcns(), choose_mcns_dataset(), and mcns_body_annotations() to run code against different datasets. Includes expert use of editing .Rprofile. ```r if (FALSE) { # \dontrun{ dr_malecns() # run expression without changing default malecns dataset with_mcns(mcns_body_annotations(194965), dataset = "male-cns:v1.0") # run expression(s) after changing default malecns dataset choose_mcns_dataset("male-cns:v1.0") mcns_body_annotations(194965) choose_mcns_dataset("CNS") mcns_body_annotations(194965) # edit .Rprofile to set package options (expert use) usethis::edit_r_profile() } # } ``` -------------------------------- ### Switch malecns dataset with choose_mcns_dataset() Source: https://natverse.org/malecns/index.html Switch between the production dataset (CNS) and the public snapshot (male-cns:v1.0) in the current session with choose_mcns_dataset(), then query body annotations. To permanently set the dataset, place options(malecns.dataset = 'CNS') in your .RProfile. ```r choose_mcns_dataset("CNS") mcns_body_annotations(194965) choose_mcns_dataset("male-cns:v1.0") mcns_body_annotations(194965) ``` ```r options(malecns.dataset = 'CNS') ``` -------------------------------- ### Register and download malecns h5 bridging registrations Source: https://natverse.org/malecns/reference/mcns_register_xforms2.html Call mcns_register_xforms2() once per session to register Saalfeld lab h5 deformation fields (JRCFIB2022M, JRC2018M, JRC2018U) and add a malecns (nm) to JRCFIB2022M (microns) scaling alias. mcns_download_xforms2() downloads the required h5 files (~3 GB total) from figshare; it is resumable and skips already present files, and it automatically calls mcns_register_xforms2() after downloading. ```r mcns_register_xforms2() mcns_download_xforms2() ```