qiime2r read_q2metadata problem?

I'm trying to use qiime2r to make stacked taxomonic barplots. I followed the tutorial with moving-pictures files everything works great. However, when I use my data I have issues. When I manually add a #q2:types row to my metadata, the read_q2metadata() command throws an error:

Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
scan() expected 'a real', got 'Blank'

I can successfully read in my metadata using:

read.table("metadata-trial2.tsv", sep="\t", comment.char="", header=T)

When I take a look at this dataframe in R all looks right with the world (although I notice that "sample-id" stays "sample-id" whereas in the moving-pictures metadata file, "sample-id" is converted to "SampleID" after read_q2metadata() which seems to suggest that R is viewing my metadata file differently).

My issue manifests when I plot using taxa_barplot(taxasums, metadata, "Treatment"). The resulting barplot does not have facets by Treatment. Instead, all bars are together with a glaring NA at the top. I suspect 3 potential causes of this problem but I'm not sure how to figure out which and solve the problem.

  1. my metadata.tsv is not formatted correctly.
  2. my metadata.tsv is not being read into R correctly.
  3. my metadata files does have more rows/samples than are in my table.qza artifact because of filtering steps in qiime. I'm not sure if this is causing an issue, and whether my metadata has to be a direct match with the samples in my table.qza.

Thanks for your help! I really appreciate the qiime2R package.

Josh

I finally figured this out. There were 2 simultaneous problems with my metadata.

  1. 'Blank' was recorded in a #numeric column for sequencing blanks i.e. negative controls. The error code in R mentioned 'Blank' but it took me a while to realize this was not referring to the absence of data but actually the string 'Blank' not being accepted in a numeric column. This precluded my metadata from being read in with read_q2metadata()

  2. Somehow the metadata I was using for taxonomy had underscores (_) in sample IDs but the metadata used in the qiime pipeline had dashes (-). This threw no error code but precluded my plots from actually faceting by specified columns of my metadata (e.g. Treatment).

Finally, the plots I wanted, just in time for the holidays :christmas_tree: :gift:

I hope this can help someone else that stumbles upon a similar problem!

3 Likes