#在string網(wǎng)絡(luò)中取差異基因的一步鄰居
DEGs<-read.delim(file.choose(),header=T,sep="\t") #file=1.7-protein_coding_?.txt
pc<-DEGs[DEGs$Gene.type=='protein_coding',][,1]
head(pc)
#如果是list,取鄰居報(bào)錯(cuò)
typeof(pc);pc<-as.vector(unlist(pc));length(pc)
#自定義取一鄰居函數(shù)
getneighbor<-function(gene,net){
neighbor=c()
for (i in gene){
neighbor=c(neighbor,which(net[i,]>0))
}
neighbor=colnames(net)[unique(neighbor)]
}
library(igraph)
string<-read.table(file.choose(),header=F,sep="\t") # file=string_700_si.txt
g<-graph.data.frame(string,directed = F)
#g<-simplify(g0)
net<-get.adjacency(g)
nodes<-1:nrow(net)
names(nodes)<-rownames(net)
#在PPI中的DEGs
PPI_pc<-intersect(names(nodes),pc);length(PPI_pc)
write.table(paste('PCgene_in_net','Neighbor',sep = '\t'),"8.1-CC_pc-edges_0.05_2.txt",append=T,row.names=F,col.names = F,quote = F)
for (i in 1:length(PPI_pc)) {
Nei=getneighbor(c(PPI_pc[i]),net)
write.table(paste(PPI_pc[i],Nei,sep = '\t'),"8.1-CC_pc-edges_0.05_2.txt",append=T,row.names=F,col.names = F,quote = F)
}
Nei<-getneighbor(PPI_pc,net);length(Nei)
wgcna<-union(pc,Nei);length(wgcna)
wgcna<-as.matrix(wgcna);colnames(wgcna)<-'W_gene';head(wgcna)
#WGCNA matrix
matrix<-read.table(file = file.choose(),header = T,sep = '\t')
head(matrix)
co_expression<-merge(wgcna,matrix,by.x = 'W_gene',by.y = 'Symbol')
head(co_expression);dim(co_expression)
write.table(co_expression,"6-CC_PPI_WGCNA.txt",row.names = F,quote = F,sep="\t")
WGCNA衍生:差異基因取一步鄰居(蛋白互作)
?著作權(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),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。