Issues using qiime2R

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:
#PLOTTING ALPHA DIVERSITY
obsOTU$data %>%
as.data.frame() %>%
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 %>%
as.data.frame() %>%
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.

thanks

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.

3 Likes

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”)

HI,

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.

physeq<-phyloseq(

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

Error: Column num2 not found

Hi,

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.

devtools::install_github("jbisanz/qiime2R")
Downloading GitHub repo jbisanz/qiime2R@master
from URL https://api.github.com/repos/jbisanz/qiime2R/zipball/master
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
"C:/Users/fabipc/AppData/Local/Temp/RtmpoVb970/devtools27bc6a53f57/jbisanz-qiime2R-ba443df"
--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'
    In R CMD INSTALL
    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:

source("https://bioconductor.org/biocLite.R")
biocLite("BiocGenerics")
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

Hi!!

I am also having issues using qiime2R.

phyloseq <- qza_to_phyloseq(features = "table.qza", tree = "rooted-tree.qza", taxonomy = "taxonomy.qza", metadata = "Updated_metadata.tsv")

My physoseq object looks like this:

And when I try to create a bar plot

bar_plot <- plot_bar(phyloseq, fill = "Phylum")

I get the error:

Error in FUN(X[[i]], ...) : object 'Phylum' not found

Hi Kaylee,

I see why this has happened. The taxonomy string is not stored in a fixed-width format inside the artifact and was getting an arbitrary column title (ta1->ta7). A quick work around that should work now is plot_bar(phyloseq, fill="ta2").

I just pushed an update that should more carefully import the taxonomy and explicitly name the columns such that plot_bar(phyloseq, fill="Phylum") should work. Just reinstall using devtools::install_github("jbisanz/MicrobeR") to get the newest version.

Jordan

3 Likes

Wonderful! It is working now. Thank you so much for your quick reply.

A post was split to a new topic: R dataframe join error: Can’t join on ‘#SampleID’ x ‘#SampleID’ because of incompatible types