From an object fit, clusters (all or some) can be renamed. This changes the names inside the VIBER object, affecting plots and all other outputs. This function can be used after clusters have been given some interpretation, e.g., cluster "C1" is the "Clonal" cluster for instance.

rename_clusters(x, new_labels)

Arguments

x

A VIBER fit object.

new_labels

A named vector representing a new names map. For instance c(`C1`=`Clonal`, `C2` = `Subclonal`) renames two clusters "C1" and "C2" as "Clonal" and "Clonal" respectively.

Value

A VIBER fit object with renamed clusters.

Examples

data(mvbmm_example)
x = variational_fit(mvbmm_example$successes, mvbmm_example$trials)
#>  [ VIBER - variational fit ] 
#> 
#>  Input n = 231, with k < 10. Dirichlet concentration α = 1e-06.
#>  Beta (a_0, b_0) = (1, 1); q_i = prior. Optimise: ε = 1e-10 or 5000 steps, r = 10 starts.
#> 
#>  VIBER fit completed in 0.1 mins (status: converged)
#> 
#> ── [ VIBER ] My VIBER model n = 231 (w = 2 dimensions). Fit with k = 10 clusters
#> • Clusters: π = 45% [C1], 28% [C3], 20% [C4], and 7% [C5], with π > 0.
#> • Binomials: θ = <0.5, 0.49> [C1], <0, 0.2> [C3], <0.25, 0.25> [C4], and <0.22,
#> 0> [C5].
#>  Score(s): ELBO = -47073.318. Fit converged in 21 steps, ε = 1e-10.
print(x)
#> ── [ VIBER ] My VIBER model n = 231 (w = 2 dimensions). Fit with k = 10 clusters
#> • Clusters: π = 45% [C1], 28% [C3], 20% [C4], and 7% [C5], with π > 0.
#> • Binomials: θ = <0.5, 0.49> [C1], <0, 0.2> [C3], <0.25, 0.25> [C4], and <0.22,
#> 0> [C5].
#>  Score(s): ELBO = -47073.318. Fit converged in 21 steps, ε = 1e-10.

x_renamed = rename_clusters(x, c(`C1`=`Clonal`, `C2` = `Subclonal`))
#> 
#> ── Renaming VIBER clusters C1, C2, C3, C4, C5, C6, C7, C8, C9, and C10 for the i
#> 
#> ── [ VIBER ] My VIBER model n = 231 (w = 2 dimensions). Fit with k = 10 clusters
#> • Clusters: π = 45% [C1], 28% [C3], 20% [C4], and 7% [C5], with π > 0.
#> • Binomials: θ = <0.5, 0.49> [C1], <0, 0.2> [C3], <0.25, 0.25> [C4], and <0.22,
#> 0> [C5].
#>  Score(s): ELBO = -47073.318. Fit converged in 21 steps, ε = 1e-10.
#> Error in new_labels %>% names(): object 'Clonal' not found
print(x_renamed)
#> Error in print(x_renamed): object 'x_renamed' not found