表达矩阵任意两个基因相关性分析 批量相关性分析 tcga geo 矩阵中相关性强的基因对 基因相关性 ecm matrisome与gpx3

使用场景

  • 1.已经确定研究的基因,但是想探索他潜在的功能,可以通过跟这个基因表达最相关的基因来反推他的功能,这种方法在英语中称为guilt of association,协同犯罪

  • 2.我们的注释方法依赖于TCGA大样本,既然他可以注释基因,那么任何跟肿瘤相关的基因都可以被注释,包括长链非编码RNA

下面操作开始:

1.加载已经整理好的癌症数据

 
  1. load(file = "exprSet_arrange.Rdata")

  2. exprSet[1:3,1:3]

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

2.批量相关性分析

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

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

查看这个数据结构

 
  1. head(cor_data_df)

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")

负相关的选取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")

我们还可以用cowplot拼图

 
  1. library(cowplot)
    
    p1 <- ggscatterstats(data = exprSet,
    
                  y = PDCD1,
    
                  x = IL2RG,
    
                  centrality.para = "mean",                              
    
                  margins = "both",                                        
    
                  xfill = "#CC79A7",
    
                  yfill = "#009E73",
    
                  marginal.type = "histogram",
    
                  title = "Relationship between PDCD1 and IL2RG")
    
    
    
    p2 <- ggscatterstats(data = exprSet,
    
                  y = PDCD1,
    
                  x = MARK1,
    
                  centrality.para = "mean",                              
    
                  margins = "both",                                        
    
                  xfill = "#CC79A7",
    
                  yfill = "#009E73",
    
                  marginal.type = "histogram",
    
                  title = "Relationship between PDCD1 and IL2RG")
    
    plot_grid(p1,p2,nrow = 1,labels = LETTERS[1:2])

setwd("/home/data/t040413/ipf/gse135893_20_PF_10_control_scRNAseq")
getwd()

#install.packages("ggside")  #.libPaths(c("/home/data/t040413/R/yll/usr/local/lib/R/site-library",  "/home/data/t040413/R/x86_64-pc-linux-gnu-library/4.2", "/usr/local/lib/R/library"))

.libPaths(c("/home/data/t040413/R/yll/usr/local/lib/R/site-library",  "/home/data/t040413/R/x86_64-pc-linux-gnu-library/4.2", "/usr/local/lib/R/library"))
library(ggstatsplot)

load("/home/data/t040413/ipf/gse135893_20_PF_10_control_scRNAseq/mydata_for_gpx3_ecm_association.rds")

head(mydata)

ggscatterstats(data =mydata,
               y = ECM_Score,
               x = GPX3,
               centrality.para = "mean", 
               margins = "both",
               xfill = "#CC79A7",
               yfill = "#009E73",
               marginal.type = "histogram",
               title = "Relationship between GPX3 and ECM_Score from fibroblasts in GSE135895")
.libPaths(c("/home/data/refdir/Rlib",
            "/home/data/t040413/R/x86_64-pc-linux-gnu-library/4.2",
            "/usr/local/lib/R/library"))

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")

 这是气泡图

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

这时候,我们能推断PDCD1这个基因主要参与T细胞激活,细胞因子受体活性调剂等功能,大致跟她本身的功能是一致的。 

这种方法,即使是非编码基因也可以注释出来,想到长链非编码基因的数量,真是钱途无量。

 

欢迎关注微信:生信小博士 

  • 0
    点赞
  • 57
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

生信小博士

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值