A quick way to analyse gene/protein sets to investigate networks and functional enrichment.
It comes in two different flavors:
- string_api_net_enrich.py: This scripts inputs a list of genes from E. coli or humans in txt format (each gene or protein in a new line), and outputs a network image in svg, a summary of the categories from the different enrichments, and an excel file with all the enrichment information. It will also create radar plots for the most common words for each enrichment category (if any). The file example.txt has a list of genes that can be used to test the script.
- string_api_MULTI.py: This scripts inputs a list of genes from E. coli or humans in excel format. This script is intended to use with gene/protein lists that are UP-regulated and DOWN-regulated. Each direction must be in different Excel sheets, with a sheet name finised in _UP' or _DOWN'. For example, sample1_UP and sample1_DOWN. More than one sample can be included in the same Excel file, the script will save each sample in separate subfolders with specific names. The list of genes/proteins MUST have a header named genes. The file multi_test serves as an example for this script. The script will analyse these samples and directions in a very similar way as the simple script, but creating subfolders for each sample within the Excel file.
This script runs in Python >3.6 and requires the following libraries: pandas, requests, seaborn,numpy, openpyxl and matplotlib.
There are several ways to install these dependencies. You can either use pip
pip install pandasOr my favourite way to do these things, through a conda env:
conda install pandasYou can install all these libraries at once:
conda install pandas requests seaborn numpy openpyxl matplotlib -yGo to the folder where you should have both the script and the file you want to analyse (for convenience), and type the following:
python string_api_net_enrich.py example.txt out_folder ecoliAnd for the other script, the same:
python string_api_MULTI.py multi_test.xlsx out_folder ecoliChange input and output for your input file, and your desired output filename. Right now it allows to specify either E. coli, Homo sapiens, C. elegans, Mus musculus, D. melanogaster, Dario rerio, Saccharomyces cerevisiae as species (type ecoli or human respectively).
Here is the list of organisms accepted at this moment in the code
| Species list | code |
|---|---|
| E. coli | ecoli |
| Homo sapiens | human |
| C. elegans | celegans |
| Mus musculus | mouse |
| D. melanogaster | fly |
| Dario rerio | zebrafish |
| Saccharomyces cerevisiae | yeast |
| Pseudomonas aeruginosa PAO1 | PA |
This is an example of the radar plots it's able to extract:
There is a version in Google Colab if you are a bit lazy
- generalise funtions into classes
- include more analyses and plots (heatmaps, semantic space of GO terms...)
- make word frequency more smart -> concept over words
- [long term] build all functions in different files, tidy everything
To adapt the script to two cases (usually up and down regulation)