Code
# Read data from the supplementary Excel file
data <- readxl::read_xlsx("rawdata/pan-cancer-immune-pathways.xlsx", skip = 1L)
#> New names:
#> • `` -> `...3`
#> • `` -> `...5`
#> • `` -> `...7`
#> • `` -> `...9`
#> • `` -> `...11`
#> • `` -> `...13`
#> • `` -> `...15`
#> • `` -> `...17`
#> • `` -> `...19`
#> • `` -> `...21`
#> • `` -> `...23`
#> • `` -> `...25`
#> • `` -> `...27`
#> • `` -> `...29`
#> • `` -> `...31`
#> • `` -> `...33`
#> • `` -> `...35`
#> • `` -> `...37`
#> • `` -> `...39`
#> • `` -> `...41`
#> • `` -> `...43`
#> • `` -> `...45`
#> • `` -> `...47`
#> • `` -> `...49`
#> • `` -> `...51`
set.seed(3L)
# Randomly select 5 pathways (rows 2–18 cover the main data)
selected <- sample(2:18, 5)
# Extract logFC and adjusted p-values for the selected pathways
logFC <- data[selected, c(1, which(as.character(data[1, ]) == "logFC"))]
adj.P <- data[selected, c(1, which(as.character(data[1, ]) == "adj.P"))]
names(adj.P) <- names(logFC)
# Convert to numeric matrix: pathways as columns, tumor as rows
logFC <- dplyr::mutate(logFC, dplyr::across(!pathway, as.numeric)) |>
tibble::column_to_rownames(var = "pathway") |>
as.matrix() |>
t()
adj.P <- dplyr::mutate(adj.P, dplyr::across(!pathway, as.numeric)) |>
tibble::column_to_rownames(var = "pathway") |>
as.matrix() |>
t()