Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Script for Interactome Construction Based on RNA-seq Data

Overview

This repository contains an R-based bioinformatics workflow for constructing and analyzing patient-specific protein-protein interaction (PPI) subnetworks from RNA-seq-derived gene lists.

The script performs gene symbol normalization, mapping of genes to STRING protein identifiers, construction of a STRING-based PPI subnetwork, topological analysis, Louvain community detection, and export of results for visualization and downstream interpretation.

The workflow is intended for exploratory network bioinformatics and candidate prioritization. It is not a diagnostic tool and does not provide clinical or treatment recommendations.

Main Features

  • Reading RNA-seq-derived gene lists with pvalue, logFC, and gene columns
  • Conversion of decimal commas to decimal points
  • HGNC-based gene symbol correction
  • Additional correction of unmapped genes using STRING aliases
  • Mapping of gene symbols to STRING protein identifiers
  • Construction of human PPI subnetworks using STRING v12.0
  • Calculation of graph-level and node-level network metrics
  • Louvain community detection
  • Export of tables for network interpretation
  • Export of a GraphML file for Cytoscape
  • Generation of publication-ready network and degree-distribution plots

Repository Structure

.
├── main_script.R       # Main R script
├── README.md           # Project description and usage instructions
└── example_input.csv   # Optional anonymized example input file

Input Data Format

The input file should be a semicolon-separated table with a header and three columns in the following order:

pvalue;logFC;gene
0.001;2.15;TOP2A
0.034;-1.27;C1QA
0.012;1.85;CDK1

The script expects the following columns:

Column Description
pvalue Statistical significance value for the gene
logFC Log fold-change value
gene Gene symbol

Decimal commas are accepted and automatically converted to decimal points.

Example:

0,001;2,15;TOP2A

will be converted to:

0.001;2.15;TOP2A

Important Input Requirements

The current version of the script reads the input file using:

read.delim(
  input_file,
  sep = ";",
  header = TRUE,
  col.names = c("pvalue", "logFC", "gene")
)

Therefore, the input file should be separated by semicolons (;), and the first three columns should correspond to:

pvalue;logFC;gene

If your file has a different separator or column order, modify the read.delim() block in main_script.R before running the analysis.

Required STRING Files

The script uses STRING v12.0 for Homo sapiens (species = 9606). Before running the script, place the following files in the local STRING cache directory:

9606.protein.aliases.v12.0.txt.gz
9606.protein.info.v12.0.txt.gz
9606.protein.links.v12.0.txt.gz

The script checks whether these files are present and whether their sizes are consistent with complete downloads.

Before Running

Open main_script.R and edit the following paths:

cache_dir <- "path_to_string_cache"
input_file <- "path_to_input_file"
output_dir <- "path_to_output_folder"

Example for Windows:

cache_dir <- "D:/STRING_cache"
input_file <- "D:/project/input/genes.csv"
output_dir <- "D:/project/results"

Example for macOS/Linux:

cache_dir <- "/Users/username/STRING_cache"
input_file <- "/Users/username/project/input/genes.csv"
output_dir <- "/Users/username/project/results"

R Packages

The script uses the following R packages:

HGNChelper
STRINGdb
igraph
openxlsx
dplyr
tibble
ggraph
ggplot2
tidygraph
viridis
scales
curl
sna
ggrepel
BiocManager

Most CRAN packages are installed automatically if they are missing. The Bioconductor package STRINGdb is installed through BiocManager.

How to Run

Run the script in R or RStudio:

source("main_script.R")

Alternatively, open main_script.R in RStudio and click Run or Source.

Workflow Description

The script performs the following steps:

  1. Installs and loads required R packages
  2. Reads the input gene table
  3. Converts pvalue and logFC to numeric format
  4. Removes rows without valid gene symbols
  5. Corrects gene symbols using HGNChelper
  6. Maps gene symbols to STRING protein identifiers
  7. Attempts additional correction of unmapped genes using STRING aliases
  8. Builds a STRING-based PPI subnetwork
  9. Converts the network to an undirected simplified graph
  10. Identifies connected components and the largest connected component
  11. Performs Louvain community detection
  12. Calculates node-level network metrics
  13. Calculates graph-level summary metrics
  14. Generates a PPI network visualization
  15. Generates a log-log degree distribution plot
  16. Exports tables, plots, and Cytoscape-compatible files

Calculated Network Metrics

The script calculates the following graph-level metrics:

  • Number of nodes
  • Number of edges
  • Number of connected components
  • Largest component size
  • Network density
  • Average degree
  • Global clustering coefficient
  • Average shortest path length in the largest component
  • Diameter of the largest component
  • Radius of the largest component
  • Number of Louvain communities
  • Louvain modularity

The script also calculates the following node-level metrics:

  • Degree
  • Betweenness centrality
  • Closeness centrality
  • Stress centrality
  • Local clustering coefficient
  • Component membership
  • Membership in the largest connected component
  • Louvain community assignment

Output Files

After successful execution, the script creates the following output files:

File Description
PPI_STRING_Style_HQ.png High-resolution PPI network visualization
PPI_STRING_Style_HQ.pdf PDF version of the PPI network visualization
Degree_Distribution_loglog.png Log-log degree distribution plot
Degree_Distribution_loglog.pdf PDF version of the degree distribution plot
GeneName_Corrections.xlsx Report on gene symbol correction and mapping status
Network_Analysis.xlsx Main Excel file with graph summary and node metrics
PPI_network_for_Cytoscape.graphml GraphML network file for Cytoscape
genes_for_Cytoscape.txt Gene list used for Cytoscape visualization
STRING_ids_for_Cytoscape.txt STRING protein identifiers used in the network
genes_for_network.csv Gene table retained for network construction
corrected_genes_only.csv List of corrected gene symbols, if corrections were found
STRING_links_persistent.txt STRING links for viewing the network online
sessionInfo.txt R session information for reproducibility

Excel Output Structure

The file Network_Analysis.xlsx contains the following sheets:

Sheet Description
Graph_Summary Global network-level metrics
Node_Metrics Metrics for all nodes in the PPI network
Top30_Proteins Top proteins ranked mainly by degree
Top30_Betweenness Top proteins ranked by betweenness centrality
Top30_Stress Top proteins ranked by stress centrality
Degree_Distribution Degree distribution table
Mapping_Summary Summary of initial and final STRING mapping
Still_Unmapped Genes that could not be mapped to STRING

The file GeneName_Corrections.xlsx contains information about gene symbol correction, mapping status, and genes that remained unmapped.

Cytoscape Export

The file:

PPI_network_for_Cytoscape.graphml

can be imported directly into Cytoscape.

Node attributes exported to Cytoscape include:

  • Gene symbol
  • Degree
  • Betweenness centrality
  • Closeness centrality
  • Stress centrality
  • Local clustering coefficient
  • Louvain community

Notes on Interpretation

The resulting PPI network should be interpreted as a reconstructed interaction subnetwork based on STRING data and the submitted RNA-seq-derived gene list.

Important limitations:

  • Bulk RNA-seq reflects the combined molecular signal of the analyzed tissue sample.
  • mRNA-level changes do not necessarily correspond directly to protein abundance, protein activity, or protein localization.
  • STRING-based PPI networks represent known and predicted protein associations, not direct experimental measurements in the analyzed sample.
  • Network centrality does not automatically indicate therapeutic relevance.
  • Candidate proteins identified by the workflow should be considered as priorities for further biological interpretation and experimental validation.

Data Privacy

Do not upload identifiable clinical or patient-related data to a public GitHub repository.

For public sharing, use only:

  • Anonymized input examples
  • Synthetic test data
  • Non-identifiable gene lists
  • Code and documentation

Recommended Use

This workflow can be used for:

  • Exploratory PPI network construction
  • Patient-specific or sample-specific network comparison
  • Prioritization of candidate proteins for further analysis
  • Preparation of Cytoscape-compatible network files
  • Reproducible reporting of graph-based bioinformatics results

Author

Danil Silin

License

No license has been specified yet. Before public reuse by other users, add a license file to the repository.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages