groupSamples: Performs community detection on sample-sample distance matrix...

View source: R/functions-core.R

groupSamplesR Documentation

Performs community detection on sample-sample distance matrix to identify groups of similar samples

Description

Takes sample-sample distance matrix as input and returns group assignments for each sample

Usage

groupSamples(
  distmat,
  distfun = "hclust",
  ncluster = NULL,
  method = "complete",
  ...
)

Arguments

distmat

A distance matrix of dimension num_samples x num_samples representing pairwise dissimilarity between samples

distfun

Method of partitioning network of samples (currently either 'hclust' or 'pam')

ncluster

Optional parameter specifying total number of sample groups

method

Optional parameter for hierarchical clustering (see "hclust" documentation)

...

Optional additional parameters to be passed to diffusionKmeans method

Details

By default, uses 'kgs' (Kelley-Gardner-Sutcliffe) method for determining optimal number of groups. Alternatively, can take user-specified number of groups). Requires 'cluster' and 'maptree' packages.

Value

Vector containing group assignments for each sample (same order as row-order of distmat) based on user-specified partitioning method (e.g. hierarchical clustering)

Examples


my_phemdObj <- createDataObj(all_expn_data, all_genes, as.character(snames_data))
my_phemdObj_lg <- removeTinySamples(my_phemdObj, 10)
my_phemdObj_lg <- aggregateSamples(my_phemdObj_lg, max_cells=1000)
my_phemdObj_monocle <- embedCells(my_phemdObj_lg, cell_model = 'monocle2', data_model = 'gaussianff', sigma=0.02, maxIter=2)
my_phemdObj_monocle <- orderCellsMonocle(my_phemdObj_monocle)
my_phemdObj_final <- clusterIndividualSamples(my_phemdObj_monocle)
my_phemdObj_final <- generateGDM(my_phemdObj_final)
my_EMD_mat <- compareSamples(my_phemdObj_final)
cluster_assignments <- groupSamples(my_EMD_mat, distfun = 'hclust', ncluster=4)


wschen/phemd documentation built on Oct. 1, 2024, 4:45 a.m.