Skip to main content

The pathway scoring algorithm as a python package.

Project description

GSNetAct

Please cite this repository if you use this code in your work.

Prerequisites

  • Tested only on python 3.12, should work python 3.7+
  • Numpy
  • Scanpy
  • Dataclasses
  • Json
  • Scikit-learn (Should come with scanpy but still)

Installing

  • Clone the repository from this source.
git clone https://github.com/BMGLab/pathway_scorers
  • Then inside the project directory, do
pip install .

The package should be installed. You can use the -e flag for automatic updates.

Usage

You can use every part of this package to develop a further approach to this algorithm. But for simple analysis, a basic use case below would be :

#!/usr/bin/env python

from gsnetact import createAdataObject

import pandas as pd

json_file_path = "Your Json File Path Containing Genesets and Their Relations."
annData_path = "Your Expressions File Path, Containing Gene Expression Data That Can Be Interpreted as AnnData by Scanpy."

analysis_result_as_annData = createAdataObject(annData_path,json_file_path,normalized=True)

df = pd.DataFrame(analysis_result_as_annData.X)
df.columns = analysis_result_as_annData.var

df.to_csv("output.csv",sep="\t")

This code firstly imports the createObject from the package, which is used for creating an AnnData object using the analysis results. Then, we specify our file paths. The pathwayScoring package needs two file inputs, one gene expression data file, and one JSON file that contains genesets and their relations. We then call the createObject function to get our files, analyzes them using the pathwayScoring's respected algorihm and creates an AnnData object using scanpy. We can use this object any way we want, for here it is used for creating a csv file that contains the scorings.

For further explanation, check the test files in test/ folder.

File Format for Genesets

The file that contains genesets and their relations has to be like this :

{
	"GeneSet1": {
		"Gene1": {
			"Gene2": 0.35,
			"Gene3": 0.77,
			"Gene4": 0.16
		},
		"Gene2": {
			"Gene1": 0.35,
			"Gene3": 0.51
		},
		"Gene3": {
			"Gene1": 0.77,
			"Gene2": 0.51,
			"Gene4": 0.40
		},
		"Gene4": {
			"Gene1": 0.16,
			"Gene3": 0.40
		}
	},
	"GeneSet2": {
		"Gene1": {
			"Gene2": 0.99
		},
		"Gene2": {
			"Gene1": 0.99
		}
	}
}

Here, GeneSet1 looks like this:

Graph for GeneSet1

You can create this format easily though, check below.

JSON Creator Tool

You can create the needed JSON file containing genesets with the data from msigdb databases. All you need to do is :

#!/usr/bin/env python

from gsnetact import makeJson

makeJson("Path to your msigdb JSON file.","Name of the JSON file containing genesets, name them whatever you want.")

The makeJson function takes your geneset names from msigdb data and finds the relations between individual genes using the STRING database.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gsnetact-0.0.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gsnetact-0.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file gsnetact-0.0.1.tar.gz.

File metadata

  • Download URL: gsnetact-0.0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for gsnetact-0.0.1.tar.gz
Algorithm Hash digest
SHA256 79e87f9778a6c0adc72ab88432253bc909bced12664e6eb25098a1bbae56a81f
MD5 4d9f2d88a875c90b0fbeff5e192941af
BLAKE2b-256 269fc70d93f308948065e72875a1dfdb6b7841c3266336fa44f125a4ae50d55e

See more details on using hashes here.

File details

Details for the file gsnetact-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: gsnetact-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for gsnetact-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd2351677846b46dffefb43ec57dcd314fcae4fdb154349e0f4efa38a212dbc4
MD5 26de8ebf1aa98e00a1e5bf93aa14c5ad
BLAKE2b-256 879c90ca492c7d7ad3cd961956403c0f7d1a92d4f6389d006f606585ca8c183b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page