Help wanted to run ANCOM BC

Hello, I am trying to follow this protocol for studying ANCOM BC.

However, after I read in all my files and try to merge the data using the following commands

ps <- phyloseq(OTU, TAX, SAMPLE,TREE) it shows this error.
Error in validObject(.Object) : invalid class “phyloseq” object: **
** Component sample names do not match.

** Try sample_names()**
I tried transposing the metadata file to make sure the OTU file row names match but the problem persists. I can read in the data and make the phyloseq object when using qiime2R but not as the tutorial show.
Further down the line, even if I use qiime2R to import the data , I face the following problems when analysing.I have attached screen shot of what my data looks like.
What should I do?



He, could you please approve the post. It's urgent :sob:. I have been stuck here for days.

Hi @newbietobioinfo,
The issue you are having seems to be related to Phyloseq in R and not QIIME 2. While we do have some R/Phyloseq users on the moderator team, these questions tend to not be prioritized so it may take a while to get a solution. If this is an urgent issue, which sounds like it is, I would consider posting this on the phyloseq github page.

Just a quick follow up on it, you say if you use qiime2R you can create the phyloseq object, so what seems to be the problem with your downstream analysis? It doesn't matter how you make your phyloseq object, once it's built it should be compatible with ANCOM-BC. Your attached photos don't include any issues to troubleshoot?

Thank you for your reply and suggestions.
During Ancom BC , I keep getting a notification saying Error: The group variable should have >= 2 categories.
I am using locality column from my metadata which has four sub categories and I had specified two of them.( attached SS)The reason I uploaded the previous three pictures is to ask if my taxonomy table, feature table and metadata table had any error due to which the functions might not be running appropriately. I keep facing trouble with these files for MaSaLin2 as well and had posted in their forum for an answer as well. I am waiting for their reply. Again, I appreciate all the help as I am really struggling to understand the microbial data more even though I have been trying to go over as many resources as possible.

Hi @newbietobioinfo,

This sounds like a new unrelated issue.
The message here is clear that the metadata/phyloseq object you are using in ANCOMBC does not have at least 2 groups. Without having access to the data or without some background information this is really hard to troubleshoot. I'll give you some starting points though:

  1. On line 53, you create a new object called ps.taxa.pse which you then add pseudocounts to on line 54. However, on line 57 when you are trying to subset your object you don't use ps.taxa.pse, instead you use the original px.taxa. I'm guessing this is a mistake.
  2. Double check that your spelling of your 2 locality groups are correct and confirm that the new subset phyloseq object actually has 2 groups as you expected. ex try this:
sample_data(ps.taxa.sub)$locality %>% table()
  1. For your ANCOMBC analysis you are removing samples with less than 1000 reads. Check to see if you were to do this filtering you would have enough samples left, ex
(sub2 <- prune_samples(sample_sums(ps.taxa.sub > 1000, ps.taxa.sub)))
sample_data(sub2)$locality %>% table()
  1. It looks like you convert locality to a factor for DESeq2, maybe this doesn't play nice with ANCOMBC? Try keeping it just as a character vector instead of factor and try again?

Thanks for all the help. I will try to go over your suggestions

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