longitudinal studies error metric

Hello Qiime2 team,

Here is a snippet of the code. There is cut off from putty.exe. The python program runs. Can you please clarify what they mean by “metric” – bold.

The code follows the code you posted on github, however, we must be missing something. Any insight or suggestions are welcome and appreciated.
longitudinal-notebooks/analysis.ipynb at master · caporaso-lab/longitudinal-notebooks · GitHub

Sincerely,
Sally

………..
Lachnospiraceae='d__Bacteria; p__Firmicutes; c__Clostridia; o__Lachnospirales; f__Lachnospiracea$
Catenisphaera='d__Bacteria; p__Firmicutes; c__Bacilli; o__Erysipelotrichales; f__Erysipelotricha$
NK4A136_group='d__Bacteria; p__Firmicutes; c__Clostridia; o__Lachnospirales; f__Lachnospiraceae; Prevotella='d__Bacteria; p__Bacteroidota; c__Bacteroidia; o__Bacteroidales; f__Prevotellaceae; g
RC9_gut_group='d__Bacteria; p__Bacteroidota; c__Bacteroidia; o__Bacteroidales; f__Rikenellaceae;$

“stuff_to_test = [(Lachnospiraceae, t304, '304'),
(Catenisphaera, t304, '304'),
(NK4A136_group, t04, '04'),
(Prevotella, t03, '03'),
(RC9_gut_group, t304, '304')]

print("t304=",t304)

for target, tab, time in stuff_to_test:
# extract the genus name for saving files
print("time=",time,target,"\n\n")
print ("tab=",tab)
target_name = target.split('__')[-1]
# run LME
viz, = longitudinal.actions.linear_mixed_effects(
metadata=sample_md,metric="target", state_column='time', individual_id_column='pig',
group_columns='treatment', table=tab)
# save qzv

viz.save(os.path.join(results_dir, 'feat-volatility-genus_may6_2022', 'lme-' + target_name $

viz, = longitudinal.actions.linear_mixed_effects(
File "", line 2, in linear_mixed_effects
File "/root/miniconda2/envs/qiime2-2021.11/lib/python3.8/site-packages/qiime2/sdk/action.py", line 245, in bound_callable
outputs = self.callable_executor(scope, callable_args,
File "/root/miniconda2/envs/qiime2-2021.11/lib/python3.8/site-packages/qiime2/sdk/action.py", line 453, in callable_executor
ret_val = self._callable(output_dir=temp_dir, **view_args)
File "/root/miniconda2/envs/qiime2-2021.11/lib/python3.8/site-packages/q2_longitudinal/_longitudinal.py", line 186, in linear_mixed_effects
metadata = _add_metric_to_metadata(table, metadata, metric)
File "/root/miniconda2/envs/qiime2-2021.11/lib/python3.8/site-packages/q2_longitudinal/_utilities.py", line 448, in _add_metric_to_metadata
raise ValueError(
ValueError: metric must be a valid metadata or feature table column.

Any updates to this post? Thanks

Hi @J_Sh,

Thanks for your patience, and welcome to the :qiime2: forum!

The answer to your post's title question 'longitudinal studies error metric' can be found in our documentation on linear mixed effects modeling - I'd highly recommend reading through that (linked below) before moving forward here!

https://docs.qiime2.org/2022.2/plugins/available/longitudinal/linear-mixed-effects/

With regards to what's going on with your code - it seems to be a bit jumbled, and looks as though some segments may have been copy/pasted together, which is most likely where this error is coming from. In your code, you've set metric to "target" (from longitudinal.actions.linear_mixed_effects) - and the error message indicates that your chosen metric must be a valid metadata or feature table column.

Without wading in too deep here, I'd recommend starting with a fresh Python notebook or equivalent method (however you have been running your code thus far), and making sure you understand how each segment of code works that you are adding/writing. Print statements will be very helpful when debugging. :slightly_smiling_face:

Cheers :lizard:

1 Like

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