diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c6c3e43116019cef78112485caa390bb9d7a1700..930ad63dd0baba9eb75f2fdd88e978ffa1963919 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,14 +14,15 @@ test-python: script: - apt-get update && apt install -y libblas-dev liblapack-dev python3-dev - pip install -r requirements.txt - - python setup.py test + - python -m unittest +# - python setup.py test parallel: matrix: - PYTHON_VERSION: [ # '3.7', # EOL '3.8', # oldest '3.10', # used in Dockerfile - '3.12', # latest + '3.12', ] @@ -127,7 +128,7 @@ build-backend: -v $(pwd)/.eggs:/code/.eggs -v $(pwd)/jass.egg-info:/code/jass.egg-info "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/${PATH_TAG}:$CI_COMMIT_SHA" - python setup.py test + python -m unittest build-client-dev: diff --git a/chart/pvc-shared-data.yaml b/chart/pvc-shared-data.yaml index 38c0a14f6448ff1c58970f112e25ebd4105fd0d5..fe918824548f2ca3390e23e9d5cf80a6c1a22958 100644 --- a/chart/pvc-shared-data.yaml +++ b/chart/pvc-shared-data.yaml @@ -8,5 +8,5 @@ spec: resources: requests: storage: 80Gi - storageClassName: isilon + storageClassName: ceph-fs status: {} \ No newline at end of file diff --git a/chart/values.yaml b/chart/values.yaml index 66caaed646d0eb59b4e19e14d5fa7067ef5ffb80..87acacf3ec131857ae3743ea0b00d3b16f3419ea 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -32,8 +32,9 @@ serviceAccount: podAnnotations: {} podSecurityContext: - {} - # fsGroup: 1001 + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 securityContext: runAsNonRoot: true @@ -85,7 +86,7 @@ backCronTasks: projects: size: 19Gi minSizeToKeepFree: 10240 # size is in MB - storageClassName: isilon + storageClassName: ceph-fs client: securityContext: diff --git a/jass/models/plots.py b/jass/models/plots.py index 3953d0f3419db0e4bbebd31e675a7d54a0be2991..ef60219ef9e54f91a5016d74d3c6851f78f69a2d 100644 --- a/jass/models/plots.py +++ b/jass/models/plots.py @@ -17,10 +17,10 @@ from matplotlib import colors import matplotlib.patches as mpatches from scipy.stats import norm, chi2 import seaborn as sns -import os from pandas import DataFrame, read_hdf import pandas as pd +default_chunk_size=50 def replaceZeroes(df): """ @@ -32,30 +32,34 @@ def replaceZeroes(df): df.values[df.values == 0] = min_nonzero return df -def create_global_plot(work_file_path: str, global_plot_path: str): + +def get_info_4_global_plot(work_file_path: str): + regions = read_hdf(work_file_path, "Regions",columns=['Region','CHR','MiddlePosition']) + print(regions.dtypes) + N_reg = regions.Region.max() # Keep biggest element in Region column + binf = regions.Region.iloc[0] + chr_considered = regions.CHR.unique() + length_chr = regions.groupby("CHR").MiddlePosition.max() / 10 ** 6 + length_chr.loc[0] = 0 + return N_reg,binf,chr_considered,length_chr + +def create_global_plot(work_file_path: str, global_plot_path: str, chunk_size:int =default_chunk_size): """ create_global_plot generate genome-wide manhattan plot for a given set of phenotypes """ - regions = read_hdf(work_file_path, "Regions") - chr_length = regions.groupby('CHR').max().position - N_reg= regions.Region.max() + N_reg,binf,chr_considered,length_chr=get_info_4_global_plot(work_file_path) maxy = 0 fig = plt.figure(figsize=(30, 12)) ax = fig.add_subplot(111) - chunk_size = 50 colors = [ '#4287f5', 'orangered' ] - binf=regions.Region.iloc[0] - bsup= binf+chunk_size - chr_considered= regions.CHR.unique() - length_chr = regions.groupby("CHR").MiddlePosition.max() / 10**6 - length_chr.loc[0] = 0 + label = "Chr"+length_chr.loc[chr_considered].index.astype("str") lab_pos = length_chr.loc[chr_considered]/2 @@ -63,7 +67,7 @@ def create_global_plot(work_file_path: str, global_plot_path: str): pos_shift.index = pos_shift.index +1 pos_shift.loc[chr_considered[0]] = 0 lab_pos = lab_pos + [pos_shift.loc[i] for i in chr_considered] - + bsup = binf + chunk_size while binf < N_reg: df = read_hdf(work_file_path, "SumStatTab", columns=["CHR","position", 'JASS_PVAL', "Region"], where = "Region >= {0} and Region < {1}".format(binf, bsup)) binf+= chunk_size diff --git a/jass/test/expected_graphs/expected_global_plot.png b/jass/test/expected_graphs/expected_global_plot.png new file mode 100644 index 0000000000000000000000000000000000000000..a1896d6c7795ac13c1aa6e542cf41f7246e43a08 Binary files /dev/null and b/jass/test/expected_graphs/expected_global_plot.png differ diff --git a/jass/test/test_plots.py b/jass/test/test_plots.py index ad0012abe26c219928e091f836c1a26e87034b9f..99d12721b4baa6fe3789b16b8d06b819ce360235 100644 --- a/jass/test/test_plots.py +++ b/jass/test/test_plots.py @@ -3,8 +3,10 @@ from __future__ import absolute_import import os, shutil, tempfile from pathlib import Path - +import matplotlib as plt from jass.models import plots +from PIL import Image +import numpy as np from . import JassTestCase @@ -12,10 +14,13 @@ from . import JassTestCase class TestPlots(JassTestCase): test_folder = "data_real" + expected_res_folder = "expected_graphs" + #expected_res_folder="baseline_images/test_plot" def setUp(self): # Create a temporary directory self.test_dir = Path(tempfile.mkdtemp()) + self.ref_res_dir=Path(os.path.join(os.path.dirname(os.path.abspath(__file__)), self.expected_res_folder)) self.worktable_hdf_path = self.get_file_path_fn("worktable-withnans.hdf5") def tearDown(self): @@ -24,7 +29,15 @@ class TestPlots(JassTestCase): pass def test_create_global_plot(self): + #import shutil + #print(plt.rcParams) plots.create_global_plot(self.worktable_hdf_path, self.test_dir / "global_plot.png") + img_new=Image.open(self.test_dir /"global_plot.png") + img_ref=Image.open(self.ref_res_dir / "expected_global_plot.png") + sum_sq_diff = np.sum((np.asarray(img_new).astype('float') - np.asarray(img_ref).astype('float')) ** 2) + print("sum_sq_diff=",sum_sq_diff) + assert(sum_sq_diff==0.0) + def test_create_qq_plot(self): plots.create_qq_plot(self.worktable_hdf_path, self.test_dir / "qq_plot.png") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..e82ed6c837119abc49291a903ea65923d8a2bb31 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,46 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "jass" +authors = [ + {name="Hervé Ménager", email='hmenager@pasteur.fr'}, + {name="Pierre Lechat", email='pierre.lechat@pasteur.fr'}, + {name="Carla Lasry", email='carla.lasry@pasteur.fr'}, + {name="Vincent Guillemot", email='vincent.guillemot@pasteur.fr'}, + {name="Hugues Aschard", email='hugues.aschard@pasteur.fr'}, + {name="Hanna Julienne", email='hanna.julienne@pasteur.fr'} +] +description="JASS allows for single SNP joint analysis of multiple GWAS summary statistics" +readme ="README.md" +dynamic = ["dependencies"] +version = "2.2" +requires-python = ">=3.6" + +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} + + +[tool.setuptools.packages.find] +include = ["jass*"] + +[tool.setuptools.package-data] +jass = ["swagger/swagger.yaml", +"data/*.tsv"] +# include-package-data = true + +[project.scripts] +jass="jass.__main__:main" + +[project.urls] +Homepage = "https://gitlab.pasteur.fr/statistical-genetics/jass" + +[project.license] +text = "MIT" \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c705857281f43e140741316bfef400d59fa45e2c..0a12f559a15f20fde1fa2fd95e6b309d88e83728 100644 --- a/requirements.txt +++ b/requirements.txt @@ -18,4 +18,4 @@ uvicorn[standard] typing_extensions; python_version < '3.8' requests h5py -wheel \ No newline at end of file +wheel diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b7e478982ccf9ab1963c74e1084dfccb6e42c583..0000000000000000000000000000000000000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[aliases] -test=pytest diff --git a/setup.py b/setup.py index 61bba8e85879dc9f5f6e8efca8c09667813475b9..551bbcd48835c52227ace9ca99cc62efa725dd42 100644 --- a/setup.py +++ b/setup.py @@ -2,56 +2,22 @@ import os import pathlib -import pkg_resources -from setuptools import setup, find_packages -NAME = "jass" -VERSION = "2.2" +from setuptools import setup -SETUP_DIR = os.path.dirname(__file__) -README = os.path.join(SETUP_DIR, 'README.md') -readme = open(README).read() - -with pathlib.Path('requirements.txt').open() as requirements_txt: - REQUIRES = [ - str(requirement) - for requirement - in pkg_resources.parse_requirements(requirements_txt) - ] - -setup( - name=NAME, - version=VERSION, - description="JASS allows for single SNP joint analysis of multiple GWAS summary statistics", - author='Hervé Ménager and Pierre Lechat and Carla Lasry and Vincent Guillemot and Hugues Aschard and Hanna Julienne', - author_email="hmenager@pasteur.fr, pierre.lechat@pasteur.fr, carla.lasry@pasteur.fr, vincent.guillemot@pasteur.fr, hugues.aschard@pasteur.fr, hanna.julienne@pasteur.fr", - url="https://gitlab.pasteur.fr/statistical-genetics/jass", - packages=find_packages(), - install_requires=REQUIRES, - license="MIT", - keywords=["GWAS", "Data analysis", "summary statistics"], - package_data={'jass': ['swagger/swagger.yaml', "data/*.tsv"]}, - include_package_data=True, - long_description=readme, - long_description_content_type="text/markdown", - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - python_requires='>=3.6', - setup_requires=[ - 'pytest-runner', - 'Flask-Testing' - ], - tests_require=[ - 'pytest', - 'Flask-Testing' - ], - entry_points={ - 'console_scripts': [ - 'jass=jass.__main__:main', - ] - } -) +# NAME = "jass" +# VERSION = "2.2" +# +# SETUP_DIR = os.path.dirname(__file__) +# README = os.path.join(SETUP_DIR, 'README.md') +# readme = open(README).read() +# +# with pathlib.Path('requirements.txt').open() as requirements_txt: +# REQUIRES = [ +# str(requirement) +# for requirement +# in pkg_resources.parse_requirements(requirements_txt) +# ] +if __name__ == "__main__": + setup() diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index 7f8d96e6b40e853d658f88fa745ddcf37ff7644c..0000000000000000000000000000000000000000 --- a/test-requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -flask_testing==0.6.1 -coverage>=4.0.3 -nose>=1.3.7 -pluggy>=0.3.1 -py>=1.4.31 -randomize>=0.13