Skip to content

Commit 781ec0c

Browse files
committed
v0.1.0
1 parent 75312ee commit 781ec0c

7 files changed

Lines changed: 106 additions & 14 deletions

File tree

.github/workflows/publish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # Trigger the workflow only when a tag starting with "v" is pushed (e.g., v0.1.0)
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
# Step 1: Check out the repository
14+
- name: Check out code
15+
uses: actions/checkout@v3
16+
17+
# Step 2: Set up Python
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.8" # Specify the Python version
22+
23+
# Step 3: Install dependencies
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install build twine
28+
29+
# Step 4: Build the package
30+
- name: Build the package
31+
run: python -m build
32+
33+
# Step 5: Publish to PyPI
34+
- name: Publish to PyPI
35+
env:
36+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
37+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
38+
run: twine upload dist/*

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
*.egg-info/
3+
dist/
4+
build/
5+
__pycache__/

mutclust/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
MutClust: A package for mutual rank-based clustering and GO enrichment analysis.
44
"""
55

6+
# Version of the MutClust package
67
__version__ = "0.1.0"

mutclust/annotate.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import pandas as pd
22

3-
def add_gene_annotations(cluster_df, path_annot):
4-
annot = pd.read_csv(path_annot, sep="\t")
5-
6-
cluster_df = cluster_df.merge(annot, on="geneID", how="left")
7-
8-
return(cluster_df)
3+
def add_gene_annotations(cluster_df, annotations):
4+
if isinstance(annotations, str): # If a file path is provided
5+
annotations = pd.read_csv(annotations, sep="\t")
6+
cluster_df = cluster_df.merge(annotations, on="geneID", how="left")
7+
return cluster_df

mutclust/gene_clustering.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
def filter_to_long_array(mr_df, threshold=100):
7+
mr_df = mr_df.astype(float)
78
mr_df.values[np.tril_indices_from(mr_df, k=0)] = np.inf
89
rows, cols = np.where(mr_df < threshold)
910
values = mr_df.values[rows, cols]

pyproject.toml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[build-system]
2-
requires = ["setuptools", "setuptools-scm"]
2+
requires = ["setuptools>=61.0.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
name = "mutclust"
6+
name = "MutClust"
7+
version = "0.1.0"
78
authors = [
89
{name = "Elly Poretsky", email = "eporetsky@plantapp.org"},
910
]
10-
description = "MutClust: Mutual rank-based clustering and GO enrichment analysis."
11+
description = "MutClust: Mutual rank-based coexpression, clustering and GO term enrichment analysis."
1112
readme = "README.md"
12-
requires-python = ">=3.8"
1313
keywords = ["bioinformatics", "coexpression", "mutual rank", "clustering", "leiden", "gene ontology", "RNA-seq", "metabolomics"]
14-
license = {text = "MIT"}
14+
license = { file = "LICENSE" }
1515
classifiers = [
1616
"Programming Language :: Python :: 3",
1717
"License :: OSI Approved :: MIT License",
@@ -26,15 +26,25 @@ dependencies = [
2626
"goatools",
2727
'importlib-metadata; python_version<"3.10"',
2828
]
29-
dynamic = ["version"]
29+
requires-python = ">=3.8"
3030

3131
[tool.setuptools.packages]
3232
# Explicitly include only the 'mutclust' directory
3333
find = { include = ["mutclust"]}
3434

3535
[project.optional-dependencies]
36-
dev = ["pytest", "black", "flake8"]
37-
docs = ["sphinx", "sphinx-rtd-theme"]
36+
dev = [
37+
"pytest", # For running tests
38+
"pytest-cov", # For test coverage reports
39+
"black", # For code formatting
40+
"flake8", # For linting
41+
"mypy", # For type checking
42+
"pre-commit" # For managing pre-commit hooks
43+
]
44+
docs = [
45+
"sphinx", # For generating documentation
46+
"sphinx-rtd-theme" # For the ReadTheDocs theme
47+
]
3848

3949
[project.scripts]
4050
mutclust = "mutclust.__main__:main"

tests/test_mutclust.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pytest
2+
import pandas as pd
3+
from mutclust.gene_clustering import filter_to_long_array, filter_and_apply_decay
4+
from mutclust.annotate import add_gene_annotations
5+
6+
def test_filter_to_long_array():
7+
# Create a mock mutual rank DataFrame
8+
data = {
9+
"GeneA": [0, 50, 200],
10+
"GeneB": [50, 0, 75],
11+
"GeneC": [200, 75, 0],
12+
}
13+
mr_df = pd.DataFrame(data, index=["GeneA", "GeneB", "GeneC"])
14+
long_array = filter_to_long_array(mr_df, threshold=100)
15+
assert len(long_array) == 2 # Only two pairs should pass the threshold
16+
17+
def test_filter_and_apply_decay():
18+
# Create a mock long array
19+
long_array = pd.DataFrame({
20+
"Gene1": [0, 1],
21+
"Gene2": [1, 2],
22+
"MR": [10, 20] # Adjusted MR values to ensure ED > 0.01
23+
})
24+
gene_id_mapping = {0: "GeneA", 1: "GeneB", 2: "GeneC"}
25+
filtered_array = filter_and_apply_decay(gene_id_mapping, long_array, e_val=10)
26+
assert "ED" in filtered_array.columns
27+
assert len(filtered_array) == 2 # Both pairs should pass the decay filter
28+
29+
def test_add_gene_annotations():
30+
# Create mock cluster and annotation data
31+
cluster_df = pd.DataFrame({"geneID": ["GeneA", "GeneB"]})
32+
annotations = pd.DataFrame({
33+
"geneID": ["GeneA", "GeneB"],
34+
"description": ["Protein A", "Protein B"]
35+
})
36+
annotated_df = add_gene_annotations(cluster_df, annotations)
37+
assert "description" in annotated_df.columns
38+
assert annotated_df.loc[0, "description"] == "Protein A"

0 commit comments

Comments
 (0)