Import data for igraph using R
0
0
Entering edit mode
2.2 years ago

I want to create igraph through R using my string interaction tsv database files.

Can anyone tell me how to read graph with string interaction tsv files in R.

It will be of much help. Thank you.

r igraph • 1.7k views
ADD COMMENT
1
Entering edit mode

It should be possible, but you need to provide a bit more context. E.g. an example of your input file. TSV file import is directly supported via the R studio user interface. igraph is available as an R-package.

ADD REPLY
0
Entering edit mode

Thanks. To run igraph command of the interaction.tsv file do i need to first convert to .txt files? because the R prog. can read my files but whenever i give read.graph command of the tsv file as such with "ncol" command it results in error:

At foreign.c:244 : Parse error in NCOL file, line 1 (syntax error, unexpected ALNUM, expecting NEWLINE), Parse error

library(igraph)
setwd(pathline)
G = read.table(file = 'string_interactions.tsv', sep = '\t', header = TRUE)

Until then it works fine. After which when i give the next command i.e

G = read.graph("string_interactions.tsv","ncol") 

the above mentioned error results.

ADD REPLY
0
Entering edit mode

I am not 100% sure at the moment, but I think read.graph requires a very igraph specific format that is itself only produced by igraph itself. Please give me the first 10 lines of your tsv file and I can fire up R and have look. eg. post the output of head(G) or head string_interactions.tsv in the linux shell.

ADD REPLY
0
Entering edit mode

Provide example input file, head string_interactions.tsv.

If your data is a 3 column ("from, to, weight") delimited file, then try using igraph::graph_from_data_frame().

ADD REPLY
0
Entering edit mode

OK thanks much. I'll try out.

ADD REPLY
1
Entering edit mode

I just started doing some work with igraph myself and while I'm not sure if this will directly answer your question I found the following resource to be really helpful:

https://kateto.net/networks-r-igraph

ADD REPLY
0
Entering edit mode

Thank you so much.

ADD REPLY

Login before adding your answer.

Traffic: 1387 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