Skip to content

Commit

Permalink
Merge pull request #10 from infocusp/build_workflows
Browse files Browse the repository at this point in the history
workflows
  • Loading branch information
saurabhinfocusp authored Oct 3, 2024
2 parents 133400e + 5abd5fb commit 83aeb2b
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 62 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Publish package to PyPI

on:
push:
tags:
- 'v*' # Push events to tag which starts with v.

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
publish-to-pypi:
name: >-
Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyscalr
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
20 changes: 20 additions & 0 deletions .github/workflows/run_isort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Import checker"

on:
- push

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install isort
run: pip install isort
- name: Run isort
run: isort . --settings-path .isort.cfg
27 changes: 27 additions & 0 deletions .github/workflows/run_pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Run Unit Test via Pytest

on:
pull_request:
branches:
- main
push:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Running test cases
run: pytest -v -s
14 changes: 14 additions & 0 deletions .github/workflows/run_yapf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: YAPF Formatting Check

on: [push]

jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: run YAPF
uses: AlexanderMelde/yapf-action@master
with:
args: --verbose
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,3 @@ repos:
hooks:
- id: isort
args: ['--settings-path', '.isort.cfg']
- repo: local
hooks:
- id: pytest
name: Running test cases in pipeline...
entry: pytest -s -v
language: system
pass_filenames: false
stages: [commit]
39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[build-system]
requires = ["hatchling", "hatch-requirements-txt"]
build-backend = "hatchling.build"

[project]
name = "scaLR"
version = "0.0.1"
requires-python = ">=3.9"
authors = [
{ name="Infocusp", email="saurabh@infocusp.com" },
]
description = "scaLR: Single cell analysis using low resource."
readme = "README.md"
classifiers = [
"Programming Language :: Python :: 3.9",
"Operating System :: OS Independent",
"Intended Audience :: Science/Research"
]

dynamic = ["dependencies"]
[tool.hatch.build.targets.wheel]
packages = ["scalr"]

[tool.hatch.metadata.hooks.requirements_txt]
files = ["requirements.txt"]

[tool.hatch.build]
exclude = [
"docs/*",
"tutorials/*",
"tests/*",
]

license = {file = "LICENSE"}

[project.urls]
Repository = "https://github.com/infocusp/scaLR.git"
Homepage = "https://github.com/infocusp/scaLR"
Issues = "https://github.com/infocusp/scaLR/issues"
1 change: 0 additions & 1 deletion scalr/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
from .gene_recall_curve import GeneRecallCurve
from .heatmap import Heatmap
from .roc_auc import RocAucCurve

11 changes: 5 additions & 6 deletions scalr/analysis/dge_pseudobulk.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,11 @@ def plot_volcano(self, dge_results_df: DataFrame, cell_type: str,
dge_results_df['-log10(pvalue)'] = -np.log10(dge_results_df['pvalue'])

upregulated_gene = (dge_results_df['log2FoldChange'] >= log2_fold_chnage
) & (dge_results_df['-log10(pvalue)'] >=
(neg_log10_pval))
downregulated_gene = (dge_results_df['log2FoldChange'] <=
(-log2_fold_chnage)) & (
dge_results_df['-log10(pvalue)'] >=
(neg_log10_pval))
) & (dge_results_df['-log10(pvalue)']
>= (neg_log10_pval))
downregulated_gene = (dge_results_df['log2FoldChange'] <= (
-log2_fold_chnage)) & (dge_results_df['-log10(pvalue)']
>= (neg_log10_pval))

unsignificant_gene = dge_results_df['-log10(pvalue)'] <= (
neg_log10_pval)
Expand Down
53 changes: 29 additions & 24 deletions tutorials/analysis/differential_gene_expression/dge_lmem_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,40 @@

from scalr.analysis import DgeLMEM


def main(config):
test_data = sc.read_h5ad(config['full_datapath'],backed='r')
dirpath= config['dirpath']
dge_type= config['dge_type']
assert (dge_type=='DgeLMEM') and ('lmem_params' in config),(
test_data = sc.read_h5ad(config['full_datapath'], backed='r')
dirpath = config['dirpath']
dge_type = config['dge_type']
assert (dge_type == 'DgeLMEM') and ('lmem_params' in config), (
f"Check '{dge_type}' and 'lmem_params' in dge_config file")

lmem_params = config['lmem_params']
dge = DgeLMEM(
fixed_effect_column = lmem_params['fixed_effect_column'],
fixed_effect_factors = lmem_params['fixed_effect_factors'],
group = lmem_params['group'],
celltype_column = lmem_params.get('celltype_column',None),
cell_subsets = lmem_params.get('cell_subsets',None),
min_cell_threshold = lmem_params.get('min_cell_threshold',10),
n_cpu = lmem_params.get('n_cpu',6),
gene_batch_size = lmem_params.get('gene_batch_size',1000),
coef_threshold = lmem_params.get('coef_threshold',0),
p_val = lmem_params.get('p_val',0.05),
y_lim_tuple = lmem_params.get('y_lim_tuple',None),
save_plot = lmem_params.get('save_plot',True),
stdout = True)
dge.generate_analysis(test_data,dirpath)
dge = DgeLMEM(fixed_effect_column=lmem_params['fixed_effect_column'],
fixed_effect_factors=lmem_params['fixed_effect_factors'],
group=lmem_params['group'],
celltype_column=lmem_params.get('celltype_column', None),
cell_subsets=lmem_params.get('cell_subsets', None),
min_cell_threshold=lmem_params.get('min_cell_threshold', 10),
n_cpu=lmem_params.get('n_cpu', 6),
gene_batch_size=lmem_params.get('gene_batch_size', 1000),
coef_threshold=lmem_params.get('coef_threshold', 0),
p_val=lmem_params.get('p_val', 0.05),
y_lim_tuple=lmem_params.get('y_lim_tuple', None),
save_plot=lmem_params.get('save_plot', True),
stdout=True)

dge.generate_analysis(test_data, dirpath)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Dge analysis : LMEM method')
parser.add_argument('--config','-c',type=str,required=True,help='Path to input dge_config.yaml file')
parser.add_argument('--config',
'-c',
type=str,
required=True,
help='Path to input dge_config.yaml file')
argument = parser.parse_args()
with open(argument.config,'r') as config_file:
with open(argument.config, 'r') as config_file:
config = yaml.safe_load(config_file)
main(config)
main(config)
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,40 @@

from scalr.analysis import DgePseudoBulk


def main(config):
test_data = sc.read_h5ad(config['full_datapath'],backed='r')
dirpath= config['dirpath']
dge_type= config['dge_type']
assert (dge_type=='DgePseudoBulk') and ('psedobulk_params' in config),(
test_data = sc.read_h5ad(config['full_datapath'], backed='r')
dirpath = config['dirpath']
dge_type = config['dge_type']
assert (dge_type == 'DgePseudoBulk') and ('psedobulk_params' in config), (
f"Check '{dge_type}' and 'psedobulk_params' in dge_config file")

psedobulk_params = config['psedobulk_params']
dge = DgePseudoBulk(
celltype_column = psedobulk_params.get('celltype_column'),
design_factor = psedobulk_params['design_factor'],
factor_categories = psedobulk_params['factor_categories'],
sum_column = psedobulk_params['sum_column'],
cell_subsets = psedobulk_params.get('cell_subsets',None),
min_cell_threshold = psedobulk_params.get('min_cell_threshold',10),
fold_change = psedobulk_params.get('fold_change',1.5),
p_val = psedobulk_params.get('p_val',0.05),
y_lim_tuple = psedobulk_params.get('y_lim_tuple',None),
save_plot = psedobulk_params.get('save_plot',True),
stdout = True)

dge.generate_analysis(test_data,dirpath)
dge = DgePseudoBulk(celltype_column=psedobulk_params.get('celltype_column'),
design_factor=psedobulk_params['design_factor'],
factor_categories=psedobulk_params['factor_categories'],
sum_column=psedobulk_params['sum_column'],
cell_subsets=psedobulk_params.get('cell_subsets', None),
min_cell_threshold=psedobulk_params.get(
'min_cell_threshold', 10),
fold_change=psedobulk_params.get('fold_change', 1.5),
p_val=psedobulk_params.get('p_val', 0.05),
y_lim_tuple=psedobulk_params.get('y_lim_tuple', None),
save_plot=psedobulk_params.get('save_plot', True),
stdout=True)

dge.generate_analysis(test_data, dirpath)


if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Dge analysis : psedobulk method')
parser.add_argument('--config','-c',type=str,required=True,help='Path to input dge_config.yaml file')
parser = argparse.ArgumentParser(
description='Dge analysis : psedobulk method')
parser.add_argument('--config',
'-c',
type=str,
required=True,
help='Path to input dge_config.yaml file')
argument = parser.parse_args()
with open(argument.config,'r') as config_file:
with open(argument.config, 'r') as config_file:
config = yaml.safe_load(config_file)
main(config)
main(config)

0 comments on commit 83aeb2b

Please sign in to comment.