ValueError: The following IDs are not present in the metadata

Hello, I'm currently using the R package to analyze 16S data (dada2 and phyloseq). As a result, I built a phyloseq object in R, which I then wanted to import into qiime2 to continue the analysis:- However, I'm having problems and need assistance.

In R

Export taxonomy table as "tax.txt"

tax<-as(tax_table(ps),"matrix")
tax_cols <- colnames(tax)
tax<-as.data.frame(tax)
tax$taxonomy<-do.call(paste, c(tax[tax_cols], sep=";"))
for(co in tax_cols) tax[co]<-NULL
write.table(tax, "tax.txt", quote=FALSE, col.names=FALSE, sep="\t")

Export feature/OTU table

As a biom file

library(biomformat);packageVersion("biomformat")

[1] '1.6.0'

#if taxa are rows = FALSE
otu<-t(as(otu_table(ps),"matrix")) # 't' to transform if taxa_are_rows=FALSE
#if taxa_are_rows=TRUE
otu<-as(otu_table(prevabun_tree0),"matrix")
otu_biom<-make_biom(data=otu)
write_biom(otu_biom,"otu_biom.biom")

Export metadata

write.table(sample_data(ps),"sample-metadata.txt", sep="\t", row.names=FALSE, col.names=TRUE, quote=FALSE)

The phylogenetic tree was extracted from the ps object (which was identical to the ones above) and imported as an unrooted tree into qiime2.

The biom file, tax, and metadata were then loaded into qiime2. This became successful. When I tried to use the following command, however, it didn't work.
qiime feature-table summarize
--i-table feature-table.qza
--o-visualization feature-table.qzv
--m-sample-metadata-file sample-metadata-inter.txt

I'm getting an error that's related to this query. (qiime2-q2cli-err-luqiime2-q2cli-err-ludqvmq0.txt (3.6 MB) dqvmq0) - The log file can be found here.

Further trial on taxonomy bar plot generate an error (qiime2-q2cli-err-oofkziqbqiime2-q2cli-err-oofkziqb.txt (3.6 MB) )The lof file can be found here

qiime taxa barplot
--i-table feature-table.qza
--i-taxonomy taxonomy.qza
--m-metadata-file sample-metadata-inter.txt
--o-visualization taxa-bar-plots.qzv

Here is the list of variables in the metadata (few examples)
sample-id
Baseline-Endline
school
Intervention-groups
I appreciate your help in advance.

Hi, Yoha!

I am not an expert in R. From log I can see you need to transpose your OTU-table, so that that sequences are recorded in rows, and sample-ids in columns.
As I understand from your code, you need to choose only one line to define otu variable correctly, and you have two to choose from. The second one replaces the first definition of the otu. Choose one and see which one does the work.
Then redo the steps you've done before through QIIME2 and it should work.

Cheers,

1 Like

Hello, I see that the question I asked on the forum was answered by crusher083. However, I attempted without success to implement the solution. I thought I would ask you since I used the script from your prior posts. I exported the phyloseq object using the following script:-

Export taxonomy table as "tax.txt"

I used this step to export tax_table

tax<-as(tax_table(ps),"matrix")
tax_cols <- colnames(tax)
tax<-as.data.frame(tax)
tax$taxonomy<-do.call(paste, c(tax[tax_cols], sep=";"))
for(co in tax_cols) tax[co]<-NULL
write.table(tax, "tax.txt", quote=FALSE, col.names=FALSE, sep="\t")

Export feature/OTU table

As a biom file

library(biomformat);packageVersion("biomformat")

[1] ‘1.6.0’

#if taxa_are_rows=TRUE use the following step
otu<-as(otu_table(GlobalPatterns),"matrix"))
otu_biom<-make_biom(data=otu)
write_biom(otu_biom,"otu_biom.biom")

When I am trying to summarize the feature table, I'm still getting the "ValueError: The following IDs don't appear in the metadata" (log file attached). I have taken into account the answer from crusher083 (the sequences are rows and sample-ids columns). I could not process my data further. I included OTU, taxonomy and sample-metadata screenshots (from qiime2view). Can you help me in this respect, please?

PS biom is imported into qiime2 as follows
qiime tools import
--input-path OTU1.biom
--type 'FeatureTable[Frequency]'
--input-format BIOMV100Format
--output-path feature-table.qza

Thanks in advance for your help.

This means that there is a mismatch between the Sample IDs in your Metadata file and the Sample IDs in your feature table. The easiest way to confirm is to run the feature-table summarize command without the metadata file - the resulting viz will report back to you all of the IDs in the table. Compare that to your feature table and then come up with a plan from there to figure out where things went wrong (probably in R somewhere, since that's where you're doing a bunch of manual manipulation of your data - please note, we can't really help with that, we don't really provide R support here).

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