Safepy
Python implementation of Spatial Analysis of Functional Enrichment (SAFE)
Install / Use
/learn @baryshnikova-lab/SafepyREADME
INTRODUCTION
SAFE (or Spatial Analysis of Functional Enrichment) is an automated network annotation algorithm. Given a biological network and a set of functional groups or quantitative features of interest, SAFE performs local enrichment analysis to determine which regions of the network are over-represented for each group or feature. SAFE visualizes the network and maps the detected enrichments onto the network.
SAFE was originally implemented in MATLAB and stored at https://bitbucket.org/abarysh/safe/. However, as of early 2017, the MATLAB implementation is only maintained for legacy purposes. New work related to SAFE is moving to Python and this repository.
WARNING. This package is still in development. Please use caution.
GETTING STARTED
Installation
SAFE requires Python 3 and a set of packages listed in extras/requirements.txt. We recommend setting up a virtual environment and installing all the required packages via pip:
cd safepy/
virtualenv -p python3 safepy_env
source safepy_env/bin/activate
pip install -r extras/requirements.txt
Usage
After the installation is complete, it is useful to run a "hello world" SAFE analysis using the Jupyter notebook at examples/Example_1_GI_network_doxorubicin.ipynb.
To do so, from within the safepy_env environment install a new ipython kernel:
ipython kernel install --user --name=safepy_env
Then start jupyter, open examples/Example_1_GI_network_doxorubicin.ipynb and select the safepy_env kernel.
jupyter lab
To run the examples, several common datasets will be required (e.g., the genetic interaction similarity network from Costanzo et al., 2016). These datasets are stored separately at https://github.com/baryshnikova-lab/safe-data (to avoid duplication with other SAFE-related repositories and packages). We recommend cloning the safe-data repository and storing it locally. In addition, it is necessary to edit the SAFE settings file (at safepy/safe_default.ini) with the path to the safe-data folder. By default, safe-data is expected to be located in the same parent folder as safepy:
vim safe_default.ini
...
[DEFAULT]
safe_data = ../safe-data/
...
Alternatively, you can pass the location of the safe-data repository to SAFE directly. See an example in examples/Example_1_GI_network_doxorubicin.ipynb and other notebooks in the same folder.
Testing
It may also be useful to run a series of unit tests to verify that SAFE provides the correct outputs for default inputs. Tests are progressively being written and added to the repository. To run all the existing tests (from the safepy folder):
cd tests/
python -m unittest discover -v -s .
HELP
Please direct all questions/comments to Anastasia Baryshnikova (abaryshk@gmail.com).
The main repository for this code is at https://github.com/baryshnikova-lab/safepy. Please subscribe to the repository to receive live updates about new code releases and bug reports.
HOW TO CITE
The manuscript describing SAFE and its applications is available at:
Baryshnikova, A. (2016). Systematic Functional Annotation and Visualization of Biological Networks. Cell Systems. http://doi.org/10.1016/j.cels.2016.04.014
Related Skills
node-connect
352.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
