This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Import data for igraph using R

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

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.

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.

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.

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().

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

0 answers

No answers yet.

Log in to answer this question.