plot.InteractionClassification {qvirus}R Documentation

Plot InteractionClassification Clusters

Description

This function visualizes the clusters formed by the InteractionClassification object. It displays the viral load differences (vl_diff) and CD4 count differences (cd_diff) as points, with each point color-coded by its cluster. Cluster centers are shown as red stars.

Usage

## S3 method for class 'InteractionClassification'
plot(
  x,
  plot_clusters = TRUE,
  evaluate_clusters = FALSE,
  max_clusters = 10,
  n_clusters = 4,
  ...
)

Arguments

x

An object of class InteractionClassification created using the InteractionClassification() function. It contains the clustering results and cluster centers.

plot_clusters

Logical. If TRUE, plots the cluster visualization. Default is TRUE.

evaluate_clusters

Logical. If TRUE, plots the WSS to evaluate the optimal number of clusters. Default is FALSE.

max_clusters

Integer. The maximum number of clusters to evaluate if evaluate_clusters is set to TRUE. Default is 10.

n_clusters

Integer. The number of clusters to suggest when plotting the elbow method. It determines where the vertical line (xintercept) is drawn in the plot. Default is 4.

...

Additional arguments (currently unused).

Details

Additionally, it can evaluate the optimal number of clusters using the elbow method by plotting the within-cluster sum of squares (WSS) using fviz_nbclust.

Value

A ggplot object that visualizes the clusters and their centers, or the WSS plot to evaluate the optimal number of clusters.

Examples

data(vl_3)
data(cd_3)
interaction_obj <- create_interactions(cd_3[,-1], vl_3[,-1])
class_obj <- InteractionClassification(interaction_obj$vlogs_diff, interaction_obj$cds_diff)
plot(class_obj)

[Package qvirus version 0.0.3 Index]