Error while qiime protein-pca SettingWithCopyWarning


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/ 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:
  plot_values['euclid_dist'] = plot_values.apply(
/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/site-packages/q2_protein_pca/ 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:
  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/", 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/", 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/", 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/", line 172, in plot_loadings
  File "/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/site-packages/q2_protein_pca/", line 152, in _plot_loadings
    context['vega_spec'] = json.dumps(spec)
  File "/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/json/", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/Users/vramirezc/opt/miniconda3/envs/protein-pca/lib/python3.8/json/", 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.


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.


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!


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:



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 -c defaults \
  q2-protein-pca q2cli q2-emperor

Thanks again,


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