1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| dat <- read.table('string_interactions.tsv', header = T) names(dat)[c(1,2)] <- c('Sourse', 'Target') dat <- dat[c('Sourse', 'Target', 'combined_score')] all <- unique(c(dat$Sourse,dat$Target)) Adj <- matrix(nrow = length(all),ncol = length(all), data = 0) rownames(Adj) <- all colnames(Adj) <- all for(i in 1:nrow(dat)){ s <- dat[i,'Sourse'] t <- dat[i,'Target'] w <- dat[i,'combined_score'] Adj[s,t] <- w Adj[t,s] <- w } tmp <- rowSums(Adj) tmp <- data.frame(tmp) tmp$symbol <- rownames(tmp) tmp <- tmp[order(tmp$tmp,decreasing = T),] hub <- tmp[1:200,'symbol'] hub_Adj <- Adj[hub,hub]
|