Skip to content

Commit

Permalink
update pyo3
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuoqing Fang authored and Zhuoqing Fang committed Nov 26, 2024
1 parent c1eb602 commit 6a40c71
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package]
name = "gseapy"
version = "1.1.0"
version = "1.1.4"
authors = ["Zhuoqing Fang <[email protected]>"]
description = "Gene Set Enrichment Analysis in Rust."
license-file = "LICENSE.md"
Expand All @@ -25,7 +25,7 @@ extension-module = ["pyo3"]


[dependencies]
pyo3 = { version = "0.16.5", features = ["extension-module"], optional = true }
pyo3 = { version = "0.23.2", features = ["extension-module"], optional = true }
rand = {version = "*", features = ['small_rng']}
rayon = "*"
csv = "*"
Expand Down
46 changes: 45 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ fn gsea_rs(
/// - nperm: number of permutation
/// - threads: number of threads
/// - seed: random seed
/// #[pyo3(signature)]
#[pyfunction]
#[pyo3(signature = (gene_name, gene_exp, gene_sets, weight = 1.0, min_size = 5, max_size = 500, nperm = None, ctype = CorrelType::Rank, threads = 4,seed = 0))]
fn ssgsea_rs(
gene_name: Vec<String>,
gene_exp: Vec<Vec<f64>>,
Expand Down Expand Up @@ -173,6 +175,39 @@ fn ssgsea_rs(
}
Ok(gsea)
}
/// Run GSVA (Gene Set Variation Analysis)
///
/// Compute gene set variation scores from the input gene expression data
///
/// Parameters
/// ----------
/// gene_name: list-like of str
/// Gene names
/// gene_expr: array-like of float
/// Gene expression data
/// gene_sets: dict-like of str : list-like of str
/// Gene sets
/// kcdf: bool
/// Use kernel density estimation
/// rnaseq: bool
/// Use RNA-seq data
/// mx_diff: bool
/// Use maximum difference between genes
/// abs_rnk: bool
/// Use absolute rank
/// tau: float
/// Weight for pathway score
/// min_size: int
/// Minimum number of genes in a gene set
/// max_size: int
/// Maximum number of genes in a gene set
/// threads: int
/// Number of threads
///
/// Returns
/// -------
/// GSEAResult
/// A GSEAResult object containing the GSVA results
#[pyfunction]
fn gsva_rs(
gene_name: Vec<String>,
Expand All @@ -194,8 +229,17 @@ fn gsva_rs(
Ok(gs)
}

/// Python module for GSEA (Gene Set Enrichment Analysis) and ssGSEA
///
/// This module provides four functions:
///
/// - `gsea_rs`: performs GSEA
/// - `prerank_rs`: performs GSEA preranking
/// - `prerank2d_rs`: performs GSEA preranking with multiple input datasets
/// - `ssgsea_rs`: performs ssGSEA
/// - `gsva_rs`: performs GSVA
#[pymodule]
fn gse(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
fn gse(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> {
// m.add_class::<GSEAResult>()?;
m.add_class::<GSEASummary>()?;
m.add_class::<GSEAResult>()?;
Expand Down
8 changes: 4 additions & 4 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use rand::Rng;
use std::collections::HashMap;
use std::hash::Hash;

#[pyclass]
#[derive(Copy, Clone)]
#[pyclass(eq, eq_int)]
#[derive(Copy, Clone, PartialEq)]
pub enum Metric {
Signal2Noise = 0,
AbsSignal2Noise = 1,
Expand All @@ -23,8 +23,8 @@ pub enum Metric {
DiffOfClasses = 5,
}

#[pyclass]
#[derive(Copy, Clone)]
#[pyclass(eq, eq_int)]
#[derive(Copy, Clone, PartialEq)]
pub enum CorrelType {
Rank = 0,
SymRank = 1,
Expand Down

0 comments on commit 6a40c71

Please sign in to comment.