Skip to content

Commit

Permalink
Three-column rel types error
Browse files Browse the repository at this point in the history
  • Loading branch information
noriakis committed Oct 31, 2023
1 parent 0cece6d commit b829efb
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions R/pathway_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,28 @@ pathway <- function(pid,
## Preallocate
all_rels <- vector(mode="list", length=length(rel_sets))
ei <- 1
rel_names <- c("entry1","entry2","type",
"subtype_name","subtype_value")
for (rel in rel_sets) {
entry1 <- xmlAttrs(rel)["entry1"]
entry2 <- xmlAttrs(rel)["entry2"]
rel_type <- xmlAttrs(rel)["type"]
# rel_subtype <- xmlAttrs(rel[["subtype"]])["name"]
rel_subtypes <- xmlElementsByTagName(rel,"subtype")
for (rs in rel_subtypes) {
all_rels[[ei]] <- c(entry1, entry2, rel_type,
xmlAttrs(rs)["name"], xmlAttrs(rs)["value"]) |>
setNames(c("entry1","entry2","type",
"subtype_name","subtype_value"))
ei <- ei + 1
if (length(rel_subtypes)!=0) {
for (rs in rel_subtypes) {
all_rels[[ei]] <- c(entry1, entry2, rel_type,
xmlAttrs(rs)["name"], xmlAttrs(rs)["value"]) |>
setNames(rel_names)
ei <- ei + 1
}
} else {
all_rels[[ei]] <- c(entry1, entry2, rel_type, NA, NA) |>
setNames(rel_names)
ei <- ei + 1
}
}

if (length(all_rels) != 0) {
kegg_edges <- dplyr::bind_rows(all_rels) |> data.frame() |>
`colnames<-`(c("entry1","entry2","type",
Expand Down

0 comments on commit b829efb

Please sign in to comment.