Commit 185bf1ab authored by Marek Ostaszewski's avatar Marek Ostaszewski
Browse files

updated code for text mining/omnipath network

parent 78749ab4
......@@ -58,6 +58,11 @@ retrieve_stringdb_net <- function(finput, fn, fscore) {
entities <- paste0("9606.", ensprotein_idest$ensembl_peptide_id)
entities <- paste(entities, collapse = "%0A" )
resp <- httr::POST(url = "api.jensenlab.org/network",
httr::add_headers('Content-Type' = "application/x-www-form-urlencoded"),
body = paste0("entities=", entities, "&additional=", n),
httr::verbose())
json <- jsonlite::fromJSON(httr::content(resp, as = "text", encoding = "UTF-8"), flatten = FALSE)
### May be important for later, when node-level info can be used for filtering
......@@ -179,74 +184,4 @@ if(nrow(ppi_network) == 0) {
"is_directed", "consensus_direction", "references")]
write.table(ppi_network, outputFile, sep = "\t", quote = F, row.names = F, col.names = T)
}
# gene_info_2entrez <- subset(gene_info_2entrez, entrezgene_id != "")
#
# result <- merge(result, gene_info_2entrez, by.x = "source_hgnc_symbol", by.y = "hgnc_symbol" )
# colnames(result)[which(names(result) == "entrezgene_id")] <- "source_entrezgene_id"
# result <- merge(result, gene_info_2entrez, by.x = "target_hgnc_symbol", by.y = "hgnc_symbol" )
# colnames(result)[which(names(result) == "entrezgene_id")] <- "target_entrezgene_id"
#
# result$pair <-apply(result,1,function(x){paste(sort(x[c("source_hgnc_symbol","target_hgnc_symbol")]),collapse=":")})
# ppi_network$pair <-apply(ppi_network,1,function(x){paste(sort(x[c("source_hgnc_symbol","target_hgnc_symbol")]),collapse=":")})
#
# message(paste0("from ",length(unique(ppi_network$pair))," pairs of interacting proteins from stringdb"))
# message(paste0("we found ", length(intersect(ppi_network$pair, result$pair) ), " interacting pairs in Omnipath"))
#
# final_results <- unique(subset(result, pair %in% ppi_network$pair)[c( "source_hgnc_symbol","source_entrezgene_id",
# "target_hgnc_symbol", "target_entrezgene_id",
# "is_directed", "consensus_direction", "references", "pair" )])
# ppi_network <- subset(ppi_network, !pair %in% final_results$pair)
# ppi_network <- within(ppi_network , rm(score, pair))
#
# final_results <- merge( final_results[, -grep("pair", colnames(final_results))],
# ppi_network, all = T )
# final_results$is_directed <- ifelse(is.na(final_results$is_directed), 0, as.character(final_results$is_directed))
#
# message(paste0(" And from those ",dim(subset(final_results, is_directed == 1) )[1], " interacting pairs have direction in Omnipath"))
#
# if( nrow( final_results ) == 0 ){
# warning("None of the pairs of interacting proteins havee pased the filters")
# } else {
# write.table(final_results, outputFile, sep = "\t", quote = F, row.names = F)
# }
# } else {
# message("Retrieving data from Omnipath")
#
# url <- paste0("http://omnipathdb.org/interactions/?genesymbols=1&partners=", paste(input, collapse = ","), "&fields=sources,references")
# dataTsv <- RCurl::getURLContent( url )
# myTextConnection <- textConnection( dataTsv )
# result <- read.csv( myTextConnection, header = TRUE, sep = "\t", colClasses=c("character"))
#
# colnames(result)[which(names(result) == "source_genesymbol")] <- "source_hgnc_symbol"
# colnames(result)[which(names(result) == "target_genesymbol")] <- "target_hgnc_symbol"
# result$pair <-apply(result,1,function(x){paste(sort(x[c("source_hgnc_symbol","target_hgnc_symbol")]),collapse=":")})
# message(paste0("there are ",length(unique(result$pair))," pairs of interacting proteins from omnipath"))
# ensembl <- useMart("ensembl")
# ensembl <- useMart("ensembl",dataset="hsapiens_gene_ensembl")
#
# gene_info_2entrez <- getBM(attributes=c('hgnc_symbol', 'entrezgene_id'),
# filters = 'hgnc_symbol',
# values = c(result$source_hgnc_symbol, result$target_hgnc_symbol),
# mart = ensembl)
# gene_info_2entrez <- subset(gene_info_2entrez, entrezgene_id != "")
#
# result <- merge(result, gene_info_2entrez, by.x = "source_hgnc_symbol", by.y = "hgnc_symbol" )
# colnames(result)[which(names(result) == "entrezgene_id")] <- "source_entrezgene_id"
# result <- merge(result, gene_info_2entrez, by.x = "target_hgnc_symbol", by.y = "hgnc_symbol" )
# colnames(result)[which(names(result) == "entrezgene_id")] <- "target_entrezgene_id"
#
#
# result <- unique(result[c( "source_hgnc_symbol", "source_entrezgene_id",
# "target_hgnc_symbol", "target_entrezgene_id",
# "is_directed", "consensus_direction", "references" )])
#
#
# if( nrow( result ) == 0 ){
# warning("None of the pairs of interacting proteins have pased the filters")
# } else {
# write.table(result, outputFile, sep = "\t", quote = F, row.names = F)
# }
#
# }
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment