-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwnt_pathway.R
67 lines (61 loc) · 2.61 KB
/
wnt_pathway.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#' Demo function for Wnt Pathway Views
#'
#'
#' @export
#' @importFrom rBiopaxParser readBiopax listPathways
#' @importFrom mully plot3d
wntpathway<-function(){
downloadPathway("R-HSA-195721")
wntBiopax=readBiopax("R-HSA-195721.owl")
pathwayID=getPathwayID(wntBiopax,"R-HSA-195721")
wntmully=pathway2Mully(wntBiopax,pathwayID)
plot3d(wntmully,layers=T,vertex.label=NA,edge.width=5,edge.arrow.size=5)
#First Plot
plot3d(wntmully,layers=T,vertex.label=NA,edge.width=5)
#Second Plot
plot3d(wntmully,layers=T,vertex.label=V(wntmully)$description,edge.width=5)
view1=pathwayView(wntmully,"View1")
view1=addStep(view1,action = "remove",element="layer",name="Rna",trans = T)
suppressWarnings(plot3d(view1$modified))
view2=pathwayView(wntmully,"View2")
view2=addStep(view2,action = "remove",element="layer",name="PhysicalEntity",trans=T)
suppressWarnings(plot3d(view2$modified))
view3=pathwayView(wntmully,"View3")
view3=addStep(view3,action = "remove",element="layer",name="Complex",trans=T)
suppressWarnings(plot3d(view3$modified))
view4=undo(view3,1)
#Add DrugBank Layer
#Get Proteins on Protein Layer
proteinLayer=getLayer(wntmully,"Protein")
proteinMappings=getExternalIDs(wntBiopax,proteinLayer$name,"UniProt")
proteinIDs=unique(proteinMappings[,2])
up=UniProt.ws()
upkbtodb=getUPKBInfo(up,proteinIDs,col=c("UNIPROTKB","DRUGBANK"))
drugIDs=unique(upkbtodb$dbid)
wntmully=addDBLayer(wntmully,dataNew,drugIDs)
wntmully=removeLayer(wntmully,"drugs",trans = F)
newWnt=addDBLayer(mully(name="Wnt Pathway",direct = T),dataNew,drugList = drugIDs)
newWnt=merge(newWnt,wntmully)
#Merge edges
upkbtodb=read.csv("mappingsWnt.csv")
dbtoupkb=getDBtoUPKB(dataNew,drugIDs,proteinIDs)
lnames=intersect(names(upkbtodb),names(dbtoupkb))
upkbtodb$source="UniProt"
dbtoupkb$source="DrugBank"
relations=merge.data.frame(upkbtodb,dbtoupkb[ ,c("dbid","upid","type","dbproteinid","source")],by=lnames,all=T)
relations$source=paste(relations$'source.x'," ",relations$'source.y')
relations=relations[,c("dbid","upid","type","dbproteinid","source")]
relations=unique(relations[order(relations$dbid),])
names(proteinMappings)=c("intid","upid")
#Replace internal IDs
newRelations=merge.data.frame(proteinMappings,newRelations)
for (i in 1:dim(relations)[1]) {
startName=V(newWnt)[which(V(newWnt)$name == newRelations$'dbid'[i])]$name
endName=V(newWnt)[which(V(newWnt)$name == newRelations$'intid'[i])]$name
attrList=newRelations[i,]
attr=as.list(attrList)
names(attr)=names(newRelations)
newWnt=mully::addEdge(newWnt,startName,endName,attributes = attr[-2])
}
return(wntmully)
}