hclustfc: Cluster a set of FlyCircuit neurons identified by gene_name

View source: R/clustering.R

hclustfcR Documentation

Cluster a set of FlyCircuit neurons identified by gene_name

Description

Given a vector of flycircuit gene/neuron names or neuronids use hclust to carry out a hierarchical clustering. The default value of distfun will handle square distance matrices and R dist objects. Note that hclustfc is a thin wrapper around the nhclust function and that is what you want to use if you have calculated a score matrix yourself e.g. for a set of all by all pairwise neurons similarities computed by nblast or nblast_allbyall.

Usage

hclustfc(
  gns,
  method = "ward",
  scoremat = getOption("flycircuit.scoremat"),
  unsquare = FALSE,
  distfun = as.dist,
  ...,
  maxneurons = 4000
)

Arguments

gns

FlyCircuit identifiers (passed to fc_gene_name).

method

clustering method (default Ward's).

scoremat

score matrix to use (see sub_score_mat for details of default).

unsquare

Whether to return the square root of the distance calculated by hclust (see details, default FALSE).

distfun

function to convert distance matrix returned by sub_dist_mat into R dist object (default= as.dist).

...

additional parameters passed to hclust.

maxneurons

set this to a sensible value to avoid loading huge (order N^2) distances directly into memory.

Details

when method is ward, ward.D or ward.D2 it may make sense to unsquare the resultant distance before plotting.

See Also

fc_gene_name, nhclust, hclust, dist, plot3d.hclust

Examples

data(kcs20, package='nat')
hckcs=hclustfc(names(kcs20))
# plot basic dendrogram
plot(hckcs)
# plot dendrogram using unsquared distance
plot(hclustfc(names(kcs20), unsquare=TRUE))
# divide hclust object into 3 groups
library(dendroextras)
plot(colour_clusters(hckcs, k=3))
# 3d plot of neurons in those clusters (with matching colours)
library(nat)
plot3d(hckcs, k=3, db=kcs20)
# names of neurons in 3 groups
subset(hckcs, k=3)

natverse/flycircuit documentation built on Jan. 26, 2023, 6:46 p.m.