Issues using qiime2R

Hi Jbisanz

I am trying to go through the steps in your tutorial, but I keep getting this error:

> SVs<-read_qza(“table.qza”)
Error in unzip(file, exdir = tmp) : ‘exdir’ does not exist

I have set my working directory to where the files are located, and have googled to see if there is a way to fix this, but no luck.



I was going through your tutorial, and I am stumped on one portion. I am trying to concert the taxonomy data into a tabular split version of itself, using your code above. After running the code, I see that the data does not split as suggested, and the taxonomy levels instead are filled with "NA". Could you please give me some input?


Hi, I have a quick question on running alpha and beta diversity in R-studio.

I tried the code you supplied and changed the variables to those I am interested in, but I keep getting this error.I have looked online, but I am not having luck finding a method to fix it.

Aesthetics must be either length 1 or the same as the data (192): x, y, shape, colour, size


My best guess is that you made a typo in your variable name in the mapping aesthetics (aes) portion. I believe this error happens if the column name doesn’t exist in the input data to ggplot. Check this and if it doesn’t fix your problems can you please upload either the artifact itself or an RDS file of your pca object? Please include your exact code as well.

Hi, I actually fixed this error, but forgo to delete my question. I do have another question, and although I’ve spend 2 hours trying to figure it out, I cannot.

When I try to recreate the alpha diversity in R, I get this error
Error: Aesthetics must either be length one, or the same length as the data

This is my code:
obsOTU$data %>% %>%
rownames_to_column("#SampleID") %>%
left_join(metadata) %>%
mutate(TimeSinceFire=as.numeric(TimeSinceFire)) %>% #coerce this to be stored as number
ggplot(aes(x=TimeSinceFire, y=obsOTU, group=Treatment, color=Site, shape=Unit)) +
geom_point(size=8) +
geom_line() +
facet_grid(Site~Treatment) + #plot body sites across rows and subjects across columns
theme_bw() +
xlab(“TimeSinceFire (years)”) +
ylab(“Observed OTU’s”) +
ggtitle(“Observed OTU’s across time”)

I am mimicing what you have done, just to see if I undestand, but I am stuck.

If you could please help me out that would be great, and if you have any other tutorials, please let me know. I am currently trying to create a PCA, but I am unsure how to do with qiime outputs.

obsOTU$data %>% %>%
rownames_to_column("#SampleID") %>%
left_join(metadata) %>%
mutate(TimeSinceFire=as.numeric(TimeSinceFire)) %>% head()

Can you run this part and send the output?

1 Like

I just wanted to apologize, I have not had a chance to re-run your fixed code. I will and let you know if it works. Ben

Yes, give me a second.

(Not sure what I am supposed to be looking for?)

I have an additional question, when trying to create a phyloseq object I continue to get this error, even when I am in the correct directory. Can you please help me with this as well? So I tried creating it using this code, but I still get an error.

physeq<-phyloseq(otu_table(ECMtable$data, taxa_are_rows = T), phy_tree(tree$data), tax_table(taxtable), sample_data(metadata))

phy<-qza_to_phyloseq("burn-rarefied-table.qza", "burn-rooted-tree-EcM.qza", "taxonomy.qza","Metadata.tsv", tmp = "C:/tmp")

Error in unzip(file, exdir = tmp, list = TRUE) : _
_ zip file 'burn-rarefied-table.qza' cannot be opened

In addition: Warning message:
In unzip(file, exdir = tmp) : error 1 in extracting from zip file

I suggest that you reserve the practice of "deleting a question after it has been asked" for when you truly need it, like after publishing sensitive data on accident. Otherwise, this generates a lot of "noise" on the forum for other users, and, can make things pretty confusing for us when we try and figure out how to go about helping you. Maybe one strategy is if you think there is a chance you would want to delete your post, wait an hour or two before before posting it, just to make sure it is actually what you intend to post. Thanks! :qiime2:

ggplot(aes(x=TimeSinceFire, y=obsOTU, group=Treatment, color=Site, shape=Unit)) +

On this line, each variable (x,y,group,color,shape) needs to be a column in your input. It would appear that the variable you want to map to y is observed_otus rather than obsOTU so you should have:

ggplot(aes(x=TimeSinceFire, y=observed_otus, group=Treatment, color=Site, shape=Unit)) +

In regards to the unzip error, that error is most likely saying that the file isn’t found. I am somewhat confused, do both of those functions return the same error or just the second? Check that the input file exists in your current working directory with list.files() and that you have not made a typo in its name. You can either set your working directory to the one containing your file setwd("/path/to/your/dir/") or use an absolute file path (read_qza("/path/to/burn-rarefied-table.gza")).

1 Like

I see, for some reason I though that since obsOTU (the complete datafile). I was thinking it looked like table.qza and that it only contained frequencies, as it appears in Qiime. Thank you, and thank you for showing me the code to look at the header of the joined data.frame.

Let me run the phyloseq code again and see if I can check the error again.

Sorry about that, I thought having unecessary questions made it worst, but I will make sure not to do this again.


So I restarted R, and set the working directory again and it worked. :slight_smile:

Thanks again

Bookkeeping note, I’ve migrated this thread to a new topic and un-deleted the questions.


strong text
Hi again,

So, the code worked but it kept my taxonomy as a string
k_;p_; … instead of breaking it down to 7 levels. Is there anything I can do about this when I run the code using qza_to_phyloseq? It works perfectly when I use phyloseq().

phy<-qza_to_phyloseq(“R-phylo/burn-rarefied-table.qza”, “R-phylo/burn-rooted-tree-EcM.qza”,
“R-phylo/taxonomy.qza”,“R-phylo/Metadata.tsv”, tmp = “C:/tmp”)


So after working with phyloseq all day, the program froze and I had to restart it, and although I loaded everything the same way and have closed and restarted laptop, I continue to get this error.


  • otu_table(table$data, taxa_are_rows = T),
  • phy_tree(tree$data),
  • tax_table( %>% select(-Confidence) %>% column_to_rownames(“Feature.ID”) %>% as.matrix()), #moving the taxonomy to the way phyloseq wants it
  • sample_data(metadata %>% %>% column_to_rownames("#SampleID"))
  • )

Error: Column num2 not found


Sorry to message you again. My R-studio was acting very glitchy and the University uninstalled it and reinstalled it, but now I am having a problem loading QIIME2R.

I’ve tried a few times, but continue to get this error, can you please help me, again.

Downloading GitHub repo jbisanz/[email protected]
from URL
Installing qiime2R
“C:/Users/fabipc/DOCUME~1/R/R-35~1.1/bin/x64/R” --no-site-file --no-environ --no-save
–no-restore --quiet CMD INSTALL
–library=“C:/Users/fabipc/Documents/R/R-3.5.1/library” --install-tests

  • installing source package ‘qiime2R’ …
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
    there is no package called ‘BiocGenerics’
    ERROR: lazy loading failed for package ‘qiime2R’
  • removing ‘C:/Users/fabipc/Documents/R/R-3.5.1/library/qiime2R’
    Installation failed: Command failed (1)

It would appear you might have lost some bioconductor packages as well. Run this code at it should hopefully fix it up:

1 Like

I am unsure exactly what is happening here or your previous pos. Without some snapshot into the inputs, I can’t really diagnose it. In the future can you post a more complete example of the code and the inputs (with the first couple rows and columns of tables). I suspect the Error: Column num2 not found is related to one of your column_to_rownames() functions and that the column which you are trying to find to make rownames doesn’t exist in the input table.

1 Like