How to make barplots for selected features

I have identified specific features that differ between two genotypes using ANCOM. I would like to make barplots to show the frequency of each feature (normalized to take into account the total number of features) in each mouse. How can I do this?

Hello Luc,

Welcome to the forums! :qiime2:

Are you running a new (or newest) version of Qiime2? I ask because we now include a tool for making barplots from ANCOM-BC results!

qiime composition da-barplot --help

https://docs.qiime2.org/2023.9/plugins/available/composition/da-barplot/

Let us know if that plugin works for you!
Colin

P.S. Posting one time helps us keep the forums tidy. We will answer all technical support posts in time.

4 Likes

Thanks Colin, but it does not work.

I have using qiime2-amplicon-2023.9 and I have freshly installed R, ANCOMBC, and qiime2 plugin as described here: GitHub - mortonjt/q2-ancombc: qiime2 plugin for ANCOMBC

When I run the following command:

qiime composition ancombc
--i-table table.qza
--m-metadata-file SampleMetaData.tsv
--p-formula genotype
--o-differentials differentials.qza

I obtain the error below. Do you have any idea what went wrong?

Luc

Plugin error from composition:

An error was encountered while running ANCOM-BC in R (return code 1), please inspect stdout and stderr to learn more.

Debug info:
Running external command line application(s). This may print messages to stdout and/or stderr.
The command(s) being run are below. These commands cannot be manually re-run as they will depend on temporary files that no longer exist.

Command: run_ancombc.R --inp_abundances_path /var/folders/sb/vjvq0d0d207960xnrsnx9njr0000gn/T/tmpje134e2n/input.biom.tsv --inp_metadata_path /var/folders/sb/vjvq0d0d207960xnrsnx9njr0000gn/T/tmpje134e2n/input.map.txt --md_column_types {"mouse-id": "numeric", "cage-id": "numeric", "sex": "categorical", "age-week": "numeric", "weight-g": "numeric", "day-of-onset": "numeric", "maximal-eae-score": "numeric", "eae-incidence": "categorical", "group": "categorical", "genotype": "categorical"} --formula genotype --p_adj_method holm --prv_cut 0.1 --lib_cut 0 --reference_levels ['genotype::Wild_type'] --tol 1e-05 --max_iter 100 --conserve False --alpha 0.05 --output_loaf /var/folders/sb/vjvq0d0d207960xnrsnx9njr0000gn/T/q2-DataLoafPackageDirFmt-miowtl87

R version 4.2.2 (2022-10-31)
Message d'avis :
NAs introduits lors de la conversion automatique
Message d'avis :
NAs introduits lors de la conversion automatique
Message d'avis :
NAs introduits lors de la conversion automatique
Message d'avis :
NAs introduits lors de la conversion automatique
Message d'avis :
NAs introduits lors de la conversion automatique
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
:heavy_check_mark: dplyr 1.1.4 :heavy_check_mark: readr 2.1.5
:heavy_check_mark: forcats 1.0.0 :heavy_check_mark: stringr 1.5.1
:heavy_check_mark: ggplot2 3.4.4 :heavy_check_mark: tibble 3.2.1
:heavy_check_mark: lubridate 1.9.3 :heavy_check_mark: tidyr 1.3.0
:heavy_check_mark: purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
:heavy_multiplication_x: dplyr::filter() masks stats::filter()
:heavy_multiplication_x: dplyr::lag() masks stats::lag()
:information_source: Use the conflicted package (http://conflicted.r-lib.org/) to force all conflicts to become errors
Registered S3 methods overwritten by 'treeio':
method from
MRCA.phylo tidytree
MRCA.treedata tidytree
Nnode.treedata tidytree
Ntip.treedata tidytree
ancestor.phylo tidytree
ancestor.treedata tidytree
child.phylo tidytree
child.treedata tidytree
full_join.phylo tidytree
full_join.treedata tidytree
groupClade.phylo tidytree
groupClade.treedata tidytree
groupOTU.phylo tidytree
groupOTU.treedata tidytree
is.rooted.treedata tidytree
nodeid.phylo tidytree
nodeid.treedata tidytree
nodelab.phylo tidytree
nodelab.treedata tidytree
offspring.phylo tidytree
offspring.treedata tidytree
parent.phylo tidytree
parent.treedata tidytree
root.treedata tidytree
rootnode.phylo tidytree
sibling.phylo tidytree
Erreur dans h(simpleError(msg, call)) :
erreur d'�valuation de l'argument 'x' lors de la s�lection d'une m�thode pour la fonction 't' : impossible d'ouvrir la connexion
Appels : t ... read.delim -> read.table -> file -> .handleSimpleError -> h
De plus : Message d'avis :
Dans file(file, "rt") :
impossible d'ouvrir le fichier '--inp_abundances_path' : No such file or directory
Exécution arrêtée
Traceback (most recent call last):
File "/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/q2_composition/_ancombc.py", line 253, in _ancombc
run_commands([cmd])
File "/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/q2_composition/_ancombc.py", line 32, in run_commands
subprocess.run(cmd, check=True)
File "/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/subprocess.py", line 516, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['run_ancombc.R', '--inp_abundances_path', '/var/folders/sb/vjvq0d0d207960xnrsnx9njr0000gn/T/tmpje134e2n/input.biom.tsv', '--inp_metadata_path', '/var/folders/sb/vjvq0d0d207960xnrsnx9njr0000gn/T/tmpje134e2n/input.map.txt', '--md_column_types', '{"mouse-id": "numeric", "cage-id": "numeric", "sex": "categorical", "age-week": "numeric", "weight-g": "numeric", "day-of-onset": "numeric", "maximal-eae-score": "numeric", "eae-incidence": "categorical", "group": "categorical", "genotype": "categorical"}', '--formula', 'genotype', '--p_adj_method', 'holm', '--prv_cut', '0.1', '--lib_cut', '0', '--reference_levels', "['genotype::Wild_type']", '--tol', '1e-05', '--max_iter', '100', '--conserve', 'False', '--alpha', '0.05', '--output_loaf', '/var/folders/sb/vjvq0d0d207960xnrsnx9njr0000gn/T/q2-DataLoafPackageDirFmt-miowtl87']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/q2cli/commands.py", line 520, in call
results = self._execute_action(
File "/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/q2cli/commands.py", line 581, in _execute_action
results = action(**arguments)
File "", line 2, in ancombc
File "/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/qiime2/sdk/action.py", line 342, in bound_callable
outputs = self.callable_executor(
File "/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/qiime2/sdk/action.py", line 566, in callable_executor
output_views = self._callable(**view_args)
File "/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/q2_composition/_ancombc.py", line 41, in ancombc
return _ancombc(
File "/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/lib/python3.8/site-packages/q2_composition/_ancombc.py", line 255, in _ancombc
raise Exception('An error was encountered while running ANCOM-BC'
Exception: An error was encountered while running ANCOM-BC in R (return code 1), please inspect stdout and stderr to learn more.

1 Like

Hi @luvalli!

Would you mind sharing your input table and metadata file with me to see if I can replicate this issue on my end? If you'd prefer not to share these files publicly, you can send them to me via DM.

Thanks! :lizard:

1 Like

This morning, I obtain the same error using the tutorial available here (see Getting started): GitHub - mortonjt/q2-ancombc: qiime2 plugin for ANCOMBC.

Here are the requested files:

SampleMetaData.tsv (1.1 KB)
Table.qza (69.8 KB)

Thanks a lot!

1 Like

Hi @luvalli,

Thanks for sharing those files! I was able to reproduce this error on my end, and it certainly is strange. Here's the part of the traceback that stands out to me:

4: stop("duplicate 'row.names' are not allowed")
3: read.table(file = file, header = header, sep = sep, quote = quote,
       dec = dec, fill = fill, comment.char = comment.char, ...)
2: read.delim(inp_abundances_path, check.names = FALSE, row.names = 1)

What I've gathered from this is that the read.table method is seeing duplicate row names in your table - but I examined your feature table and was unable to find dupliate row names anywhere - all of your features and samples have unique IDs.

@jwdebelius have you ever come across something like this before in your R adventures? I'm a bit stumped on where the duplicate row names could be coming from. I also tested this out with our example data just to make sure there isn't a bug in ANCOM-BC itself, but that ran as expected.

1 Like

Hello,

After reinstalling Microconda, Qiime2 Amplicon, and ANCOM-BC, I still get the same error with my own data or the tutorial data. Below is my command and the error message.

Any ideas on how to solve this problem? Thanks in advance.

Luc

qiime composition ancombc
--i-table table.qza
--m-metadata-file metadata.txt
--p-formula "labels"
--o-differentials differentials.qza

Plugin error from composition:
An error was encountered while running ANCOM-BC in R (return code 1), please inspect stdout and stderr to learn more.
Debug info has been saved to /var/folders/sb/vjvq0d0d207960xnrsnx9njr0000gn/T/qiime2-q2cli-err-2qe2hwao.log

Hello Luc,

Can you post that file here so we can take a look?

Here are they (same files as in my previous message). The table is the output of DADA2, is that OK?

@lizgehret mentioned that he was able to reproduce the error, but the files seem OK.

Contrary to @lizgehret, I have the same problem with tutorial data.

Thanks in advance.

Table.qza (69.8 KB)
SampleMetaData.tsv (1.1 KB)

1 Like

Hi @luvalli,

After reinstalling Microconda, Qiime2 Amplicon, and ANCOM-BC,

It's possible that the issue here is that you don't need to be installing ANCOM-BC independently of QIIME 2. Could try reinstalling the QIIME 2 amplicon distribution, and then running your qiime composition ancombc command?

To explain why I think this might be the issue: The plugin repository that you're referring to is a third-party plugin that pre-dated the including of ancombc in the QIIME 2 amplicon distribution, so I think the install instructions you're following there might be causing some problems with your QIIME 2 environment. Sorry for the confusion - I'm going to touch base with the developer of that plugin (cc @mortonjt) to see if a note could be added to avoid this confusion in the future.

1 Like

Hello and thank you @gregcaporaso!

Unfortunately, after re-installing QIIME2 without the independent ANCOM-BC plug-in, I get the same error:

Plugin error from composition:

An error was encountered while running ANCOM-BC in R (return code 1), please inspect stdout and stderr to learn more.

Debug info has been saved to /var/folders/sb/vjvq0d0d207960xnrsnx9njr0000gn/T/qiime2-q2cli-err-tnam0r9y.log

Hi @luvalli,
Sorry for the delayed response! Could you run qiime info and post the screenshot?

As requested, here is the qiime info:

System versions

Python version: 3.8.18

QIIME 2 release: 2023.9

QIIME 2 version: 2023.9.2

q2cli version: 2023.9.1

Installed plugins

alignment: 2023.9.0

composition: 2023.9.0

cutadapt: 2023.9.0

dada2: 2023.9.0

deblur: 2023.9.0

demux: 2023.9.1

diversity: 2023.9.0

diversity-lib: 2023.9.0

emperor: 2023.9.0

feature-classifier: 2023.9.0

feature-table: 2023.9.0

fragment-insertion: 2023.9.0

longitudinal: 2023.9.1

metadata: 2023.9.0

phylogeny: 2023.9.0

quality-control: 2023.9.0

quality-filter: 2023.9.0

sample-classifier: 2023.9.0

taxa: 2023.9.0

types: 2023.9.0

vsearch: 2023.9.0

Application config directory

/Users/lucvallieres/miniconda3/envs/qiime2-amplicon-2023.9/var/q2cli

Hi @luvalli,
That looks all good to me!

This one is definitely a confusing problem! We have multiple of our mods looking into this issue and we will let you know what is going on as soon as we know.

Thank you so much for your patience!

1 Like

Hi @luvalli,
Sorry again for how long this took! I have figured it out and its something pretty silly.

The back-end of this method was written in R and turns out it does not like your sample ids very much. I am not a 100% sure the reason.

My best guess is that your ids, like 33002E607, are getting converted to exponents because they look like "(numbers)E 607". I think we are losing some resolution when it converts them and its turning at least 2 ids into "duplicates" like 33001E607 and 33002E607 into 3300E608.

I was able to get it to work by finding and replacing the E in your ids to an F.

So my recommendation would be that you should rename your samples without the E values. I should mentions that your sample-ids should be fine for all other methods, ANCOM-BC should be the only one with this bug.

There are two ways that you could rename your samples for ancombc.

  1. You could go edit all the fastq files that you imported to say something different.

    Instead of the file name being this:
    Screenshot 2024-01-30 at 2.24.08 PM
    It would be something like this:
    33001F607_S1251_L001_R1_001.fastq.gz.

    Then when you go to import 33001F607 would be your sample ids. Just don't forget to change it in the metadata as well. However this would require that you re-do all your quality control steps.

  2. You could use feature-table group to rename your files. All you would need is a mapping file that says what your samples is currently names and what it should be named. For example:

    SampleID New-sample-id
    33002E607 33002F607
    33001E607 33001F607

    Don't forget that your newly named data will need metadata that has the new sample ids.

I am aware that this is not a perfect solution, but I hope it allows you to continue on with your analysis. I have opened up an issue on our github so that we can fix this bug. Here is the issue, if you want to follow progress on this. Feel free to add any additional information that might help!

Thank you so much for reporting this issue and for your patience as we try to figure out what was going on.
If you have any other questions, we are here to help!
:turtle:

4 Likes

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

This bug in ancom-bc has been fixed in qiime2-2024.5

https://docs.qiime2.org/2024.5/plugins/available/composition/ancombc/

1 Like