Skip to content

Commit

Permalink
Merge pull request #8 from lldelisle/switch_pyprojecttoml
Browse files Browse the repository at this point in the history
Switch pyprojecttoml
  • Loading branch information
lldelisle authored May 8, 2024
2 parents 5936a6c + 1162f94 commit 7018a57
Show file tree
Hide file tree
Showing 82 changed files with 11,366 additions and 11,405 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@ jobs:

runs-on: ubuntu-latest

permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write

steps:
- uses: actions/checkout@v3
- uses: mamba-org/setup-micromamba@main
- name: Set up Python
uses: actions/setup-python@v3
with:
environment-file: ./baredSC_dev_env.yml
cache-downloads: true
environment-name: baredSC_dev
- name: pip install
python-version: '3.10'
- name: Install dependencies
run: |
micromamba activate baredSC_dev
python -m pip install --upgrade pip
pip install build
pip install .
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_BAREDSC_API_TOKEN }}
uses: pypa/[email protected]
6 changes: 5 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
# Required
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
Expand All @@ -15,6 +20,5 @@ formats:

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
2 changes: 0 additions & 2 deletions baredSC/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@
on the probability density function (PDF) of expression of one or two genes
from single-cell RNA-seq data. It uses the raw counts and the total number of UMI for each cell.
"""

from . _version import __version__
5 changes: 0 additions & 5 deletions baredSC/_version.py

This file was deleted.

13 changes: 10 additions & 3 deletions baredSC/baredSC_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Runner for baredSC_1d
"""

import argparse
import sys
import os
from itertools import permutations
Expand All @@ -13,8 +14,8 @@

# Local imports
from . common import permuted, get_Ax, \
plot_QC, get_bins_centers, parse_arguments, checkNeff, args_check_baredSC, \
get_data_from_args
plot_QC, get_bins_centers, common_parse_arguments, checkNeff, \
args_check_baredSC, get_data_from_args
from . oned import logprob, extract_from_npz, write_evidence, \
get_pdf, plots_from_pdf, args_check

Expand Down Expand Up @@ -188,11 +189,17 @@ def plot(oxpdf, x, logprob_values, samples, title, output, data, col_gene,
plots_from_pdf(x, pdf, title, output, data, col_gene, osampx, xscale, target_sum)


def parse_arguments() -> argparse.ArgumentParser:
"""Argument parser for baredSC_1d
"""
return common_parse_arguments('baredSC_1d')


def main(args=None):
"""Main function of baredSC_1d
"""
original_args = sys.argv[1:]
args = parse_arguments('baredSC_1d').parse_args(args)
args = parse_arguments().parse_args(args)
args = args_check_baredSC(args)
# Update args and check
args = args_check(args)
Expand Down
13 changes: 10 additions & 3 deletions baredSC/baredSC_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Runner for baredSC_2d
"""

import argparse
import sys
import os
from itertools import permutations
Expand All @@ -14,8 +15,8 @@

# Local imports
from . common import permuted, get_Ax, get_prefix_suffix, \
plot_QC, get_bins_centers, parse_arguments, checkNeff, args_check_baredSC, \
get_data_from_args
plot_QC, get_bins_centers, common_parse_arguments, checkNeff, \
args_check_baredSC, get_data_from_args
from . twod import logprob, extract_from_npz, write_evidence, \
get_pdf, plots_from_pdf, args_check

Expand Down Expand Up @@ -289,11 +290,17 @@ def plot(oxpdf, oypdf, x, y, logprob_values, samples,
Neff)


def parse_arguments() -> argparse.ArgumentParser:
"""Argument parser for baredSC_2d
"""
return common_parse_arguments('baredSC_2d')


def main(args=None):
"""Main function of baredSC_2d
"""
original_args = sys.argv[1:]
args = parse_arguments('baredSC_2d').parse_args(args)
args = parse_arguments().parse_args(args)
args = args_check_baredSC(args)
# Update args and check
args = args_check(args)
Expand Down
11 changes: 9 additions & 2 deletions baredSC/combineMultipleModels_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
"""
Runner for combineMultipleModels_1d
"""
import argparse
import sys
import os
from tempfile import NamedTemporaryFile

import numpy as np

# Local imports
from . common import get_bins_centers, parse_arguments, \
from . common import get_bins_centers, common_parse_arguments, \
get_data_from_args
from . oned import logprob, extract_from_npz, write_evidence, \
get_pdf, plots_from_pdf, args_check
Expand Down Expand Up @@ -96,10 +97,16 @@ def plot_combined(all_results, all_logevid, title, output, data, col_gene,
return None


def parse_arguments() -> argparse.ArgumentParser:
"""Argument parser for combineMultipleModels_1d
"""
return common_parse_arguments('combineMultipleModels_1d')


def main(args=None):
"""Main function of combineMultipleModels_1d
"""
args = parse_arguments('combineMultipleModels_1d').parse_args(args)
args = parse_arguments().parse_args(args)
# Update args and check
args = args_check(args)
# Check the directory of args.figure is writtable:
Expand Down
11 changes: 9 additions & 2 deletions baredSC/combineMultipleModels_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Runner for combineMultipleModels_2d
"""
import argparse
import sys
import os
from tempfile import NamedTemporaryFile
Expand All @@ -10,7 +11,7 @@

# Local imports
from . common import get_bins_centers, \
get_Neff, parse_arguments, get_data_from_args
get_Neff, common_parse_arguments, get_data_from_args
from . twod import logprob, extract_from_npz, write_evidence, \
get_pdf, plots_from_pdf, args_check

Expand Down Expand Up @@ -136,10 +137,16 @@ def plot_combined(all_results, all_logevid, title, output,
return None


def parse_arguments() -> argparse.ArgumentParser:
"""Argument parser for combineMultipleModels_2d
"""
return common_parse_arguments('combineMultipleModels_2d')


def main(args=None):
"""Main function of combineMultipleModels_2d
"""
args = parse_arguments('combineMultipleModels_2d').parse_args(args)
args = parse_arguments().parse_args(args)
# Update args and check
args = args_check(args)

Expand Down
7 changes: 3 additions & 4 deletions baredSC/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import time
from tempfile import NamedTemporaryFile
from shutil import copy
from importlib.metadata import version
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
Expand All @@ -16,8 +17,6 @@
import anndata
from samsam import acf

from . _version import __version__

mpl.use('agg')


Expand Down Expand Up @@ -388,7 +387,7 @@ def get_bins_centers(xmin, xmax, nx):
return (x_borders[:-1] + x_borders[1:]) / 2


def parse_arguments(tool: str) -> argparse.ArgumentParser:
def common_parse_arguments(tool: str) -> argparse.ArgumentParser:
"""Argument parser for all 4 tools
"""
docu_ref = "The full documentation is available at https://baredsc.readthedocs.io"
Expand Down Expand Up @@ -592,7 +591,7 @@ def parse_arguments(tool: str) -> argparse.ArgumentParser:
help="Size of sampling of random parameters in logevidence evaluation.")
# Version
argp.add_argument('--version', action='version',
version=__version__)
version=version('baredSC'))
return argp


Expand Down
2 changes: 1 addition & 1 deletion baredSC/tests/test_baredSC_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

BARED_1D_TEXT_SUFFIX = ['_neff.txt', '_p.txt', '_pdf.txt', '_posterior_per_cell.txt']

TOLERENCE = 18 # default matplotlib pixed difference tolerance
TOLERENCE = 13 # default matplotlib pixed difference tolerance


def test_baredSC_1d_1gauss_default():
Expand Down
9 changes: 7 additions & 2 deletions baredSC/tests/test_baredSC_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
from tempfile import NamedTemporaryFile
import os.path
import platform
import matplotlib as mpl
from matplotlib.testing.compare import compare_images
import baredSC.baredSC_2d
Expand All @@ -20,7 +21,7 @@

BARED_2D_TEXT_SUFFIX = ['_neff.txt', '_p.txt', '_corr.txt', '_pdf2d.txt', '_pdf2d_flat.txt']

TOLERENCE = 13 # default matplotlib pixed difference tolerance
TOLERENCE = 19 # default matplotlib pixed difference tolerance


def test_baredSC_2d_1gauss_small():
Expand All @@ -45,7 +46,11 @@ def test_baredSC_2d_1gauss_small():
f"--figure {outfig.name} " \
f"--logevidence {outfile_evid.name}".split()
baredSC.baredSC_2d.main(args)
for suffix in BARED_2D_IMAGES_SUFFIX:
if platform.system() == "Linux":
suffix_to_test = BARED_2D_IMAGES_SUFFIX
else:
suffix_to_test = ['', '_median']
for suffix in suffix_to_test:
expected_file = f'{expected}{suffix}.{extension}'
obtained_file = f'{outfig_base}{suffix}.{extension}'
res = compare_images(expected_file,
Expand Down
7 changes: 6 additions & 1 deletion baredSC/tests/test_combine_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
from tempfile import NamedTemporaryFile
import os.path
import platform
import matplotlib as mpl
from matplotlib.testing.compare import compare_images
import baredSC.combineMultipleModels_2d
Expand Down Expand Up @@ -40,7 +41,11 @@ def test_combine_2d_test1():
f"--outputs {ROOT}/2d_small_1gauss {ROOT}/2d_small_2gauss " \
f"--figure {outfig.name}".split()
baredSC.combineMultipleModels_2d.main(args)
for suffix in BARED_2D_IMAGES_SUFFIX:
if platform.system() == "Linux":
suffix_to_test = BARED_2D_IMAGES_SUFFIX
else:
suffix_to_test = ['', '_median']
for suffix in suffix_to_test:
expected_file = f'{expected}{suffix}.{extension}'
obtained_file = f'{outfig_base}{suffix}.{extension}'
res = compare_images(expected_file,
Expand Down
Binary file modified baredSC/tests/test_data/2d_small_1gauss.npz
Binary file not shown.
Binary file modified baredSC/tests/test_data/2d_small_2gauss.npz
Binary file not shown.
Binary file modified baredSC/tests/test_data/2d_small_2gauss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified baredSC/tests/test_data/2d_small_2gauss_convergence.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified baredSC/tests/test_data/2d_small_2gauss_corner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion baredSC/tests/test_data/2d_small_2gauss_corr.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mean median low high pval error
0.902971588834658 0.9030205591240211 0.8808479278110088 0.9249439927709214 0.007859609399117668 0.007859609399117668
0.9029716395251455 0.9030200651684039 0.8808479278441326 0.9249441195524556 0.007859623867374954 0.007859623867374954
Binary file modified baredSC/tests/test_data/2d_small_2gauss_individuals.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified baredSC/tests/test_data/2d_small_2gauss_median.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion baredSC/tests/test_data/2d_small_2gauss_neff.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
127.23278590819812
127.23255169384986
Binary file modified baredSC/tests/test_data/2d_small_2gauss_p.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions baredSC/tests/test_data/2d_small_2gauss_p.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name low median high
xy_mux0 0.3421735749355604 0.36400142067277885 0.38414407467979367
xy_muy0 0.3602753667616778 0.3797834812619477 0.3997083085113705
xy_scalex0 0.128373484740148 0.13754306887169315 0.154475100117708
xy_scaley0 0.11267797849970684 0.13404387324572375 0.1636497454683696
xy_corr0 -0.056936609709389754 0.20134274953150133 0.4823245136404016
xy_amp1 0.4683630960583824 0.4935067017747425 0.5184297378623833
xy_mux1 0.9950898144773097 1.0128387895441175 1.0323483080264237
xy_muy1 0.9882799141570242 1.0073935336038764 1.0262810747590292
xy_scalex1 0.12680233831791496 0.1317913482460104 0.1439711554909536
xy_scaley1 0.10695025120288884 0.11525119819932761 0.13138587521715606
xy_corr1 0.27825576244514594 0.5311286235242539 0.7541979912185461
xy_mux0 0.3421738328109765 0.36400189932266336 0.3841440747553726
xy_muy0 0.3602753667866474 0.3797834812932726 0.39970830854564193
xy_scalex0 0.12837392956595675 0.13754306888676632 0.1544751002101545
xy_scaley0 0.11267797846698233 0.1340437185508837 0.16364975095169854
xy_corr0 -0.05693660975737857 0.20134265783169808 0.4823245134294125
xy_amp1 0.4683630960248498 0.49350668946491333 0.5184297378980278
xy_mux1 0.9950898816264488 1.012838789457257 1.0323483079969673
xy_muy1 0.9882799141741364 1.0073935335689348 1.0262810747408535
xy_scalex1 0.12680170616971262 0.13179069883831943 0.14397113027517466
xy_scaley1 0.1069508246498268 0.11525151370549018 0.13138555730081636
xy_corr1 0.27825576227578863 0.5311286284596629 0.7541981226602934
Loading

0 comments on commit 7018a57

Please sign in to comment.