This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to run protein-protein interaction on R using STRING database

Hi,

I would like to know the codes precisely on how I load data with my list of protein targets that I want analysed on the String database. So far I know that I have to run these codes below.

From then on, I do not know how I should:

  1. Load the dataset
  2. Link the dataset on R in order to run it on R

    install.packages("BiocManager")
    install.packages("STRINGdb")
    library("STRINGdb")
    

PS. I am a beginner level in programming.

Thank you in advance, I hope for a favourable response.

stringdb

Please use the formatting bar (especially the code option) to present your post better. You can use backticks for inline code (`text` becomes text), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.
code_formatting

How did you install STRINGdb, a Biooconductor package, using install.packages() instead of BiocManager::install()?

May I kindly RamRS,

From then on, what codes can I use to avoid getting the error below: Error in tempMatr[i, ] : incorrect number of dimensions

The question is on linking the dataset on R to the STRING database.

install.packages("BiocManager")
install.packages("STRINGdb")
library(BiocManager)
library("STRINGdb")
string_db <- STRINGdb$new( version="11", species=469008, score_threshold=00, input_directory="")
library(readxl)
p <- read_excel("1.xlsx")
View(p)
p_mapped <- string_db$map( p, "gene", removeUnmappedRows = TRUE )
**Error in tempMatr[i, ] : incorrect number of dimensions**

Basically the proteins I want to establish a network for are in this sharable link: https://drive.google.com/file/d/1aJisbhWyqUFcx_wIBMxcDtw5fMIE-z5d/view?usp=sharing

I would greatly appreciate the help very much.

I am not sure why, but when you read your data from Excel into R some times you will face difficulty around your data type. Conveting your data to data frame by data.frame function resovled the issue. look at :

   str(p)
    tibble [331 x 3] (S3: tbl_df/tbl/data.frame)
     $ Protein IDs: chr [1:331] "UPI000012B727" "UPI000012A283" "UPI000013B55B" "UPI00000540BA" ...
     $ dprfH-wt   : num [1:331] 5.24 4.64 3.95 3.92 3.79 ...
     $ gene       : chr [1:331] "GLND_ECOLI" "EUTC_ECOLI" "MSCM_ECOLI" "TATA_ECOLI" ...

converting p to pp as a dataframe

pp <- data.frame(p)

str(pp)
'data.frame':   331 obs. of  3 variables:
 $ Protein.IDs: chr  "UPI000012B727" "UPI000012A283" "UPI000013B55B" "UPI00000540BA" ...
 $ dprfH.wt   : num  5.24 4.64 3.95 3.92 3.79 ...
 $ gene       : chr  "GLND_ECOLI" "EUTC_ECOLI" "MSCM_ECOLI" "TATA_ECOLI" ...

Now it works,

string_db <- STRINGdb$new( version="11", species=469008, score_threshold=00, input_directory="")
p_mapped <- string_db$map( pp, "gene", removeUnmappedRows = TRUE )
Warning:  we couldn't map to STRING 100% of your identifiers

It seems your identifires are not in correct format.

Also, make sure you pasted correct codes for package installation. Is it possible to install a Biocondoctor package by install.packages() function?

Its better to check on the website on installations: anyhow if you run this code it will work,

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("STRINGdb")

Hi, first of all I'm not an expert at all but I've been working with STRINGdb in R this week and I wanted to contribute to the community.

Firstly, in case you don't know it, you can use the gene symbols you have in your Excel without mapping them to a STRING id, so you can save yourself the mapping part.

You don't say how (in which format) do you want the network, it can be as a PNG image or as a TSV file, for example. If you want an image you can just use the get_png method from STRINGdb package. An easy way to use it in your example would be something like this:

  string_db$get_png(p$gene, file="network.png")

However, I don't know why you put 00 as score_threshold, the medium (and by default) value is 400 and if you to set it lower than that, I suggest a value of 200.

Hope it serves. Regards

1 answer

Thank you for noticing, its a bit embarrassing to fail to notice the installation, baby steps :), it's still a discovery for me :).

I just ran the installation code now as you advised.

From then on, I do what codes to use to avoid getting the error below:

Link the dataset on R in order to run it on R. Below is my reference codes I used and an error at the bottom for reference:

install.packages("BiocManager")
install.packages("STRINGdb")
library(BiocManager)
library("STRINGdb")
string_db <- STRINGdb$new( version="11", species=469008, score_threshold=00, input_directory="")
library(readxl)
p <- read_excel("1.xlsx")
View(p)
p_mapped <- string_db$map( p, "gene", removeUnmappedRows = TRUE )
**Error in tempMatr[i, ] : incorrect number of dimensions**

Basically the proteins I want to establish a network for are in this sharable link: https://drive.google.com/file/d/1aJisbhWyqUFcx_wIBMxcDtw5fMIE-z5d/view?usp=sharing

I would greatly appreciate the help very much.

Hi,

This reply is better suited as a reply to my comment. Could you make the appropriate change please? That would involve the following steps:

  1. Copy the contents of your reply from this answer (you can edit this answer (Ctrl/Cmd + click the link to open it in a new tab) and do a Select All -> Copy there).
  2. Click on Add Reply on my comment here: C: How to run protein-protein interaction on R using STRING database
  3. Paste the copied text
  4. Click on the green Add Comment button
  5. Click on moderate back in your answer here: A: How to run protein-protein interaction on R using STRING database
  6. Choose Delete Post
  7. Click on the blue Submit button.

Thank you!

P.S: Please do not add answers unless you're answering the top level question. Use Add Comment or Add Reply as appropriate. Also, pay attention to my previous comment on formatting your post.

Log in to answer this question.