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.
- Reading RNA-seq-derived gene lists with
pvalue,logFC, andgenecolumns - 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
.
├── main_script.R # Main R script
├── README.md # Project description and usage instructions
└── example_input.csv # Optional anonymized example input file
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
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.
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.
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"The script uses the following R packages:
HGNChelper
STRINGdb
igraph
openxlsx
dplyr
tibble
ggraph
ggplot2
tidygraph
viridis
scales
curl
sna
ggrepel
BiocManagerMost CRAN packages are installed automatically if they are missing. The Bioconductor package STRINGdb is installed through BiocManager.
Run the script in R or RStudio:
source("main_script.R")Alternatively, open main_script.R in RStudio and click Run or Source.
The script performs the following steps:
- Installs and loads required R packages
- Reads the input gene table
- Converts
pvalueandlogFCto numeric format - Removes rows without valid gene symbols
- Corrects gene symbols using
HGNChelper - Maps gene symbols to STRING protein identifiers
- Attempts additional correction of unmapped genes using STRING aliases
- Builds a STRING-based PPI subnetwork
- Converts the network to an undirected simplified graph
- Identifies connected components and the largest connected component
- Performs Louvain community detection
- Calculates node-level network metrics
- Calculates graph-level summary metrics
- Generates a PPI network visualization
- Generates a log-log degree distribution plot
- Exports tables, plots, and Cytoscape-compatible files
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
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 |
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.
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
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.
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
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
Danil Silin
No license has been specified yet. Before public reuse by other users, add a license file to the repository.