Utilities for integrating python scripts into Perseus workflows
Project description
perseuspy README
This repository contains the source code of the perseuspy software package. perseuspy contains convenience functions which allow for faster and easier development of plugins for Perseus in the Python programming language. This page contains installation instructions and developer information on perseuspy, for high-level information please refer to the manuscript listed below.
perseuspy was designed to work in conjunction with the PluginInterop plugin, but can also be used stand-alone.
Citation
If you use perseuspy in your projects, please cite
Rudolph, J D and Cox, J 2018, A network module for the Perseus software for computational proteomics facilitates proteome interaction graph analysis doi:10.1101/447268.
Installation
perseuspy can be installed directly from pip. If you are new to Python, more detailed installation instructions for windows are provided below.
pip install perseuspy
Developing plugins
Perseus provides activities to call Python scripts from within the workflow via PluginInterop, e.g. Matrix => Python. Developing a plugin therefore translates to writing a Python script that follows a small set of conventions. By adhering to these conventions, Perseus will be able to successfully communicate with R and transfer inputs and results between the programs. perseuspy provides the neccessary functions to make plugin development in Python easy and straight forward.
Matrix plugin
This example Python script extracts the first 15 rows from the matrix. While its functionality is very simple. It can serve as a starting point for more extensive scripts.
import sys
from perseuspy import pd
from perseuspy.parameters import *
_, infile, outfile = sys.argv # read arguments from the command line
df = pd.read_perseus(infile) # read the input matrix into a pandas.DataFrame
df2 = df.head(15) # keep only the first 15 rows of the table
df2.to_perseus(outfile) # write pandas.DataFrame in Perseus txt format
Network plugin
The following snippet can be used as a starting point for network analyses.
import sys
from perseuspy import nx, pd, read_networks, write_networks
_, infolder, outfolder = sys.argv # read arguments from the command line
networks_table, networks = read_networks(infolder) # networks in tabular form
graphs = nx.from_perseus(networks_table, networks) # graphs as networkx objects
# perform some analysis
_networks_table, _networks = nx.to_perseus(graphs) # convert back into tabular form
write_networks(tmp_dir, networks_table, networks) # write to folder
Updating to the latest version
pip install --upgrade perseuspy
Installation (Windows long)
First open a terminal by searching for cmd.exe in the start menu. Here we can easily check if all required programs are installed.
Check to see if the pip executable is already available.
pip install perseuspy
If there is no error you are already done. If it fails, continue with the next steps.
Navigate to the installation directory of your Python installation. If it is installed e.g. D:/Programs/Python/ we would first change the drive letter (maybe unnecessary) and then go to the installation directory.
D: cd Programs/Python
Now we should be able to run python from the command line.
python.exe --version
This should print the installed version of python
Navigate to the Scripts directory and run the installation
cd Scripts pip install perseuspy
If you want to upgrade you installation, run
pip install --upgrade perseuspy
Test the installation by navigating back to the Python folder and trying to import perseuspy.
cd .. python.exe
Now you should be inside the python interpreter. Check the installation by running.
import perseuspy
If the command doesn’t produce any error you can exit python by pressing CTRL+c.
Add python to your PATH (optional, recommended). Makes it easier for Perseus to find the Python installation. There are many resources on how to add programs to the PATH available online. No description is provided here since instructions are specific to the version of Windows that is used.
Usage
You can use perseuspy just like any other python module.
# import a monkey-patched version of pandas
from perseuspy import pd
df = pd.read_perseus('matrix1.txt')
df2 = df.dropna()
df2.to_perseus('matrix2.txt')
Generating the developer documentation
Run ./generate_docs.sh from bash.
Licensing and Contributions
perseuspy is licensed under the MIT lisence. Contributions are welcome! If you are interested in contributing to code or documentation, please read CONTRIBUTING.rst.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file perseuspy-0.3.9.linux-x86_64.tar.gz
.
File metadata
- Download URL: perseuspy-0.3.9.linux-x86_64.tar.gz
- Upload date:
- Size: 27.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf91fde6f517bbec024d31ffe241d5bae9055742847bbac9ecaf67524072fb3f |
|
MD5 | 2c7c4d9959494c4d762d9fb5a2217a17 |
|
BLAKE2b-256 | ef08d06a48ecaad76657df941f1f616fcbc37e8526e4c08092fe3ce3b1b09c05 |
File details
Details for the file perseuspy-0.3.9-py3-none-any.whl
.
File metadata
- Download URL: perseuspy-0.3.9-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8929f196aa864fad2997d17d139f560a7ab8418c3c5ba11d74d3cee3df1e18b8 |
|
MD5 | acd1e285de3f26bd259c845c3e1aa2ec |
|
BLAKE2b-256 | cf66e2c5737567b6e7c369d1d75e2ba2fa03243e4dcea3fb46a31353fa734d7b |