iTALK---單細(xì)胞受配體互作分析及可視化(詳細(xì)版教程)

今天我們說一說另外一種---iTALK,iTALK也在很多文章中出現(xiàn)過,原理是基于受配體平均表達(dá)量。它有兩個(gè)優(yōu)點(diǎn),第一是可以比較差異受配體,第二是可視化比較好,我們可以借用借用它的函數(shù),讓自己的結(jié)果更加完美!詳細(xì)版注釋代碼以及使用的數(shù)據(jù)已上傳QQ群文件,更多精彩內(nèi)容請(qǐng)至我的公眾號(hào)---KS科研分享與服務(wù)!iTALK的文章連接如下:https://www.biorxiv.org/content/10.1101/507871v1包的地址:https://github.com/Coolgenome/iTALK首先安裝包。

if(!require(devtools)) install.packages("devtools");
devtools::install_github("Coolgenome/iTALK", build_vignettes = TRUE)
library(circlize)
library(iTALK)

構(gòu)建數(shù)據(jù)、設(shè)置細(xì)胞及分組,設(shè)置顏色,尋找高變基因!


human_data <- readRDS("D:/cellinter-celldb/human_data.rds")
exp <- as.data.frame(t(as.matrix(human_data@assays$RNA@counts)))
exp$cell_type <- human_data@meta.data$celltype
exp$compare_group <- human_data@meta.data$group
length(unique(human_data$celltype))
# [1] 5
highly_exprs_genes<-rawParse(exp,top_genes=25,stats='mean')
comm_list<-c('growth factor','other','cytokine','checkpoint')
cell_col<-structure(c("#B17BA6", "#FF7F00", "#FDB462", "#E7298A", "#E78AC3"),names=unique(exp$cell_type))

接下來進(jìn)行分析,并對(duì)每種類型的互作進(jìn)行可視化:

par(mfrow=c(1,2))
res<-NULL

for(comm_type in comm_list){
  res_cat<-FindLR(highly_exprs_genes,datatype='mean count',comm_type=comm_type)
  res_cat<-res_cat[order(res_cat$cell_from_mean_exprs*res_cat$cell_to_mean_exprs,decreasing=T),]
  NetView(res_cat,col=cell_col,vertex.label.cex=1,arrow.width=1,edge.max.width=5)
  LRPlot(res_cat[1:20,],datatype='mean count',cell_col=cell_col,link.arr.lwd=res_cat$cell_from_mean_exprs[1:20],link.arr.width=res_cat$cell_to_mean_exprs[1:20])
  title(comm_type)
  res<-rbind(res,res_cat)
}
image.png

最后可視化一下整體的互作效果,有互作圖和受配體弦圖兩種形式。

res<-res[order(res$cell_from_mean_exprs*res$cell_to_mean_exprs,decreasing=T),]
NetView(res,col=cell_col,vertex.label.cex=1,arrow.width=1,edge.max.width=5)

image.png

iTALK::LRPlot(res[1:20,],
       datatype='mean count',
       link.arr.lwd=res$cell_from_mean_exprs[1:20],
       link.arr.width=res$cell_to_mean_exprs[1:20])
image.png

當(dāng)然了,我們也提到,iTALK可以做組間差異比較,可能是由于我的數(shù)據(jù)隨意構(gòu)建吧,沒有差異,這里就不展示了,感興趣的可跟著作者的數(shù)據(jù)學(xué)習(xí)。

#######------------------兩組間顯著的配體-受體對(duì)---------------------------------

# # randomly assign the compare group to each sample
# data<-data %>% mutate(compare_group=sample(2,nrow(data),replace=TRUE))
# # find DEGenes of regulatory T cells and NK cells between these 2 groups
# deg_t<-DEG(data %>% filter(cell_type=='regulatory_t'),method='Wilcox',contrast=c(2,1))
# deg_nk<-DEG(data %>% filter(cell_type=='cd56_nk'),method='Wilcox',contrast=c(2,1))
# # find significant ligand-receptor pairs and do the plotting
# par(mfrow=c(1,2))
# res<-NULL
# for(comm_type in comm_list){
#   res_cat<-FindLR(deg_t,deg_nk,datatype='DEG',comm_type=comm_type)
#   res_cat<-res_cat[order(res_cat$cell_from_logFC*res_cat$cell_to_logFC,decreasing=T),]
#   #plot by ligand category
#   if(nrow(res_cat)==0){
#     next
#   }else if(nrow(res_cat>=20)){
#     LRPlot(res_cat[1:20,],datatype='DEG',cell_col=cell_col,link.arr.lwd=res_cat$cell_from_logFC[1:20],link.arr.width=res_cat$cell_to_logFC[1:20])
#   }else{
#     LRPlot(res_cat,datatype='DEG',cell_col=cell_col,link.arr.lwd=res_cat$cell_from_logFC,link.arr.width=res_cat$cell_to_logFC)
#   }
#   NetView(res_cat,col=cell_col,vertex.label.cex=1,arrow.width=1,edge.max.width=5)
#   title(comm_type)
#   res<-rbind(res,res_cat)
# }

###https://github.com/Coolgenome/iTALK/blob/master/example/example_code.r

到這里還沒有結(jié)束,我非??春胕TALK種的LRPlot函數(shù),不僅可視化了細(xì)胞之間的關(guān)系,還展示了具體的受配體,這樣的圖形一目了然。之間我們?cè)赾ellchat及cellphonedb種沒有這樣的可視化,這里我們使用cellchat的數(shù)據(jù),也可以利用iTALK這個(gè)包的函數(shù)做很好的可視化!


setwd("D:/KS項(xiàng)目/公眾號(hào)文章/iTalk_細(xì)胞互作")
A <- read.csv("net_inter.csv", header = T)
A<-A[order(A$cell_from_mean_exprs*A$cell_to_mean_exprs,decreasing=T),]

設(shè)置受配體及細(xì)胞顏色。


gene_col<-structure(c(rep('#CC3333',length(A[1:40,]$ligand)),
                      rep("#006699",length(A[1:40,]$receptor))),
                    names=c(A[1:40,]$ligand,
                            A[1:40,]$receptor))

cell_col <- structure(c("#DC050C", "#FB8072", "#1965B0", "#7BAFDE", "#882E72",
                        "#B17BA6", "#FF7F00", "#FDB462", "#E7298A", "#E78AC3",
                        "#33A02C", "#B2DF8A", "#55A1B1"),
                      names=unique(A$cell_from))

作圖:


iTALK::LRPlot(A[1:40,],
              datatype='mean count',
              link.arr.lwd=A$cell_from_mean_exprs[1:40],
              link.arr.width=0.1,
              link.arr.col = 'grey20',#連線顏色設(shè)置
              print.cell = T,
              track.height_1=uh(1, "mm"),
              track.height_2 = uh(15, "mm"),
              text.vjust = "0.5cm",
              gene_col = gene_col,
              cell_col = cell_col)
image.png

效果還是很好的,用在論文中也是挺吸引人的,對(duì)于結(jié)果的解讀也是更加清晰。覺得小編分享有用的,點(diǎn)個(gè)贊、分享一下唄!更多精彩內(nèi)容請(qǐng)至我的公眾號(hào)---KS科研分享與服務(wù)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容