Skip to content
/ RASpy Public

RASpy: a Scanpy Extension for Metabolic ReactionActivity Analysis

Notifications You must be signed in to change notification settings

CompBtBs/RASpy

Repository files navigation

Raspy : RASpy: Metabolic Reaction Activity Analysis with Scanpy

  • Install Python (from release version 3.0 on)
  • You can find the requirements in the requirements.txt file and install them through the following commands:
pip install -r requirements.txt
  • Using terminal, navigate to the favourite installation directory and run the following Git command:
git clone https://github.com/compBtBs/RASpy.git
  • RAS computation
  • RAS cluster analysis
  • Deferentially Expressed Reactions analysis
  • Color a metabolic map (SVG Escher format) using RAS fold-change

To easily understand how to use RASPY, we invite you to try our notebook tutorial Tutorial

Other examples of use can be found in the notebook_examples directory.

Notebooks
Name Link
How to prepare a count matrix for RAS computation Notebook1
How to compute a RAS matrix Notebook2
How to perform RAS cluster analysis Notebook3
How to remove cell cycle effect from RAS matrix Notebook4

You can load any count matrix file using any read function from scanpy tool. For example, you can load a h5ad file in the following way:

import scanpy as sc
adata=sc.read_h5ad(name_of_count_matrix)

The dataset is saved in an AnnData object from Scanpy. We provided two example of public datasets in the datasets directory. * The first dataset (E-GEOD-86618), is provided as TPM matrix and considers human lung epithelial cell types involved in the pathogenesis of Idiopathic pulmonary fibrosis (IPF). * The second dataset (GSE110949), is provided as Raw count matrix, and considers MDA-MB-231 cell line adapted to culture in media containing 0 mM or 2 mM metformin.

You can load any metabolic model using any read function from Cobrapy tool. For example, you can load a SBML model in the following way:

from cobra.io import read_sbml_model
model=read_sbml_model(name_of_sbml_model)

As example of metabolic model, we have included the RECON3D model from http://bigg.ucsd.edu/models, where we convert the gene annotation both in ENSG and Gene symbol.

Once you have a metabolic model and a count matrix, you can use a RAS_computation object in the following way:

from ras import RAS_computation as rc
#%% inizialize ras object
ras_object=rc(adata,model)
#%% Compute ras
ras_adata=ras_object.compute()

The RAS dataset is saved in an AnnData object. See Notebook2 for more details.

WARNING: Make sure that gene annotation for count matrix and metabolic model must be the same.

Once you have computed the RAS dataset, you can perform a cluster analysis, using the Scanpy tool. For example, you can use the following code to clusters the cells with the Leiden algorithm.

import scanpy as sc
sc.tl.pca(ras_adata, svd_solver='arpack'))
sc.pp.neighbors(ras_adata)
sc.tl.leiden(ras_adata)
sc.tl.umap(ras_adata)
sc.pl.umap(ras_adata, color=["leiden"])

See Notebook3 for more details.

Suppose that you want to characterize the metabolic differences between two groups of cells (e.g. cancer vs normal cells). Starting from the ras_adata matrix you can use the computer_diff method to obtain a list of reactions whose RASs results statistically different (up-regulated or down-regulated) as follow:

df_comparison=ras_object.compute_diff(ras_adata,name_feature)

where name_feature is the key of the observations grouping to consider. The object df_comparison is a table reporting the fold change between RASs of the two groups, after the application of a statistical test (t-test by default).

Once you have obtained the dataframe of statistically different reactions (up- or down- regulated) between two groups of cells, you can visualize it on a metabolic map (in ESCHER svg format) using the colorMap method

from ras import RAS_map
import numpy as np
met_map=RAS_map()
image=met_map.colorMap(mapNetwork,mapNetwork2,df_comparison)

where mapNetwork is the name of the SVG input metabolic map and mapNetwork2 is the name of the SVG output metabolic map. Up regulated reaction are coloured in red, whereas down-regulated reaction are coloured in blue.

About

RASpy: a Scanpy Extension for Metabolic ReactionActivity Analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published