extract_positive_pathways: Extract Positive Pathways from SSGSEA Results and Select...

View source: R/EnrichmentSpiralize.R

extract_positive_pathwaysR Documentation

Extract Positive Pathways from SSGSEA Results and Select Random Samples

Description

This function processes the results of SSGSEA, specifically focusing on KEGG pathways. It extracts pathways with positive values from each sample and randomly selects a subset of them.

Usage

extract_positive_pathways(ssgsea_kegg, max_paths_per_sample = 5)

Arguments

ssgsea_kegg

A matrix or data frame with pathways as rows and samples as columns.

max_paths_per_sample

Integer, maximum number of pathways to select per sample.

Value

A data frame with selected pathways, samples, and their corresponding values.

Examples

# Example: Generating input data for the extract_positive_pathways function

# Define example pathways
pathways <- c("Pathway_1", "Pathway_2", "Pathway_3", "Pathway_4", "Pathway_5",
              "Pathway_6", "Pathway_7", "Pathway_8", "Pathway_9", "Pathway_10")

# Define example samples
samples <- c("Sample_A", "Sample_B", "Sample_C")

# Generate random SSGSEA KEGG scores including both positive and negative values
set.seed(456)  # For reproducibility
ssgsea_scores <- matrix(rnorm(length(pathways) * length(samples), mean = 0, sd = 1),
                        nrow = length(pathways), ncol = length(samples),
                        dimnames = list(pathways, samples))

# Convert to a data frame
ssgsea_kegg <- as.data.frame(ssgsea_scores)

# Use the extract_positive_pathways function to extract up to 3 positive pathways per sample
selected_positive_pathways <- extract_positive_pathways(ssgsea_kegg, max_paths_per_sample = 3)


TransProR documentation built on April 4, 2025, 3:16 a.m.