KEGGREST using keggGet() for over 10 results and URL errors for unexisting records
1
1
Entering edit mode
5.2 years ago

1. Over 10 results

I am trying to get pathway names using a list of 16 list of enzymes (list of lists). I used lapply and works correctly for the first 10 enzymes from each list.

# list of 16 list of enzymes    
list_Enz <- lapply(read_files, function(z) paste0("ec:",z[,3]))

# example enzymes 

    x<- c("ec:1.1.1.2", "ec:6.2.1.1", "ec:1.2.4.1", "ec:2.3.1.12", "ec:1.8.1.4", "ec:1.2.1.51", 
"ec:1.1.1.27", "ec:1.2.1.4", "ec:1.2.1.5", "ec:2.7.1.11", "ec:4.1.2.13", "ec:2.7.1.40", 
"ec:1.2.1.49", "ec:2.7.2.3", "ec:5.3.1.9", "ec:5.3.1.1", "ec:2.7.1.1", "ec:2.7.1.2", 
"ec:2.7.1.147", "ec:5.4.2.2", "ec:5.4.2.5", "ec:5.4.2.6", "ec:5.2.2.2", "ec:5.1.3.3", "ec:2.7.1.1")

    y <- c("ec:1.1.1.1", "ec:1.1.1.71", "ec:1.1.1.27", "ec:1.2.1.4", "ec:1.2.1.5", "ec:2.7.1.11", 
"ec:4.2.1.11", "ec:3.6.1.7", "ec:1.2.1.12", "ec:4.1.2.13", "ec:1.2.4.1", "ec:2.3.1.12", 
"ec:2.7.1.147", "ec:5.3.1.9", "ec:3.2.1.20", "ec:3.2.1.28", "ec:2.4.1.186", "ec:2.4.1.11", 
"ec:2.4.1.11", "ec:2.4.1.18", "ec:2.4.1.1", "ec:3.2.1.1")

  # trial 25 enzymes
  list_Enzh<- list(x,y)
  listpaths <- lapply(list_Enzh, function(m) keggGet(m))

How could I use a for or while loops to got all the information?. Tried a nested loop and it doesn't work:

for (k in 1:16){
  for (l in 1:25){
    listpaths2 <- lapply(list_Enzh, function(m) keggGet(m[[k]][[l]]))
  }
}

Error in m[[k]][[l]] : subscript out of bounds

2. Error for some enzyme records I used while loop for a single list of enzymes. It works correctly, but for "ec:5.2.2.2" (x example list) gives an error message.

paths <- c()
i<- 1
while (i < length (x)){
paths[i] <- keggGet(x[i])
}

Error in .getUrl(url, .flatFileParser) : Not Found (HTTP 404).

I appreciate a lot any help!

keggGet KEGGREST list of list enzymes pathways • 4.1k views
ADD COMMENT
1
Entering edit mode
5.1 years ago

So far I found the following code works and avoid URL errors:

for(i in 1:length(enz)){
  data_all[i] <- tryCatch(keggGet(enz[i]), error=function(e) NULL)
}

If anyone could like to check, I reviewed line 89 in: https://github.com/GuangchuangYu/clusterProfiler/blob/master/R/kegg-utilities.R#L88

ADD COMMENT

Login before adding your answer.

Traffic: 3443 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6