fix_clusters: fix_clusters

View source: R/fix_clusters.R

fix_clustersR Documentation

fix_clusters

Description

Function to iteratively update an intially clustering, greedily maximising the BAPS marginal likelihood.

Usage

fix_clusters(sparse.data, clusters, n.iterations = 1, quiet = FALSE)

Arguments

sparse.data

a sparse SNP data object returned from import_fasta_sparse_nt

clusters

the initial clustering to be improved. Given as a vector of cluster memberships (1 to n.cluster) of length equal to the number of sequences

n.iterations

the number of greedy maximisation iterations to perform

quiet

whether or not to print the improvements in the likelihood at each step (default=FALSE)

Value

a final clustering

Examples


## Not run: 
fasta.file.name <- system.file("extdata", "seqs.fa", package = "fastbaps")
sparse.data <- import_fasta_sparse_nt(fasta.file.name)
sim.matrix <- snp_similarity(sparse.data)
x <- as.dist(1-sim.matrix/max(sim.matrix))
phylo <- ape::as.phylo(hclust(x, method="average"))
clusters <- best_baps_partition(sparse.data, phylo)
clusters <- fix_clusters(sparse.data, clusters)

## End(Not run)


gtonkinhill/fastbaps documentation built on Sept. 25, 2022, 1:56 p.m.