Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
David Hoksza
bh19-rare-diseases
Commits
d92ab358
Commit
d92ab358
authored
Dec 02, 2019
by
David Hoksza
Browse files
Merge branch 'master' of
https://git-r3lab.uni.lu/david.hoksza/bh19-rare-diseases
parents
24afafba
185bf1ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
associations/extend_network/get_extended_network.R
View file @
d92ab358
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment