Error while qiime protein-pca SettingWithCopyWarning

Hi,

When I run the following command to do the PCA. I installed qiime using conda.

qiime protein-pca plot-loadings --i-pca-loadings PCA-pca-loadings.qza --i-positions-mapping PCA-mapped.qza --o-visualization PCA-pca-loadings.qzv

I got the following error:

Plugin error from protein-pca:

  Object of type int64 is not JSON serializable

Debug info has been saved to /var/folders/5z/jxpr82fd79b82r12wbc5jf200000gn/T/qiime2-q2cli-err-2koftfe9.log

Then when I read it:

/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/site-packages/q2_protein_pca/_plot.py:136: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  plot_values['euclid_dist'] = plot_values.apply(
/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/site-packages/q2_protein_pca/_plot.py:138: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
  plot_values['max_distance'] = plot_values['euclid_dist'].max()
Traceback (most recent call last):
  File "/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/site-packages/q2cli/commands.py", line 339, in __call__
    results = action(**arguments)
  File "<decorator-gen-50>", line 2, in plot_loadings
  File "/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/site-packages/qiime2/sdk/action.py", line 245, in bound_callable
    outputs = self._callable_executor_(scope, callable_args,
  File "/Users/vramirezc/opt/miniconda3/envs/protein-pca/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 "/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/site-packages/q2_protein_pca/_plot.py", line 172, in plot_loadings
    _plot_loadings(
  File "/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/site-packages/q2_protein_pca/_plot.py", line 152, in _plot_loadings
    context['vega_spec'] = json.dumps(spec)
  File "/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)

I have tried to solve this error by checking thousand times my input file but I do not see the error. I ran the examples file and they worked but not my files. I do not understand what is wrong with them.

Please let me know if you have any suggestions.

Thanks,
vramirezc

I have tried debugging and found that the problem is the sequence from my fasta file (not the headers, not the metadata file). But I downloaded it again, looked for lowercase letters, and spaces, and still got the error. Please help me! I really cannot find what is wrong.

Thanks!

Hello @vramirezc, welcome to the forum!

Sorry to hear you are experiencing issues with the protein-pca plugin and thanks for reporting the problem. Do you think you could provide a sample of your file for which you have observed that issue? It would help with debugging. Thanks in advance!

Cheers,
Michal

1 Like

Thanks! Yes of course. (The name are the same as the example but the content is different).

Fasta file: thioredoxin-seqs.fasta - Google Drive

Metadata: thioredoxin-metadataE.tsv - Google Drive

Let me know if the links work.

Thanks again!

Hey @vramirezc! Thanks for providing the files - yes, the links do work.

The good news is that nothing is wrong with your data. As a matter of fact, you have identified a little :bug: in q2-protein-pca: it turns out it would break when there are no gaps in an alignment :scream: It should be fixed now - it would be great if you could try it again. I had to update/refresh the installation instructions a little - please check those out here before reinstalling anything.

Let me know how it went, when you get a chance to try it out! :pray:

Best,
Michal

3 Likes

Hi Michal,

Thank you very much for solving this problem! It worked perfectly. However, when I was reinstalling I used the 'conda' command instead of 'mamba' (mamba did not work). As following:

conda create -yn protein-pca \
  -c conda-forge -c bioconda -c https://packages.qiime2.org/qiime2/2022.4/tested -c defaults \
  q2-protein-pca q2cli q2-emperor

Thanks again,
Valeria

2 Likes

This post was flagged by the community and is temporarily hidden.