--p-formula syntax error if "class" included

I’m trying to run qiime gneiss ols-regression with --p-formula "class+habitat+sampling_method". This generates the following error:

Traceback (most recent call last):
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/q2cli/commands.py", line 218, in __call__
    results = action(**arguments)
  File "<decorator-gen-195>", line 2, in ols_regression
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/qiime2/sdk/action.py", line 220, in bound_callable
    output_types, provenance)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/qiime2/sdk/action.py", line 416, in _callable_executor_
    ret_val = self._callable(output_dir=temp_dir, **view_args)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/q2_gneiss/regression/_regression.py", line 31, in ols_regression
    formula=formula)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/gneiss-0.4.2-py3.5.egg/gneiss/regression/_ols.py", line 129, in ols
    x = dmatrix(formula, metadata, return_type='dataframe')
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/patsy/highlevel.py", line 291, in dmatrix
    NA_action, return_type)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/patsy/highlevel.py", line 165, in _do_highlevel_design
    NA_action)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/patsy/highlevel.py", line 70, in _try_incr_builders
    NA_action)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/patsy/build.py", line 689, in design_matrix_builders
    factor_states = _factors_memorize(all_factors, data_iter_maker, eval_env)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/patsy/build.py", line 354, in _factors_memorize
    which_pass = factor.memorize_passes_needed(state, eval_env)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/patsy/eval.py", line 474, in memorize_passes_needed
    subset_names = [name for name in ast_names(self.code)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/patsy/eval.py", line 474, in <listcomp>
    subset_names = [name for name in ast_names(self.code)
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/site-packages/patsy/eval.py", line 105, in ast_names
    for node in ast.walk(ast.parse(code)):
  File "/ebio/abt3_projects/software/miniconda3/envs/qiime2/lib/python3.5/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)
  File "<unknown>", line 1
    class
        ^
SyntaxError: invalid syntax

I get the error regardless of where “class” is in the formula. If I switch “class” to a different metadata column such as “order” or “family” (this is the taxonomy of the host), then I don’t get the syntax error.

It appears that qiime gneiss ols-regression is treating “class” as python code instead of part of the formula. More specifically, memorize is interpreting “class” incorrectly.

System versions
Python version: 3.5.4
QIIME 2 release: 2017.10
QIIME 2 version: 2017.10.0
q2cli version: 2017.10.0

Installed plugins
alignment 2017.10.0
composition 2017.10.0
dada2 2017.10.0
deblur 2017.10.0
demux 2017.10.0
diversity 2017.10.0
emperor 2017.10.0
feature-classifier 2017.10.0
feature-table 2017.10.0
gneiss 2017.10.0
longitudinal 2017.10.0
metadata 2017.10.0
phylogeny 2017.10.0
quality-control 2017.10.0
quality-filter 2017.10.0
sample-classifier 2017.10.0
taxa 2017.10.0
types 2017.10.0
vsearch 2017.10.0

Thanks for reporting this issue @nick-youngblut!

Looks like something is getting clobbered in or on the way to patsy. I’ve opened an issue on q2-gneiss to track this down.

I did notice your installation is 2 releases behind, does installing the latest resolve the problem? I don’t recall anything really changing for gneiss in that time, but it might have!

Thanks and Happy New Years! :fireworks:

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.