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