library(GSVA)
library(tidyverse)
library(KEGGREST)
## demo of kegg info downloading -----
<- KEGGREST::keggList("pathway", "mmu")
pth_id <- list()
kegg_info_lst for(idx in 241:length(pth_id)) {
= KEGGREST::keggGet(names(pth_id)[idx])[[1]]
lst1 if("GENE" %in% names(lst1)) {
<- lst1$GENE |> grep("^[A-Z]+", ., value = T) |>
str1 str_split("; ", simplify = T) |> as.data.frame() |>
::rename("gene_name" = "V1", "description" = "V2")
dplyr<- lst1$GENE |> grep("^[0-9]+", ., value = T)
str2 names(pth_id)[idx]]] <-
kegg_info_lst[[data.frame(path_id = names(pth_id)[idx], path_name = pth_id[idx]) |>
data.frame(., str1)
}
}= kegg_info_lst |> bind_rows() |>
kegg_pth_info mutate(path_name = case_when(grepl("Mus mus", path_name) ~ str_sub(path_name, end = -30),
TRUE ~ path_name))
write_csv(kegg_pth_info, "kegg_mmu_all_pth_genes.csv")
## read the kegg pathway info and perform ssGSEA -----
<- read_csv("kegg_mmu_all_pth_genes.csv")
kegg_info <- lapply(unique(kegg_info$pth_name), function(x) {
kegg_lst |> dplyr::filter(pth_name == x) |> pull(gene_name)
kegg_info |> setNames(nm = unique(kegg_info$pth_name))
})
<- "st_seu_obj.rds"
rds_fn4 <- read_rds(rds_fn4)
seu_lst <- lapply(names(seu_lst), function(nm) {
ssgsea_score <- seu_lst[[nm]]
seu2 <- JoinLayers(seu2[["Spatial"]]) |> LayerData(layer = "counts") |> as.matrix()
cnt <- GSVA::ssgseaParam(cnt, kegg_lst)
ssgsea_param <- GSVA::gsva(ssgsea_param)
ssgsea_score |> setNames(nm = names(seu_lst))
}) write_rds(ssgsea_score, "ssgsea_score_lst.rds")
7 Functional evaluation with ST data
7.1 Functional evaluation
Pathway information was retrieved from the KEGG database (v110.0) using the KEGGREST
package (v1.46.0). Single-sample gene set enrichment analysis (ssGSEA), implemented in the GSVA
package (v1.52.3), was performed to estimate functional profiles at each spot.