1.已经确定研究的基因,但是想探索他潜在的功能,可以通过跟这个基因表达最相关的基因来反推他的功能,这种方法在英语中称为guilt of association,协同犯罪。
    2.我们的注释方法依赖于TCGA大样本,既然他可以注释基因,那么任何跟肿瘤相关的基因都可以被注释,包括长链非编码RNA

    下面操作开始:
    1.加载已经整理好的癌症数据

    1. load(file = "exprSet_arrange.Rdata")
    2. exprSet[1:3,1:3]

    image.png
    这个数据依然是行是样本,列是基因。

    2.批量相关性分析
    将第一行目的基因跟其他行的编码基因批量做相关性分析,得到相关性系数以及p值 需要大概30s左右的时间。

    1. y <- as.numeric(exprSet[,"PDCD1"])
    2. colnames <- colnames(exprSet)
    3. cor_data_df <- data.frame(colnames)
    4. for (i in 1:length(colnames)){
    5. test <- cor.test(as.numeric(exprSet[,i]), y, type="spearman")
    6. cor_data_df[i,2] <- test$estimate
    7. cor_data_df[i,3] <- test$p.value
    8. }
    9. names(cor_data_df) <- c("symbol","correlation","pvalue")

    查看这个数据结构

    1. head(cor_data_df)

    image.png
    3.筛选最相关的基因
    筛选p值小于0.05,按照相关性系数绝对值选前500个的基因, 数量可以自己定

    1. library(dplyr)
    2. library(tidyr)
    3. cor_data_sig <- cor_data_df %>%
    4. filter(pvalue < 0.05) %>%
    5. arrange(desc(abs(correlation)))%>%
    6. dplyr::slice(1:500)

    4.随机选取正的和负的分别作图验证
    用到的方法在以前的图有毒系列里面图有毒系列之二
    正相关的选取IL2RG

    1. library(ggstatsplot)
    2. ggscatterstats(data = exprSet,
    3. y = PDCD1,
    4. x = IL2RG,
    5. centrality.para = "mean",
    6. margins = "both",
    7. xfill = "#CC79A7",
    8. yfill = "#009E73",
    9. marginal.type = "histogram",
    10. title = "Relationship between PDCD1 and IL2RG")

    image.png
    负相关的选取MARK1

    1. library(ggstatsplot)
    2. ggscatterstats(data = exprSet,
    3. y = PDCD1,
    4. x = MARK1,
    5. centrality.para = "mean",
    6. margins = "both",
    7. xfill = "#CC79A7",
    8. yfill = "#009E73",
    9. marginal.type = "histogram",
    10. title = "Relationship between PDCD1 and IL2RG")

    image.png
    我们还可以用cowplot拼图

    1. library(cowplot)
    2. p1 <- ggscatterstats(data = exprSet,
    3. y = PDCD1,
    4. x = IL2RG,
    5. centrality.para = "mean",
    6. margins = "both",
    7. xfill = "#CC79A7",
    8. yfill = "#009E73",
    9. marginal.type = "histogram",
    10. title = "Relationship between PDCD1 and IL2RG")
    11. p2 <- ggscatterstats(data = exprSet,
    12. y = PDCD1,
    13. x = MARK1,
    14. centrality.para = "mean",
    15. margins = "both",
    16. xfill = "#CC79A7",
    17. yfill = "#009E73",
    18. marginal.type = "histogram",
    19. title = "Relationship between PDCD1 and IL2RG")
    20. plot_grid(p1,p2,nrow = 1,labels = LETTERS[1:2])

    image.png
    5.下面进行功能富集分析
    既然确定了相关性是正确的,那么我们用我们筛选的基因进行富集分析就可以反推这个基因的功能

    1. library(clusterProfiler)
    2. #获得基因列表
    3. library(stringr)
    4. gene <- str_trim(cor_data_sig$symbol,'both')
    5. #基因名称转换,返回的是数据框
    6. gene = bitr(gene, fromType="SYMBOL", toType="ENTREZID", OrgDb="org.Hs.eg.db")
    7. go <- enrichGO(gene = gene$ENTREZID, OrgDb = "org.Hs.eg.db", ont="all")

    这里因为是计算的所有GO分析的三个分类,所以可以合并作图
    这是条形图

    1. barplot(go, split="ONTOLOGY") facet_grid(ONTOLOGY~., scale="free")

    image.png
    这是气泡图

    1. dotplot(go, split="ONTOLOGY") facet_grid(ONTOLOGY~., scale="free")

    image.png
    这时候,我们能推断PDCD1这个基因主要参与T细胞激活,细胞因子受体活性调剂等功能,大致跟她本身的功能是一致的。
    这种方法,即使是非编码基因也可以注释出来,想到长链非编码基因的数量。