source("https://bioconductor.org/biocLite.R")
biocLite("STRINGdb")
library(STRINGdb)
library(igraph)
g <- read.graph("karate.net", format="pajek")
d <- get.diameter(g)
L <- graph(n=9,c(1,4,2,4,3,4,4,5,5,6,6,7,7,8,8,9),directed=F)
plot(L, layout=layout.fruchterman.reingold, edge.arrow.mode="-", edge.width=2, vertex.label.cex=1.2)
g <- graph.empty (5, directed = FALSE)
new_edges <- c(1,3, 1,5, 2,5, 4,5)
g <- add.edges(g, new_edges)
plot(g)
library(igraph)
dat = as.matrix(read.table('/Users/lsy/Downloads/string_interactions.tsv',sep='\t',header = FALSE))
#dat = rbind(dat,c("BCAM","","0","0","9606.ENSP00000363071","0","0","0","0","0","0","0","0.0","0","0"))
edges = as.vector(t(dat[,1:2]))
g<-graph(edges, n=max(edges), isolates=c("BCAM"))
get.edgelist(g)
plot(g, layout = layout.fruchterman.reingold, vertex.label=V(g)$number,edge.arrow.size=0.5)
library(igraph)
dat = as.matrix(read.table('/Users/lsy/Downloads/string_interactions.tsv',sep='\t',header = FALSE))
edges = as.vector(t(dat[,1:2]))
net <- graph_from_data_frame(d=dat, vertices=unique(edges), directed=T)
plot(net, edge.arrow.size=.4,vertex.label=NA)
as_data_frame(net, what="edges")
as_data_frame(net, what="vertices")
plot(net, vertex.shape="none", vertex.label=names(V(net)),
vertex.label.font=2, vertex.label.color="gray40",
vertex.label.cex=.7, edge.color="gray85")
E(net)$color[E(net)$weight > 2] <- 'green'
plot.igraph(net,vertex.label=V(net)$name,layout=layout.fruchterman.reingold,edge.arrow.size=0.2,
vertex.label.color="gray40",edge.color="red",vertex.shape="none"
)
E(testgraph)$color <- as.factor(edges$department)
E(g)$lty[E(g)$weight == 8] <- 1
E(g)$color[E(g)$weight == 3] <- 'green'
E(g)$lty[E(g)$weight == 3] <- 2
library(igraph)
dat = as.matrix(read.table('/Users/lsy/Downloads/string_interactions.tsv',sep='\t',header = FALSE))
edges = as.vector(t(dat[,1:2]))
g<-graph(edges, n=max(edges), isolates=c("BCAM"), directed=FALSE)
E(g)$weight = as.numeric(dat[,15])
E(g)$color <-"skyblue"
E(g)$color[which(E(g)$weight > 0.7)] ="blue"
V(g)$color <-c('red','red','yellow','red','yellow','yellow','yellow')
plot.igraph(g,layout=layout.fruchterman.reingold,
vertex.shape="circle",vertex.color=c("#Eddfed","#Eddfed","#90A66A","#Eddfed","#C45A63","#C45A63","#C45A63")
,vertex.size=30,
vertex.label=V(g)$name, vertex.label.color=V(g)$color,vertex.label.cex=1, vertex.frame.color= "white",
edge.arrow.size=0.2,edge.color=E(g)$color,edge.label=c("","PM1689487","","","","PM27559130","",""),
edge.label.color="black",edge.label.cex=0.7
)
g<-graph(edges, n=max(edges), isolates=c("Glioblastoma\ngene","Damaging\nnsSNV","Tolerated\nnsSNV"), directed=FALSE)
V(g)$color <-c('red','red','yellow','red','yellow','yellow','red','yellow','yellow')
plot.igraph(g,layout=layout.fruchterman.reingold,
vertex.shape="circle",
vertex.color=c("#Eddfed","#Eddfed","#90A66A","#Eddfed","#C45A63","#C45A63","#Eddfed","#C45A63","#90A66A")
,vertex.size=50,
vertex.label=V(g)$name, vertex.label.color=V(g)$color,vertex.label.cex=1, vertex.frame.color= "white",
edge.arrow.size=0.2,edge.color=E(g)$color,edge.label=c("","PM1689487","","","","PM27559130","",""),
edge.label.color="black",edge.label.cex=0.7
)
de
legend("topleft", legend=c("interaction score > 0.7", "0.7 < interaction score > 0.4"), col=c("blue", "skyblue"), lty=1, cex=0.8)
'Coding > R' 카테고리의 다른 글
PCA (0) | 2018.07.16 |
---|---|
[plot]violin plot (0) | 2018.07.10 |
[plot] barplot with text (0) | 2017.06.13 |
line plot (0) | 2014.03.14 |
line plot (0) | 2014.01.28 |