Skip to content
Snippets Groups Projects
Commit 080ac051 authored by Bryan BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

Merge branch 'master' into fix-urls

parents 628270c9 7075cbdc
Branches fix-urls
No related tags found
No related merge requests found
...@@ -14,14 +14,15 @@ test-python: ...@@ -14,14 +14,15 @@ test-python:
script: script:
- apt-get update && apt install -y libblas-dev liblapack-dev python3-dev - apt-get update && apt install -y libblas-dev liblapack-dev python3-dev
- pip install -r requirements.txt - pip install -r requirements.txt
- python setup.py test - python -m unittest
# - python setup.py test
parallel: parallel:
matrix: matrix:
- PYTHON_VERSION: [ - PYTHON_VERSION: [
# '3.7', # EOL # '3.7', # EOL
'3.8', # oldest '3.8', # oldest
'3.10', # used in Dockerfile '3.10', # used in Dockerfile
'3.12', # latest '3.12',
] ]
...@@ -127,7 +128,7 @@ build-backend: ...@@ -127,7 +128,7 @@ build-backend:
-v $(pwd)/.eggs:/code/.eggs -v $(pwd)/.eggs:/code/.eggs
-v $(pwd)/jass.egg-info:/code/jass.egg-info -v $(pwd)/jass.egg-info:/code/jass.egg-info
"$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/${PATH_TAG}:$CI_COMMIT_SHA" "$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG/${PATH_TAG}:$CI_COMMIT_SHA"
python setup.py test python -m unittest
build-client-dev: build-client-dev:
......
...@@ -8,5 +8,5 @@ spec: ...@@ -8,5 +8,5 @@ spec:
resources: resources:
requests: requests:
storage: 80Gi storage: 80Gi
storageClassName: isilon storageClassName: ceph-fs
status: {} status: {}
\ No newline at end of file
...@@ -32,8 +32,9 @@ serviceAccount: ...@@ -32,8 +32,9 @@ serviceAccount:
podAnnotations: {} podAnnotations: {}
podSecurityContext: podSecurityContext:
{} runAsUser: 1000
# fsGroup: 1001 runAsGroup: 1000
fsGroup: 1000
securityContext: securityContext:
runAsNonRoot: true runAsNonRoot: true
...@@ -85,7 +86,7 @@ backCronTasks: ...@@ -85,7 +86,7 @@ backCronTasks:
projects: projects:
size: 19Gi size: 19Gi
minSizeToKeepFree: 10240 # size is in MB minSizeToKeepFree: 10240 # size is in MB
storageClassName: isilon storageClassName: ceph-fs
client: client:
securityContext: securityContext:
......
...@@ -17,10 +17,10 @@ from matplotlib import colors ...@@ -17,10 +17,10 @@ from matplotlib import colors
import matplotlib.patches as mpatches import matplotlib.patches as mpatches
from scipy.stats import norm, chi2 from scipy.stats import norm, chi2
import seaborn as sns import seaborn as sns
import os
from pandas import DataFrame, read_hdf from pandas import DataFrame, read_hdf
import pandas as pd import pandas as pd
default_chunk_size=50
def replaceZeroes(df): def replaceZeroes(df):
""" """
...@@ -32,30 +32,34 @@ def replaceZeroes(df): ...@@ -32,30 +32,34 @@ def replaceZeroes(df):
df.values[df.values == 0] = min_nonzero df.values[df.values == 0] = min_nonzero
return df 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 create_global_plot
generate genome-wide manhattan plot for a given set of phenotypes generate genome-wide manhattan plot for a given set of phenotypes
""" """
regions = read_hdf(work_file_path, "Regions") N_reg,binf,chr_considered,length_chr=get_info_4_global_plot(work_file_path)
chr_length = regions.groupby('CHR').max().position
N_reg= regions.Region.max()
maxy = 0 maxy = 0
fig = plt.figure(figsize=(30, 12)) fig = plt.figure(figsize=(30, 12))
ax = fig.add_subplot(111) ax = fig.add_subplot(111)
chunk_size = 50
colors = [ colors = [
'#4287f5', '#4287f5',
'orangered' '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") label = "Chr"+length_chr.loc[chr_considered].index.astype("str")
lab_pos = length_chr.loc[chr_considered]/2 lab_pos = length_chr.loc[chr_considered]/2
...@@ -63,7 +67,7 @@ def create_global_plot(work_file_path: str, global_plot_path: str): ...@@ -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.index = pos_shift.index +1
pos_shift.loc[chr_considered[0]] = 0 pos_shift.loc[chr_considered[0]] = 0
lab_pos = lab_pos + [pos_shift.loc[i] for i in chr_considered] lab_pos = lab_pos + [pos_shift.loc[i] for i in chr_considered]
bsup = binf + chunk_size
while binf < N_reg: 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)) 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 binf+= chunk_size
......
jass/test/expected_graphs/expected_global_plot.png

321 KiB

...@@ -3,8 +3,10 @@ ...@@ -3,8 +3,10 @@
from __future__ import absolute_import from __future__ import absolute_import
import os, shutil, tempfile import os, shutil, tempfile
from pathlib import Path from pathlib import Path
import matplotlib as plt
from jass.models import plots from jass.models import plots
from PIL import Image
import numpy as np
from . import JassTestCase from . import JassTestCase
...@@ -12,10 +14,13 @@ from . import JassTestCase ...@@ -12,10 +14,13 @@ from . import JassTestCase
class TestPlots(JassTestCase): class TestPlots(JassTestCase):
test_folder = "data_real" test_folder = "data_real"
expected_res_folder = "expected_graphs"
#expected_res_folder="baseline_images/test_plot"
def setUp(self): def setUp(self):
# Create a temporary directory # Create a temporary directory
self.test_dir = Path(tempfile.mkdtemp()) 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") self.worktable_hdf_path = self.get_file_path_fn("worktable-withnans.hdf5")
def tearDown(self): def tearDown(self):
...@@ -24,7 +29,15 @@ class TestPlots(JassTestCase): ...@@ -24,7 +29,15 @@ class TestPlots(JassTestCase):
pass pass
def test_create_global_plot(self): 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") 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): def test_create_qq_plot(self):
plots.create_qq_plot(self.worktable_hdf_path, self.test_dir / "qq_plot.png") plots.create_qq_plot(self.worktable_hdf_path, self.test_dir / "qq_plot.png")
......
[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
...@@ -18,4 +18,4 @@ uvicorn[standard] ...@@ -18,4 +18,4 @@ uvicorn[standard]
typing_extensions; python_version < '3.8' typing_extensions; python_version < '3.8'
requests requests
h5py h5py
wheel wheel
\ No newline at end of file
[aliases]
test=pytest
...@@ -2,56 +2,22 @@ ...@@ -2,56 +2,22 @@
import os import os
import pathlib import pathlib
import pkg_resources
from setuptools import setup, find_packages
NAME = "jass" from setuptools import setup
VERSION = "2.2"
SETUP_DIR = os.path.dirname(__file__) # NAME = "jass"
README = os.path.join(SETUP_DIR, 'README.md') # VERSION = "2.2"
readme = open(README).read() #
# SETUP_DIR = os.path.dirname(__file__)
with pathlib.Path('requirements.txt').open() as requirements_txt: # README = os.path.join(SETUP_DIR, 'README.md')
REQUIRES = [ # readme = open(README).read()
str(requirement) #
for requirement # with pathlib.Path('requirements.txt').open() as requirements_txt:
in pkg_resources.parse_requirements(requirements_txt) # REQUIRES = [
] # str(requirement)
# for requirement
setup( # in pkg_resources.parse_requirements(requirements_txt)
name=NAME, # ]
version=VERSION, if __name__ == "__main__":
description="JASS allows for single SNP joint analysis of multiple GWAS summary statistics", setup()
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',
]
}
)
flask_testing==0.6.1
coverage>=4.0.3
nose>=1.3.7
pluggy>=0.3.1
py>=1.4.31
randomize>=0.13
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment