Reactome biopax level 3 structure

library(rBiopaxParser)
biopaxfile3 <- "./Reactome/R-HSA-169911_level3.owl"
biopax <- readBiopax(biopaxfile3, verbose = F)
pw_list = listInstances(biopax, class = "bp:Pathway")
pw_list
##         id                                                                name
## 1 Pathway1                                             Regulation of Apoptosis
## 2 Pathway2 Regulation of activated PAK-2p34 by proteasome mediated degradation
## 3 Pathway3                     Regulation of PAK-2p34 activity by PS-GAP/RHG10
selectInstances(biopax, id = "Pathway1")[property=="pathwayComponent",.(property_attr_value)]
##      property_attr_value
## 1:             #Pathway2
## 2:             #Pathway3
## 3: #BiochemicalReaction5
br_5_components = selectInstances(biopax,id="BiochemicalReaction5")
br_5_components[property=="displayName",.(property_value)]
##          property_value
## 1: OMA1 hydrolyses OPA1
p_left <- br_5_components[property=="left",]
p_right <- br_5_components[property=="right",]
p_left
##                  class                   id property property_attr
## 1: BiochemicalReaction BiochemicalReaction5     left  rdf:resource
## 2: BiochemicalReaction BiochemicalReaction5     left  rdf:resource
##    property_attr_value property_value
## 1:     #SmallMolecule1               
## 2:          #Protein64
p_right
##                  class                   id property property_attr
## 1: BiochemicalReaction BiochemicalReaction5    right  rdf:resource
## 2: BiochemicalReaction BiochemicalReaction5    right  rdf:resource
##    property_attr_value property_value
## 1:          #Protein65               
## 2:          #Protein66
selectInstances(biopax,id="Protein64")[property=="displayName",.(property_value)]
##    property_value
## 1:           OPA1
selectInstances(biopax,id=p_left$property_attr_value)[property=="displayName",.(property_value)]
##    property_value
## 1:           OPA1
## 2:            H2O
selectInstances(biopax,id=p_right$property_attr_value)[property=="displayName",.(property_value)]
##    property_value
## 1:     OPA1_HUMAN
## 2:     OPA1_HUMAN
selectInstances(biopax,id=p_right$property_attr_value)[property=="name",.(property_value)]
##                                                          property_value
## 1:                                                         OPA1(88-194)
## 2: Dynamin-like 120 kDa protein, mitochondrial ecNumber3.6.5.5/ecNumber
## 3:                                                        OPA1(195-960)
## 4: Dynamin-like 120 kDa protein, mitochondrial ecNumber3.6.5.5/ecNumber
g1 <- pathway2RegulatoryGraph(biopax, pwid="Pathway1", expandSubpathways=F,splitComplexMolecules=F, useIDasNodenames = T, verbose=F)
g2 <- pathway2Graph(biopax, pwid="Pathway1", expandSubpathways=F ,splitComplexMolecules=F, useIDasNodenames = F, verbose=F)
pw_1graph_laidout = layoutRegulatoryGraph(g1)
pw_2graph_laidout = layoutRegulatoryGraph(g2)
g1
## A graphNEL graph with directed edges
## Number of Nodes = 10 
## Number of Edges = 9
head(edges(g1),3)
## $PhysicalEntity1
## [1] "Protein1"  "Protein2"  "Protein17"
## 
## $Protein1
## character(0)
## 
## $Protein2
## character(0)
# plot(pw_1graph_laidout)
g2
## A graphNEL graph with directed edges
## Number of Nodes = 13 
## Number of Edges = 18
edges(g2)
## $Protein1
## [1] "Protein17" "Complex2" 
## 
## $Protein2
## [1] "Protein17"
## 
## $Protein17
## character(0)
## 
## $Protein63
## [1] "Complex2"
## 
## $Complex2
## [1] "Complex3"
## 
## $Complex3
## character(0)
## 
## $SmallMolecule1
## [1] "Protein65" "Protein66"
## 
## $Protein64
## [1] "Protein65" "Protein66"
## 
## $Protein65
## character(0)
## 
## $Protein66
## character(0)
## 
## $PhysicalEntity1
## [1] "Protein1"  "Protein2"  "Protein17"
## 
## $Complex1
## [1] "Protein17" "Protein2" 
## 
## $Protein67
## [1] "SmallMolecule1" "Protein64"      "Protein65"      "Protein66"
plot(g2)

Biopax level 3 to table

library(rBiopaxParser)
biopaxfile3 <- "./Reactome/R-HSA-169911_level3.owl"
biopax <- readBiopax(biopaxfile3, verbose = F)
listPathways(biopax)
##         id                                                                name
## 1 Pathway1                                             Regulation of Apoptosis
## 2 Pathway2 Regulation of activated PAK-2p34 by proteasome mediated degradation
## 3 Pathway3                     Regulation of PAK-2p34 activity by PS-GAP/RHG10
unique(listPathwayComponents(biopax, id="Pathway1"))
##                      id
## 1  BiochemicalReaction1
## 2  BiochemicalReaction2
## 3  BiochemicalReaction3
## 4  BiochemicalReaction4
## 5  BiochemicalReaction5
## 6              Pathway2
## 7              Pathway3
## 8            Catalysis1
## 14           Catalysis2
## 20           Catalysis3
## 26         PathwayStep1
## 29         PathwayStep2
## 31         PathwayStep3
## 32         PathwayStep4
## 34         PathwayStep5
## 35         PathwayStep6
## 36         PathwayStep7
##                                                                                                        name
## 1                                                                                Ubiquitination of PAK-2p34
## 2                                                               Proteasome mediated degradation of PAK-2p34
## 3                        Rho GTPase-activating protein 10 (RHG10) interacts with caspase-activated PAK-2p34
## 4  Interaction of PAK-2p34 with RGH10/ PS-GAP results in accumulation of PAK-2p34 in the perinuclear region
## 5                                                                                      OMA1 hydrolyses OPA1
## 6                                       Regulation of activated PAK-2p34 by proteasome mediated degradation
## 7                                                           Regulation of PAK-2p34 activity by PS-GAP/RHG10
## 8                                                                                                          
## 14                                                                                                         
## 20                                                                                                         
## 26                                                                                                         
## 29                                                                                                         
## 31                                                                                                         
## 32                                                                                                         
## 34                                                                                                         
## 35                                                                                                         
## 36
listInteractionComponents(biopax, id="BiochemicalReaction5")
##               id       name
## 1      Protein64       OPA1
## 2      Protein65 OPA1_HUMAN
## 3      Protein66 OPA1_HUMAN
## 4 SmallMolecule1        H2O
pw_list = listInstances(biopax, class = "bp:Pathway")
path_df <- data.frame(biopax=biopaxfile3, relation="has_pathway", pw_list)
path_df
##                               biopax    relation       id
## 1 ./Reactome/R-HSA-169911_level3.owl has_pathway Pathway1
## 2 ./Reactome/R-HSA-169911_level3.owl has_pathway Pathway2
## 3 ./Reactome/R-HSA-169911_level3.owl has_pathway Pathway3
##                                                                  name
## 1                                             Regulation of Apoptosis
## 2 Regulation of activated PAK-2p34 by proteasome mediated degradation
## 3                     Regulation of PAK-2p34 activity by PS-GAP/RHG10
pw_component_list <- NULL
for(pw in pw_list$id){
  pw_c <- selectInstances(biopax, id = pw)[property=="pathwayComponent",.(property_attr_value)]
  pw_c_df <- data.frame(pathway=pw, relation="has_pathwayComponent", pw_c)
  pw_component_list[[pw]] <- pw_c_df
}
pw_component <- rbindlist(pw_component_list)
pw_component
##     pathway             relation   property_attr_value
## 1: Pathway1 has_pathwayComponent             #Pathway2
## 2: Pathway1 has_pathwayComponent             #Pathway3
## 3: Pathway1 has_pathwayComponent #BiochemicalReaction5
## 4: Pathway2 has_pathwayComponent #BiochemicalReaction1
## 5: Pathway2 has_pathwayComponent #BiochemicalReaction2
## 6: Pathway3 has_pathwayComponent #BiochemicalReaction3
## 7: Pathway3 has_pathwayComponent #BiochemicalReaction4
br_components_list <- NULL
brs <- unique(sub("^#","",pw_component[grep("BiochemicalReaction", property_attr_value),]$property_attr_value))
for(br in brs) {
  # cat(br)
  br_components = selectInstances(biopax, id = br)
  br_c_name <-
    br_components[property == "displayName", .(property_value)]$property_value
  p_left <- br_components[property == "left", ]
  p_right <- br_components[property == "right", ]
  
  p_right$property_attr_value
  br_comp_df <-
    rbind(
      data.frame(
        ID = br,
        Name = br_c_name,
        relation = "has_left",
        Molecula = p_left$property_attr_value
      ),
      data.frame(
        ID = br,
        Name = br_c_name,
        relation = "has_right",
        Molecula = p_right$property_attr_value
      )
    )
  br_components_list[[br]] <- br_comp_df
}
br_components_df <- rbindlist(br_components_list)
br_components_df
##                       ID
##  1: BiochemicalReaction5
##  2: BiochemicalReaction5
##  3: BiochemicalReaction5
##  4: BiochemicalReaction5
##  5: BiochemicalReaction1
##  6: BiochemicalReaction1
##  7: BiochemicalReaction1
##  8: BiochemicalReaction2
##  9: BiochemicalReaction2
## 10: BiochemicalReaction3
## 11: BiochemicalReaction3
## 12: BiochemicalReaction3
## 13: BiochemicalReaction4
## 14: BiochemicalReaction4
##                                                                                                         Name
##  1:                                                                                     OMA1 hydrolyses OPA1
##  2:                                                                                     OMA1 hydrolyses OPA1
##  3:                                                                                     OMA1 hydrolyses OPA1
##  4:                                                                                     OMA1 hydrolyses OPA1
##  5:                                                                               Ubiquitination of PAK-2p34
##  6:                                                                               Ubiquitination of PAK-2p34
##  7:                                                                               Ubiquitination of PAK-2p34
##  8:                                                              Proteasome mediated degradation of PAK-2p34
##  9:                                                              Proteasome mediated degradation of PAK-2p34
## 10:                       Rho GTPase-activating protein 10 (RHG10) interacts with caspase-activated PAK-2p34
## 11:                       Rho GTPase-activating protein 10 (RHG10) interacts with caspase-activated PAK-2p34
## 12:                       Rho GTPase-activating protein 10 (RHG10) interacts with caspase-activated PAK-2p34
## 13: Interaction of PAK-2p34 with RGH10/ PS-GAP results in accumulation of PAK-2p34 in the perinuclear region
## 14: Interaction of PAK-2p34 with RGH10/ PS-GAP results in accumulation of PAK-2p34 in the perinuclear region
##      relation        Molecula
##  1:  has_left #SmallMolecule1
##  2:  has_left      #Protein64
##  3: has_right      #Protein65
##  4: has_right      #Protein66
##  5:  has_left       #Protein1
##  6:  has_left       #Protein2
##  7: has_right      #Protein17
##  8:  has_left      #Protein17
##  9: has_right       #Protein2
## 10:  has_left       #Protein1
## 11:  has_left      #Protein63
## 12: has_right       #Complex2
## 13:  has_left       #Complex2
## 14: has_right       #Complex3
moleculas <- unique(sub("^#","",br_components_df$Molecula))
moleculas_name_list <- list()
for(m in moleculas){
name <- selectInstances(biopax,id=m)[property=="displayName",.(property_value)]$property_value
  moleculas_name_list[[m]] <- data.frame(Molecula=m, relation="has_displayName", name)
}
moleculas_name_df <- rbindlist(moleculas_name_list)
moleculas_name_df
##           Molecula        relation                               name
##  1: SmallMolecule1 has_displayName                                H2O
##  2:      Protein64 has_displayName                               OPA1
##  3:      Protein65 has_displayName                         OPA1_HUMAN
##  4:      Protein66 has_displayName                         OPA1_HUMAN
##  5:       Protein1 has_displayName                    p-T402-PAK-2p34
##  6:       Protein2 has_displayName                                 Ub
##  7:      Protein17 has_displayName          K48polyUb-p-T402-PAK-2p43
##  8:      Protein63 has_displayName                           ARHGAP10
##  9:       Complex2 has_displayName             PAK-2p34:RHG10 complex
## 10:       Complex3 has_displayName perinuclear PAK-2p34:RHG10 complex
# Name not display name
moleculas_name_list <- list()
for(m in grep("Complex",moleculas,value = T, invert = T)){
  cat(m)
name <- selectInstances(biopax,id=m)[property=="name",.(property_value)]$property_value
  moleculas_name_list[[m]] <- data.frame(Molecula=m, relation="has_name", name)
}
## SmallMolecule1Protein64Protein65Protein66Protein1Protein2Protein17Protein63
moleculas_name_df <- rbindlist(moleculas_name_list)
moleculas_name_df
##           Molecula relation
##  1: SmallMolecule1 has_name
##  2:      Protein64 has_name
##  3:      Protein64 has_name
##  4:      Protein65 has_name
##  5:      Protein65 has_name
##  6:      Protein66 has_name
##  7:      Protein66 has_name
##  8:       Protein1 has_name
##  9:       Protein1 has_name
## 10:       Protein2 has_name
## 11:      Protein17 has_name
## 12:      Protein63 has_name
##                                                                     name
##  1:                                                                water
##  2: Dynamin-like 120 kDa protein, mitochondrial ecNumber3.6.5.5/ecNumber
##  3:                                                           OPA1_HUMAN
##  4:                                                         OPA1(88-194)
##  5: Dynamin-like 120 kDa protein, mitochondrial ecNumber3.6.5.5/ecNumber
##  6:                                                        OPA1(195-960)
##  7: Dynamin-like 120 kDa protein, mitochondrial ecNumber3.6.5.5/ecNumber
##  8:                                                 p-T402-PAK2(213-524)
##  9:                                           phospho-PAK-2p34 (Thr 402)
## 10:                                                            ubiquitin
## 11:                                   K48polyUb-phospho-PAK-2p34(Thr402)
## 12:                                                     Graf-2/ Arhgap10