YuLab-SMU / SVP

GNU General Public License v3.0
5 stars 0 forks source link

the tissue image can also be visualized by plot_point_features #1

Closed xiangpin closed 8 months ago

xiangpin commented 1 year ago
library(SpatialExperiment)
library(STexampleData)
library(scran)
library(nnSVG)
library(tidyverse)
library(msigdbr)
library(GSVA)
library(GSEABase)
library(SVP)

# 下载空转数据
# 数据说明:
# http://www.bioconductor.org/packages/devel/data/experiment/vignettes/STexampleData/inst/doc/STexampleData_overview.html#visium_humandlpfc
#load("Visium_mouseCoronal.RData")
spe <- Visium_mouseCoronal()

# 数据过滤
# 挑选切片上的数据
spe <- spe[, colData(spe)$in_tissue == 1]

# 过滤低表达量的基因
spe <- filter_genes(spe)

# 表达量标准化
spe <- computeLibraryFactors(spe)
spe <- logNormCounts(spe)

# 查看现在有哪些表达值
assayNames(spe)

spe

# 提取GSVA的基因集:GO,KEGG
KEGG_df_all <-  msigdbr(species = "Mus musculus", # Homo sapiens or Mus musculus
                        category = "C2",
                        subcategory = "CP:KEGG")
KEGG_df <- dplyr::select(KEGG_df_all,gs_name,gs_exact_source,ensembl_gene)
kegg_list <- split(KEGG_df$ensembl_gene, KEGG_df$gs_name)

#####
#####
# 这块的分析来自SVP包。

xx <- svp(spe, kegg_list, assayName = "logcounts", threads = 5, gsva.method = 'gsva')

res <- gsvaExp(xx)

features <- rowData(res) |> data.frame() %>% dplyr::arrange(rank) %>% rownames() %>% head(12)

p1 <- plot_point_features(res, assayName = 1, features = NULL, image.plot = TRUE)
p2 <- plot_point_features(res, assayNames = 1, features = NULL, image.plot = FALSE)
p3 <- plot_point_features(res, assayName = 1, features = NULL, image.plot = TRUE, remove.point = TRUE)
p4 <- plot_point_features(res, assayName = 1, features = features[1], image.plot = FALSE)
p5 <- plot_point_features(res, assayName = 1, features = features[1], image.plot = TRUE)

aplot::plot_list(p1, p2, p3, p4, p5, nrow = 1)

image

GuangchuangYu commented 1 year ago

画图可以用ggsc来画,拓展一下,来支持bioconductor的对象。

xiangpin commented 1 year ago

好的,我后续用S4方法重新组织下ggsc