Skip to content

Commit

Permalink
For release 1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lemieuxl committed Feb 10, 2017
2 parents 7c79341 + d56dbf1 commit 7b218aa
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 85 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: python
python:
- "3.4"
- "3.5"
- "3.6"
before_install:
- "wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh"
- "bash miniconda.sh -b -p $HOME/miniconda"
Expand All @@ -17,7 +18,7 @@ before_install:
install:
- "conda install -q nomkl"
- "conda install -q jinja2"
- "conda install -q numpy"
- "conda install -q 'numpy<1.12'"
- "conda install -q pandas"
- "conda install -q scipy"
- "conda install -q patsy"
Expand Down
5 changes: 4 additions & 1 deletion README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tool:
> **genipe: an automated genome-wide imputation pipeline with automatic reporting
> and statistical tools.**
> *Bioinformatics* 2016, Epub ahead of print.
> [DOI:[10.1093/bioinformatics/btw487](http://dx.doi.org/10.1093/bioinformatics/btw487)].
> (DOI:[10.1093/bioinformatics/btw487](http://dx.doi.org/10.1093/bioinformatics/btw487)).

## Documentation
Expand Down Expand Up @@ -78,6 +78,9 @@ and Cox's regressions), `genipe` requires the following Python modules:
* `pyfaidx` version 0.3.7 or latest
* `drmaa` version 0.7.6 or latest

Note that `statsmodels` (specifically MixedLM analysis) version 0.6 **is not
compatible** with `numpy` version 1.12 and latest.

Finally, the tool requires a LaTeX installation to compile the automatically
generated report in PDF format.

Expand Down
2 changes: 1 addition & 1 deletion conda_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ then
fi

# The different python versions and platforms
python_versions="3.4 3.5"
python_versions="3.4 3.5 3.6"
platforms="linux-32 linux-64 osx-64"

# Building
Expand Down
8 changes: 4 additions & 4 deletions genipe/tests/test_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,8 @@ def test_segment_length_large(self):
# Checking the warning is logged
with self.assertLogs(level="WARNING") as cm:
check_args(self.args)
log_m = ["WARNING:root:segment length (5e+06 bp) is more than 5Mb"]
self.assertEqual(log_m, cm.output)
log_m = "WARNING:root:segment length (5e+06 bp) is more than 5Mb"
self.assertTrue(log_m in cm.output)

def test_segment_length_small(self):
"""Tests different invalid segment length (too small)."""
Expand All @@ -797,8 +797,8 @@ def test_segment_length_small(self):
# Checking the warning is logged
with self.assertLogs(level="WARNING") as cm:
check_args(self.args)
log_m = ["WARNING:root:segment length (999 bp) is too small"]
self.assertEqual(log_m, cm.output)
log_m = "WARNING:root:segment length (999 bp) is too small"
self.assertTrue(log_m in cm.output)

def test_segment_length_invalid(self):
"""Tests different invalid segment length."""
Expand Down
4 changes: 1 addition & 3 deletions genipe/tests/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ def test_matrix_from_line(self):
self.assertTrue(np.allclose(expected_geno, observed_geno))

# An invalid line should raise an exception
with self.assertRaises(ValueError) as cm:
with self.assertRaises(ValueError):
impute2.matrix_from_line(input_line.split(" ")[:-1])
error_m = "total size of new array must be unchanged"
self.assertEqual(error_m, str(cm.exception))

def test_get_good_probs(self):
"""Tests the 'get_good_probs' function."""
Expand Down
140 changes: 70 additions & 70 deletions genipe/tests/test_imputed_stats.py

Large diffs are not rendered by default.

32 changes: 28 additions & 4 deletions genipe/tools/imputed_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,32 @@ def _skat_write_marker(name, dosage, snp_set, genotype_files):
print(name, *dosage, sep=",", file=file_object)


def _extract_mixedlm_random_effect(fitted):
"""Extracts the random effects from a MixedLM fit object.
Args:
fitted (MixedLMResultsWrapper): The fitted object.
Returns:
pandas.DataFrame: The random effects as a DataFrame (with a column
named "RE").
Note
====
Depending of the version of StatsModels, the object might be a pandas
DataFrame or a dictionary...
"""
# Getting the random effects
random_effects = fitted.random_effects

# If it's a dictionary, we need to create a DataFrame
if isinstance(random_effects, dict):
return pd.DataFrame(random_effects).T.rename(columns={"groups": "RE"})

return random_effects.rename(columns={"Intercept": "RE"})


def compute_statistics(impute2_filename, samples, markers_to_extract,
phenotypes, remove_gender, out_prefix, options):
"""Parses IMPUTE2 file while computing statistics.
Expand Down Expand Up @@ -789,13 +815,11 @@ def compute_statistics(impute2_filename, samples, markers_to_extract,
# We need to compute the random effects if it's a MixedLM analysis
random_effects = None
if options.analysis_type == "mixedlm" and options.interaction is None:
random_effects = smf.mixedlm(
random_effects = _extract_mixedlm_random_effect(smf.mixedlm(
formula=formula.replace("_GenoD + ", ""),
data=phenotypes,
groups=phenotypes.index,
).fit(reml=not options.use_ml).random_effects.rename(
columns={"Intercept": "RE"},
)
).fit(reml=not options.use_ml))

# Reading the file
nb_processed = 0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

MAJOR = 1
MINOR = 3
MICRO = 1
MICRO = 2
VERSION = "{0}.{1}.{2}".format(MAJOR, MINOR, MICRO)


Expand Down

0 comments on commit 7b218aa

Please sign in to comment.