Plot cosine clustering of neuprint/hemibrain neurons

  partners = c("inputs", "outputs"),
  threshold = 5,
  method = c("ward.D", "single", "complete", "average", "mcquitty", "median", "centroid",
  group = FALSE,
  labRow = "{type}",
  heatmap = FALSE,
  interactive = FALSE,
  nas = c("zero", "drop"),
  conn = NULL,



Query ids. May including searches in the style of neuprint_ids


Whether to cluster based on connections to input or output partner neurons (default both).


An integer threshold (connections >= this will be returned)


The cluster method to use (see hclust)


Whether to group by cell type or another named column.


A vector defining the row labels. If it is a character vector length 1 containing any curly braces it will be interpreted as a glue string for interpolation, using the data.frame returned by neuprint_get_meta as a source of information.


A logical indicating whether or not to plot the heatmap OR a function to plot the heatmap whose argument names are compatible with stats::heatmap. gplots::heatmap.2 is a good example. Defaults to TRUE therefore plotting the full heatmap with stats::heatmap.


Whether to plot an interactive heatmap (allowing zooming and id selection). See details.


What to do with entries that have NAs. Default is to set them to 0 similarity.


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 heatmap


The result of heatmap invisibly including the row and column dendrograms or, when heatmap=FALSE, a

stats::hclust object.


Note that when interactive=TRUE you must have external packages including InteractiveComplexHeatmap installed with the coconat package. If you are using Rstudio, we recommend using an external browser (e.g. Chrome) rather than the built-in browser, especially for larger heatmaps.


# \donttest{
neuprint_cosine_plot("/DA[1-3].*PN", partners='in')
#> Call:
#> hclust(d = as.dist(1 - x), method = method)
#> Cluster method   : ward.D 
#> Number of objects: 17 
# }
if (FALSE) {
# Considering all partners
neuprint_cosine_matrix("/lLN2.+", partners='in') %>% neuprint_cosine_plot()
# excluding the PN partners from the cosine distance score
neuprint_cosine_matrix("/lLN2.+", !grepl("PN",type), partners='in') %>% neuprint_cosine_plot()
# just use PN partners for cosine distance score
neuprint_cosine_matrix("/lLN2.+", grepl("PN",type), partners='in') %>% neuprint_cosine_plot()

# interactive heatmap allowing zooming and id selection
neuprint_cosine_plot("/lLN2.+",  partners='out', interactive=TRUE)