View source: R/EnrichmentSpiralize.R
extract_ntop_pathways | R Documentation |
This function processes a dataframe containing SSGSEA KEGG results. It allows specifying the number of top pathways to extract for each sample based on their scores, and stores these in a new dataframe with sample names and pathway scores.
extract_ntop_pathways(ssgsea_kegg, nTop = 5)
ssgsea_kegg |
Dataframe containing SSGSEA KEGG results with samples as columns and pathways as rows. |
nTop |
Integer, number of top pathways to select for each sample. |
A dataframe with columns 'Pathway', 'Sample', and 'Value' representing the top pathways for each sample.
# Example: Generating input data for the extract_ntop_pathways function
# Define example pathways
pathways <- c("Pathway_A", "Pathway_B", "Pathway_C", "Pathway_D", "Pathway_E",
"Pathway_F", "Pathway_G", "Pathway_H", "Pathway_I", "Pathway_J")
# Define example samples
samples <- c("Sample_1", "Sample_2", "Sample_3")
# Generate random SSGSEA KEGG scores between 0 and 1
set.seed(123) # For reproducibility
ssgsea_scores <- matrix(runif(length(pathways) * length(samples), min = 0, max = 1),
nrow = length(pathways), ncol = length(samples),
dimnames = list(pathways, samples))
# Convert to a data frame
ssgsea_kegg <- as.data.frame(ssgsea_scores)
# Extract the top 3 pathways for each sample
top_pathways <- extract_ntop_pathways(ssgsea_kegg, nTop = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.