Predict the group of aedes neurons using type or group information
Source:R/predict-group.R
aedes_predict_group.RdReturns a numeric group id for each neuron, preferring its cell
type, then its curated group, then its NBLAST cluster and optionally its
own serial_id. This is
intended for grouping partner neurons in connectivity clustering, e.g. with
coconatfly::cf_cosine_plot().
Usage
aedes_predict_group(
x,
badtypes = c(NA, "", "undefined", "KCx", "LHN"),
singletons = FALSE
)Arguments
- x
A data.frame with
type,group,nblast_groupandserial_idcolumns, such as returned byaedes_meta()or a partner table fromcoconatfly::cf_partners()/coconatfly::multi_connection_table()(where these columns describe the partner neurons). Alternatively neuron ids in any form understood byaedes_meta().- badtypes
Values of the type column (after removing any trailing
?) that are too broad or uninformative to define a group.- singletons
Whether neurons without a type, group or NBLAST cluster should fall back to their own
serial_id(defaultFALSE, returningNA). Singleton groups keep connectivity to individual partner neurons (likegroup = FALSE) but can never match across hemispheres, so they tend to pull left/right homologues apart.
Value
A numeric vector of group ids with one element per row of x
(NA for ungroupable neurons unless singletons = TRUE).
Details
All returned ids are serial_id values, so they share one
namespace:
typed neurons get the smallest
serial_idamong the rows inxwith the same type (so type-derived ids depend on which rows are supplied). A trailing?is removed before grouping, so e.g.KC4?joinsKC4. Types listed inbadtypesare ignored.untyped neurons use their
groupcolumn (itself the smallestserial_idof the group's founding members, seeaedes_set_group()). Agroupof0is treated as ungrouped.neurons with no type or group use their
nblast_groupcluster when this has the formCNNNNNorNNNNN(whereNNNNNis the smallestserial_idin the cluster); any leadingCis dropped. Surrounding whitespace and a trailing?are ignored, so" C12345?"is read as12345. All othernblast_groupvalues are ignored, so a cluster can be struck out by prefixing it withX(e.g.XC12345) without deleting it.neurons with none of these get
NA, so that coconatfly drops them as partners, just as it does forgroup = "group". Whensingletons = TRUEthey instead fall back to their ownserial_id, i.e. each becomes a group of one.
Once register_aedes_coconat() has been called, coconatfly metadata for
aedes neurons includes the result as a pgroup column, so you can use
group = "pgroup" directly in coconatfly functions (see examples).
Examples
if (FALSE) { # \dontrun{
library(coconatfly)
x <- multi_connection_table(cf_ids(aedes = "/type:MBON.+"),
partners = c("in", "out"), threshold = 5, group = FALSE)
x$pgroup <- aedes_predict_group(x)
cf_cosine_plot(x, group = "pgroup")
# coconatfly metadata for aedes neurons already includes a pgroup column
cf_cosine_plot(cf_ids(aedes = "/type:MBON.+"), group = "pgroup")
} # }