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)A VIBER fit object with renamed clusters.
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.04 mins (status: converged)
#>
#> ── [ VIBER ] My VIBER model n = 231 (w = 2 dimensions). Fit with k = 10 clusters
#> • Clusters: π = 45% [C4], 28% [C3], 20% [C9], and 7% [C2], with π > 0.
#> • Binomials: θ = <0.5, 0.49> [C4], <0, 0.2> [C3], <0.25, 0.25> [C9], and <0.22,
#> 0> [C2].
#> ℹ Score(s): ELBO = -47073.328. 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% [C4], 28% [C3], 20% [C9], and 7% [C2], with π > 0.
#> • Binomials: θ = <0.5, 0.49> [C4], <0, 0.2> [C3], <0.25, 0.25> [C9], and <0.22,
#> 0> [C2].
#> ℹ Score(s): ELBO = -47073.328. Fit converged in 21 steps, ε = 1e-10.
# rename 6 clusters as new_C_1, new_C_2, ....
new_labels = paste0("new_C_", 1:6)
names(new_labels) = paste0("C", 1:6)
x_renamed = rename_clusters(x, new_labels)
#>
#> ── 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% [C4], 28% [C3], 20% [C9], and 7% [C2], with π > 0.
#> • Binomials: θ = <0.5, 0.49> [C4], <0, 0.2> [C3], <0.25, 0.25> [C9], and <0.22,
#> 0> [C2].
#> ℹ Score(s): ELBO = -47073.328. Fit converged in 21 steps, ε = 1e-10.
#> ! Cluster C7, C8, C9, and C10 are not going to be renamed.
#>
#> ── Renaming map
#>
#> C1 -> new_C_1
#> C2 -> new_C_2
#> C3 -> new_C_3
#> C4 -> new_C_4
#> C5 -> new_C_5
#> C6 -> new_C_6
#>
#> ── Renamed VIBER object
#>
#> ── [ VIBER ] My VIBER model n = 231 (w = 2 dimensions). Fit with k = 10 clusters
#> • Clusters: π = 45% [new_C_4], 28% [new_C_3], 20% [C9], and 7% [new_C_2], with
#> π > 0.
#> • Binomials: θ = <0.5, 0.49> [new_C_4], <0, 0.2> [new_C_3], <0.25, 0.25> [C9],
#> and <0.22, 0> [new_C_2].
#> ℹ Score(s): ELBO = -47073.328. Fit converged in 21 steps, ε = 1e-10.
print(x_renamed)
#> ── [ VIBER ] My VIBER model n = 231 (w = 2 dimensions). Fit with k = 10 clusters
#> • Clusters: π = 45% [new_C_4], 28% [new_C_3], 20% [C9], and 7% [new_C_2], with
#> π > 0.
#> • Binomials: θ = <0.5, 0.49> [new_C_4], <0, 0.2> [new_C_3], <0.25, 0.25> [C9],
#> and <0.22, 0> [new_C_2].
#> ℹ Score(s): ELBO = -47073.328. Fit converged in 21 steps, ε = 1e-10.