Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summarize visualizer breaks on columnless metadata #227

Open
thermokarst opened this issue Apr 1, 2020 · 1 comment
Open

Summarize visualizer breaks on columnless metadata #227

thermokarst opened this issue Apr 1, 2020 · 1 comment

Comments

@thermokarst
Copy link
Contributor

Bug Description
Providing ID-only sample metadata to summarize breaks.

Expected behavior
We should still error out, but in a more controlled fashion.

Screenshots

/home/wanghuilin/miniconda3/envs/qiime2/lib/python3.6/site-packages/q2_feature_table/_summarize/_visualizer.py:122: FutureWarning: The signature of Series.to_csv was aligned to that of DataFrame.to_csv, and argument ‘header’ will change its default value from False to True: please pass an explicit value to suppress this warning.
os.path.join(output_dir, ‘sample-frequency-detail.csv’))
/home/wanghuilin/miniconda3/envs/qiime2/lib/python3.6/site-packages/q2_feature_table/_summarize/_visualizer.py:124: FutureWarning: The signature of Series.to_csv was aligned to that of DataFrame.to_csv, and argument ‘header’ will change its default value from False to True: please pass an explicit value to suppress this warning.
os.path.join(output_dir, ‘feature-frequency-detail.csv’))
Traceback (most recent call last):
File “/home/wanghuilin/miniconda3/envs/qiime2/lib/python3.6/site-packages/q2cli/commands.py”, line 328, in call
results = action(**arguments)
File “</home/wanghuilin/miniconda3/envs/qiime2/lib/python3.6/site-packages/decorator.py:decorator-gen-326>”, line 2, in summarize
File “/home/wanghuilin/miniconda3/envs/qiime2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 245, in bound_callable
output_types, provenance)
File “/home/wanghuilin/miniconda3/envs/qiime2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 452, in callable_executor
ret_val = self._callable(output_dir=temp_dir, **view_args)
File “/home/wanghuilin/miniconda3/envs/qiime2/lib/python3.6/site-packages/q2_feature_table/_summarize/_visualizer.py”, line 156, in summarize
sample_frequencies
File “/home/wanghuilin/miniconda3/envs/qiime2/lib/python3.6/site-packages/q2_feature_table/_summarize/_vega_spec.py”, line 106, in vega_spec
‘value’: metadata_categories[0]
IndexError: list index out of range

References

  1. Forum
@thermokarst
Copy link
Contributor Author

BTW, for anyone interested in tackling this, I think adding a simple check around here will do it:

if sample_metadata is not None:
context.update({'vega_spec':
json.dumps(vega_spec(sample_metadata,
sample_frequencies
))
})

    if sample_metadata is not None and sample_metadata.column_count > 0:

What isn't clear to me is if we should error or not. I guess if someone provides ID-only we could still show them the interactive viz, although it doesnt have much utility.

Another potential solution is to do what we do in q2-taxa's barplot viz - "demote" the ID column to a vanilla metadata column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant