View source: R/Visualizations_SDA.R
plot_component_ridge | R Documentation |
This function creates a ridge plot to visualize the distribution of component scores split by a specified metadata feature.
plot_component_ridge(
scores_matrix,
meta_df,
component,
meta_feature,
title = "Ridge Plot of Component Scores"
)
scores_matrix |
A numeric matrix where rows are samples (with rownames) and columns are components. |
meta_df |
A data frame with rownames matching those in 'scores_matrix' and containing metadata features. |
component |
Integer or character. The component column (e.g., '"Component_1"') to visualize. |
meta_feature |
Character. The metadata column to split the ridge plot by (e.g., '"seqrun"'). |
title |
Character. Plot title (default: '"Ridge Plot of Component Scores"'). |
A ggplot object displaying the ridge plot.
## Not run:
if(requireNamespace("ggplot2", quietly = TRUE) && requireNamespace("ggridges", quietly = TRUE)) {
# Example scores matrix
scores <- matrix(rnorm(500), nrow = 100, ncol = 5)
rownames(scores) <- paste0("Sample", 1:100)
colnames(scores) <- paste0("Component_", 1:5)
# Example metadata dataframe
meta <- data.frame(
seqrun = sample(c("Run1", "Run2", "Run3"), 100, replace = TRUE),
InfectionGroup = sample(c("Control", "Infected"), 100, replace = TRUE),
MonkeyName = sample(LETTERS[1:5], 100, replace = TRUE),
TreatmentCode = sample(c("A", "B", "C"), 100, replace = TRUE),
PD1status = sample(c("High", "Low"), 100, replace = TRUE),
row.names = rownames(scores)
)
# Generate ridge plot for Component 1 split by seqrun
plot_component_ridge(scores, meta, component = "Component_1", meta_feature = "seqrun")
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.