-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
9,196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Test | ||
on: [push, pull_request] | ||
|
||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
|
||
jobs: | ||
build-linux: | ||
name: Test on Linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: mamba-org/setup-micromamba@main | ||
with: | ||
environment-file: ./baredSC_dev_env.yml | ||
cache-downloads: true | ||
environment-name: baredSC_dev | ||
- name: pip install | ||
run: | | ||
micromamba activate baredSC_dev | ||
pip install . | ||
- name: Test baredSC | ||
run: | | ||
micromamba activate baredSC_dev | ||
pytest -v | ||
- name: make an artifact | ||
run: | | ||
micromamba activate baredSC_dev | ||
rm -f dist/* | ||
python -m build | ||
- uses: actions/upload-artifact@master | ||
with: | ||
name: "Dist files" | ||
path: "dist" | ||
test-wheels: | ||
name: test wheel | ||
runs-on: ubuntu-latest | ||
needs: build-linux | ||
strategy: | ||
matrix: | ||
python-version: ['3.7','3.8','3.9','3.10', '3.11'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: "Dist files" | ||
path: ~/dist/ | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
- name: install wheel | ||
run: | | ||
pip install ~/dist/*whl | ||
baredSC_1d -h | ||
- name: pytest | ||
run: | | ||
pip install pytest | ||
pytest -v | ||
build-osx: | ||
name: Test on OSX | ||
runs-on: macOS-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: mamba-org/setup-micromamba@main | ||
with: | ||
environment-file: .github/baredSC_dev.yml | ||
cache-downloads: true | ||
environment-name: baredSC_dev | ||
- name: pip install | ||
run: | | ||
micromamba activate baredSC_dev | ||
pip install . | ||
- name: Test baredSC | ||
run: | | ||
micromamba activate baredSC_dev | ||
pytest -v |
Binary file added
BIN
+3.79 KB
baredSC/tests/__pycache__/test_baredSC_1d.cpython-311-pytest-7.4.2.pyc
Binary file not shown.
Binary file added
BIN
+5.14 KB
baredSC/tests/__pycache__/test_baredSC_1d.cpython-312-pytest-7.4.2.pyc
Binary file not shown.
Binary file added
BIN
+3.42 KB
baredSC/tests/__pycache__/test_baredSC_2d.cpython-312-pytest-7.4.2.pyc
Binary file not shown.
Binary file added
BIN
+3.24 KB
baredSC/tests/__pycache__/test_combine_1d.cpython-312-pytest-7.4.2.pyc
Binary file not shown.
Binary file added
BIN
+3.32 KB
baredSC/tests/__pycache__/test_combine_2d.cpython-312-pytest-7.4.2.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
# baredSC_1d | ||
baredSC_1d \ | ||
--input baredSC/tests/test_data/nih3t3_generated_2d_2.txt \ | ||
--geneColName 0.5_0_0_0.5_x \ | ||
--output example/first_example_1d_1gauss \ | ||
--nnorm 1 \ | ||
--figure example/first_example_1d_1gauss.png \ | ||
--title "first gene 1 gauss" \ | ||
--logevidence example/first_example_1d_1gauss_logevid.txt | ||
baredSC_1d \ | ||
--input baredSC/tests/test_data/nih3t3_generated_2d_2.txt \ | ||
--metadata1ColName 0_0.5_0.5_0_group \ | ||
--metadata1Values 1.0 \ | ||
--xmin -15 \ | ||
--xmax -7 \ | ||
--nx 25 \ | ||
--xscale log \ | ||
--minNeff 400 \ | ||
--geneColName 0.5_0_0_0.5_x \ | ||
--output example/first_example_1d_2gauss_log \ | ||
--nnorm 2 \ | ||
--figure example/first_example_1d_2gauss_log.pdf \ | ||
--title "first gene 2 gauss log scale" \ | ||
--logevidence example/first_example_1d_2gauss_log_logevid.txt | ||
|
||
# Combined_1d | ||
for nnorm in 1 2; do | ||
baredSC_1d --input baredSC/tests/test_data/nih3t3_generated_2d_2.txt --geneColName 0.5_0_0_0.5_x --nnorm ${nnorm} --output baredSC/tests/test_data/small_${nnorm}gauss --nx 10 --nsampMCMC 20000 --force | ||
done | ||
combineMultipleModels_1d --input baredSC/tests/test_data/nih3t3_generated_2d_2.txt --geneColName 0.5_0_0_0.5_x \ | ||
--outputs baredSC/tests/test_data/small_1gauss baredSC/tests/test_data/small_2gauss \ | ||
--nx 10 --title 'first gene combine 1 and 2 gauss' --prettyBins 100 --figure baredSC/tests/test_data/combine_test1.png | ||
|
||
# baredSC 2d prep | ||
for nnorm in 1 2; do | ||
baredSC_2d --input baredSC/tests/test_data/nih3t3_generated_2d_2.txt --geneXColName '0.5_0_0_0.5_x' --geneYColName '0.5_0_0_0.5_y' --nnorm ${nnorm} --output baredSC/tests/test_data/2d_small_${nnorm}gauss --nx 10 --ny 12 --nsampMCMC 20000 --force | ||
done | ||
|
||
# baredSC 2d plot | ||
nnorm=2 | ||
baredSC_2d --input baredSC/tests/test_data/nih3t3_generated_2d_2.txt --geneXColName '0.5_0_0_0.5_x' --geneYColName '0.5_0_0_0.5_y' --nnorm ${nnorm} --output baredSC/tests/test_data/2d_small_${nnorm}gauss --nx 10 --ny 12 --nsampMCMC 20000 --figure baredSC/tests/test_data/2d_small_${nnorm}gauss.png --prettyBinsx 50 --prettyBinsy 50 | ||
|
||
# combined_2d | ||
combineMultipleModels_2d --input baredSC/tests/test_data/nih3t3_generated_2d_2.txt --geneXColName '0.5_0_0_0.5_x' --geneYColName '0.5_0_0_0.5_y' \ | ||
--outputs baredSC/tests/test_data/2d_small_1gauss baredSC/tests/test_data/2d_small_2gauss \ | ||
--nx 10 --ny 12 --prettyBinsx 50 --prettyBinsy 50 \ | ||
--figure baredSC/tests/test_data/2d_small_combined.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# -*- coding: utf-8 -*- | ||
""" Test for baredSC_1d | ||
""" | ||
from tempfile import NamedTemporaryFile | ||
import os.path | ||
import matplotlib as mpl | ||
from matplotlib.testing.compare import compare_images | ||
import baredSC.baredSC_1d | ||
|
||
mpl.use('agg') | ||
|
||
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
"test_data") | ||
|
||
EXAMPLE = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
"..", "..", "example") | ||
|
||
BARED_1D_IMAGES_SUFFIX = ['', '_convergence', '_p', '_corner', '_individuals', | ||
'_with_posterior', '_posterior_individuals', | ||
'_posterior_andco'] | ||
|
||
BARED_1D_TEXT_SUFFIX = ['_neff.txt', '_p.txt', '_pdf.txt', '_posterior_per_cell.txt'] | ||
|
||
TOLERENCE = 13 # default matplotlib pixed difference tolerance | ||
|
||
|
||
def test_baredSC_1d_1gauss_default(): | ||
"""First test matching example | ||
""" | ||
extension = 'png' | ||
expected = os.path.join(EXAMPLE, 'first_example_1d_1gauss') | ||
outfile = NamedTemporaryFile(prefix='baredSC_test_', # pylint: disable=R1732 | ||
delete=False) | ||
outfig = NamedTemporaryFile(suffix= f'.{extension}', prefix='baredSC_test_', # pylint: disable=R1732 | ||
delete=False) | ||
outfig_base = outfig.name[:-(len(extension) + 1)] | ||
outfile_evid = NamedTemporaryFile(suffix='.txt', prefix='baredSC_test_', # pylint: disable=R1732 | ||
delete=False) | ||
args = f"--input {ROOT}/nih3t3_generated_2d_2.txt " \ | ||
"--geneColName 0.5_0_0_0.5_x " \ | ||
f"--output {outfile.name}.npz " \ | ||
"--nnorm 1 " \ | ||
f"--figure {outfig.name} " \ | ||
f"--logevidence {outfile_evid.name}".split() | ||
args += ['--title', 'first gene 1 gauss'] | ||
baredSC.baredSC_1d.main(args) | ||
for suffix in BARED_1D_IMAGES_SUFFIX: | ||
expected_file = f'{expected}{suffix}.{extension}' | ||
obtained_file = f'{outfig_base}{suffix}.{extension}' | ||
res = compare_images(expected_file, | ||
obtained_file, TOLERENCE) | ||
assert res is None, res | ||
|
||
os.remove(obtained_file) | ||
# for suffix in BARED_1D_TEXT_SUFFIX: | ||
# expected_file = f'{expected}{suffix}' | ||
# obtained_file = f'{outfig_base}{suffix}' | ||
# expected_mat = np.loadtxt(expected_file, skiprows=1) | ||
# obtained_mat = np.loadtxt(obtained_file, skiprows=1) | ||
# assert np.all(np.isclose(obtained_mat, expected_mat)) | ||
|
||
# os.remove(obtained_file) | ||
|
||
|
||
def test_baredSC_1d_2gauss_log_pdf(): | ||
"""Second test with pdf cells subset prettyBins... | ||
""" | ||
|
||
extension = 'pdf' | ||
expected = os.path.join(EXAMPLE, 'first_example_1d_2gauss_log') | ||
outfile = NamedTemporaryFile(prefix='baredSC_test_', # pylint: disable=R1732 | ||
delete=False) | ||
outfig = NamedTemporaryFile(suffix= f'.{extension}', prefix='baredSC_test_', # pylint: disable=R1732 | ||
delete=False) | ||
outfig_base = outfig.name[:-(len(extension) + 1)] | ||
outfile_evid = NamedTemporaryFile(suffix='.txt', prefix='baredSC_test_', # pylint: disable=R1732 | ||
delete=False) | ||
args = f"--input {ROOT}/nih3t3_generated_2d_2.txt " \ | ||
"--metadata1ColName 0_0.5_0.5_0_group " \ | ||
"--metadata1Values 1.0 " \ | ||
"--xmin -15 " \ | ||
"--xmax -7 " \ | ||
"--nx 25 " \ | ||
"--xscale log " \ | ||
"--minNeff 400 " \ | ||
"--geneColName 0.5_0_0_0.5_x " \ | ||
f"--output {outfile.name}.npz " \ | ||
"--nnorm 2 " \ | ||
f"--figure {outfig.name} " \ | ||
f"--logevidence {outfile_evid.name}".split() | ||
args += ['--title', 'first gene 2 gauss log scale'] | ||
baredSC.baredSC_1d.main(args) | ||
for suffix in BARED_1D_IMAGES_SUFFIX: | ||
expected_file = f'{expected}{suffix}.{extension}' | ||
obtained_file = f'{outfig_base}{suffix}.{extension}' | ||
res = compare_images(expected_file, | ||
obtained_file, TOLERENCE) | ||
assert res is None, res | ||
|
||
os.remove(obtained_file) | ||
# for suffix in BARED_1D_TEXT_SUFFIX: | ||
# expected_file = f'{expected}{suffix}' | ||
# obtained_file = f'{outfig_base}{suffix}' | ||
# expected_mat = np.loadtxt(expected_file, skiprows=1) | ||
# obtained_mat = np.loadtxt(obtained_file, skiprows=1) | ||
# assert np.all(np.isclose(obtained_mat, expected_mat)) | ||
|
||
# os.remove(obtained_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# -*- coding: utf-8 -*- | ||
""" Test for baredSC_2d | ||
""" | ||
from tempfile import NamedTemporaryFile | ||
import os.path | ||
import matplotlib as mpl | ||
from matplotlib.testing.compare import compare_images | ||
import baredSC.baredSC_2d | ||
|
||
mpl.use('agg') | ||
|
||
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
"test_data") | ||
|
||
EXAMPLE = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
"..", "..", "example") | ||
|
||
BARED_2D_IMAGES_SUFFIX = ['', '_convergence', '_p', '_corner', '_individuals', | ||
'_median'] | ||
|
||
BARED_2D_TEXT_SUFFIX = ['_neff.txt', '_p.txt', '_corr.txt', '_pdf2d.txt', '_pdf2d_flat.txt'] | ||
|
||
TOLERENCE = 13 # default matplotlib pixed difference tolerance | ||
|
||
|
||
def test_baredSC_2d_1gauss_small(): | ||
"""First test with small | ||
""" | ||
extension = 'png' | ||
expected = os.path.join(ROOT, '2d_small_2gauss') | ||
outfile = NamedTemporaryFile(prefix='baredSC_test_', # pylint: disable=R1732 | ||
delete=False) | ||
outfig = NamedTemporaryFile(suffix= f'.{extension}', prefix='baredSC_test_', # pylint: disable=R1732 | ||
delete=False) | ||
outfig_base = outfig.name[:-(len(extension) + 1)] | ||
outfile_evid = NamedTemporaryFile(suffix='.txt', prefix='baredSC_test_', # pylint: disable=R1732 | ||
delete=False) | ||
args = f"--input {ROOT}/nih3t3_generated_2d_2.txt " \ | ||
"--geneXColName 0.5_0_0_0.5_x " \ | ||
"--geneYColName 0.5_0_0_0.5_y " \ | ||
"--nx 10 --ny 12 --nsampMCMC 20000 " \ | ||
"--prettyBinsx 50 --prettyBinsy 50 " \ | ||
f"--output {outfile.name}.npz " \ | ||
"--nnorm 2 " \ | ||
f"--figure {outfig.name} " \ | ||
f"--logevidence {outfile_evid.name}".split() | ||
baredSC.baredSC_2d.main(args) | ||
for suffix in BARED_2D_IMAGES_SUFFIX: | ||
expected_file = f'{expected}{suffix}.{extension}' | ||
obtained_file = f'{outfig_base}{suffix}.{extension}' | ||
res = compare_images(expected_file, | ||
obtained_file, TOLERENCE) | ||
assert res is None, res | ||
|
||
os.remove(obtained_file) | ||
# for suffix in BARED_2D_TEXT_SUFFIX: | ||
# expected_file = f'{expected}{suffix}' | ||
# obtained_file = f'{outfig_base}{suffix}' | ||
# expected_mat = np.loadtxt(expected_file, skiprows=1) | ||
# obtained_mat = np.loadtxt(obtained_file, skiprows=1) | ||
# assert np.all(np.isclose(obtained_mat, expected_mat)) | ||
|
||
# os.remove(obtained_file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
""" Test for combineMultipleModels_1d | ||
""" | ||
from tempfile import NamedTemporaryFile | ||
import os.path | ||
import matplotlib as mpl | ||
from matplotlib.testing.compare import compare_images | ||
import baredSC.combineMultipleModels_1d | ||
|
||
mpl.use('agg') | ||
|
||
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
"test_data") | ||
|
||
EXAMPLE = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
"..", "..", "example") | ||
|
||
BARED_1D_IMAGES_SUFFIX = ['', '_individuals', | ||
'_with_posterior', '_posterior_individuals', | ||
'_posterior_andco'] | ||
|
||
BARED_1D_TEXT_SUFFIX = ['_pdf.txt', '_posterior_per_cell.txt'] | ||
|
||
TOLERENCE = 13 # default matplotlib pixed difference tolerance | ||
|
||
|
||
def test_combine_1d_test1(): | ||
"""Simple test from small npz | ||
""" | ||
|
||
extension = 'png' | ||
expected = os.path.join(ROOT, 'combine_test1') | ||
with NamedTemporaryFile(suffix= f'.{extension}', prefix='baredSC_test_', | ||
delete=False) as outfig: | ||
outfig_base = outfig.name[:-(len(extension) + 1)] | ||
args = f"--input {ROOT}/nih3t3_generated_2d_2.txt " \ | ||
"--geneColName 0.5_0_0_0.5_x " \ | ||
f"--outputs {ROOT}/small_1gauss {ROOT}/small_2gauss " \ | ||
"--nx 10 --prettyBins 100 " \ | ||
f"--figure {outfig.name}".split() | ||
args += ['--title', 'first gene combine 1 and 2 gauss'] | ||
baredSC.combineMultipleModels_1d.main(args) | ||
for suffix in BARED_1D_IMAGES_SUFFIX: | ||
expected_file = f'{expected}{suffix}.{extension}' | ||
obtained_file = f'{outfig_base}{suffix}.{extension}' | ||
res = compare_images(expected_file, | ||
obtained_file, TOLERENCE) | ||
assert res is None, res | ||
|
||
os.remove(obtained_file) | ||
# for suffix in BARED_1D_TEXT_SUFFIX: | ||
# expected_file = f'{expected}{suffix}' | ||
# obtained_file = f'{outfig_base}{suffix}' | ||
# expected_mat = np.loadtxt(expected_file, skiprows=1) | ||
# obtained_mat = np.loadtxt(obtained_file, skiprows=1) | ||
# assert np.all(np.isclose(obtained_mat, expected_mat)) | ||
|
||
# os.remove(obtained_file) |
Oops, something went wrong.