# general discussion of qiime2r tutorial

**URL:** https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818
**Category:** Library Support
**Created:** [April 12, 2019, 9:27pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818 "2019-04-12T21:27:05Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![Irshad](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/i/8797f3/32.png) [@Irshad](https://forum.qiime2.org/u/Irshad)
#### Post date: [July 24, 2020, 9:27pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/21 "2020-07-24T21:27:53Z")

</div>

Hi @jbisanz,

I have some trouble with the following script as it gives me an error which I searched online but could not rectify it. Do you have some time to look into it?  
Thank you,

> metadata \<- read\_q2metadata("qiime2/metadata.tsv")  
> SVs \<- read\_qza("table-with-no-mt-no-chlp.qza")$data  
> taxonomy \<- read\_qza("qiime2/taxonomy-single-end.qza")  
> SVs \<- apply(SVs, 2, function(x) x/sum(x)\*100)  
> SVsToPlot \<- data.frame(MeanAbundance=rowMeans(SVs)) %\>%

- rownames\_to\_column("Feature.ID") %\>%
- arrange(desc(MeanAbundance)) %\>%
- top\_n(30, MeanAbundance) %\>%
- pull(Feature.ID)

> SVs %\>%

- as.data.frame()%\>%
- rownames\_to\_column("Feature.ID") %\>%
- gather(-Feature.ID, key="SampleID", value = "Abundance") %\>%
- mutate(Feature.ID=if\_else(Feature.ID %in% SVsToPlot, Feature.ID, "Remainder")) %\>%
- group\_by(SampleID, Feature.ID) %\>%
- summarize(Abundance=sum(Abundance)) %\>%
- left\_join(metadata) %\>%
- mutate(NormAbundance=log10(Abundance+0.01)) %\>%
- left\_join(taxonomy) %\>%
- mutate(Feature=paste(Feature.ID, Taxon)) %\>%
- mutate(Feature=gsub("[kpcofgs\_\_", "", Feature)) %\>%
- ggplot(aes(x=SampleID, y=Feature, fill= NormAbundance))+
- geom\_tile()+
- facet\_grid(~`category`, scales = "free-x") +
- theme\_q2r() +
- theme(axis.text.x = element\_text(angle = 45, hjust=1)) +
- scale\_fill\_viridis\_c(name= "log10(% Abundance)")  
`summarise()` regrouping output by 'SampleID' (override with `.groups` argument)  
Joining, by = "SampleID"  
Error: `x` and `y` must share the same src, set `copy` = TRUE (may be slow).  
Run `rlang::last_error()` to see where the error occurred.

> rlang::last\_error()  
> \<error/rlang\_error\>  
> `x` and `y` must share the same src, set `copy` = TRUE (may be slow).  
> Backtrace:

1. base::as.data.frame(.)
2. tibble::rownames\_to\_column(., "Feature.ID")
3. tidyr::gather(., -Feature.ID, key = "SampleID", value = "Abundance")
4. dplyr::mutate(...)
5. dplyr::group\_by(., SampleID, Feature.ID)
6. dplyr::summarize(., Abundance = sum(Abundance))
7. dplyr::left\_join(., metadata)
8. dplyr::mutate(., NormAbundance = log10(Abundance + 0.01))
9. dplyr::left\_join(., taxonomy)
10. dplyr::auto\_copy(x, y, copy = copy)
11. dplyr:::glubort(...)  
Run `rlang::last_trace()` to see the full context.

> rlang::last\_trace()  
> \<error/rlang\_error\>  
> `x` and `y` must share the same src, set `copy` = TRUE (may be slow).  
> Backtrace:  
> █

1. └─`%>%`(...)
2. ├─base::withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
3. └─base::eval(quote(`_fseq`(`_lhs`)), env, env)
4. 

```
└─base::eval(quote(`_fseq`(`_lhs`)), env, env)

```

5. 

```
  └─`_fseq`(`_lhs`)

```

6. 

```
    └─magrittr::freduce(value, `_function_list`)

```

7. 

```
      └─function_list[[i]](value)

```

8. 

```
        ├─dplyr::left_join(., taxonomy)

```

9. 

```
        └─dplyr:::left_join.data.frame(., taxonomy)

```

10. 

```
          └─dplyr::auto_copy(x, y, copy = copy)

```

11. 

```
            └─dplyr:::glubort(...)

```

---

<div class="post-metadata">

### Author: ![jbisanz](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jbisanz/32/1720_2.png) [@jbisanz](https://forum.qiime2.org/u/jbisanz)
#### Post date: [July 24, 2020, 9:46pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/22 "2020-07-24T21:46:08Z")

</div>

That is an interesting one... I have not seen this before. I would start by updating dplyr to the latest version and starting a fresh session. By any chance are you working on a remote server?

---

<div class="post-metadata">

### Author: ![Irshad](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/i/8797f3/32.png) [@Irshad](https://forum.qiime2.org/u/Irshad)
#### Post date: [July 24, 2020, 10:47pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/23 "2020-07-24T22:47:28Z")

</div>

Thank you @jbisanz for getting back so quickly - I really appreciate that. The RStudio is installed on my computer (standalone), however, the data I am analyzing is coming from the institute server (supercomputer).

Do you want me to start a fresh session and get dplyr updated? The same script was working two days ago on the same table and then suddenly it start behaving differently.

---

<div class="post-metadata">

### Author: ![jbisanz](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jbisanz/32/1720_2.png) [@jbisanz](https://forum.qiime2.org/u/jbisanz)
#### Post date: [July 27, 2020, 5:34pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/24 "2020-07-27T17:34:49Z")

</div>

Could you please:  
1- transfer the relevant artifacts to your personal computer  
2- make sure you have the working directory set to one on your computer  
3- Rerun the code and see if you can replicate this error?

---

<div class="post-metadata">

### Author: ![Irshad](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/i/8797f3/32.png) [@Irshad](https://forum.qiime2.org/u/Irshad)
#### Post date: [July 28, 2020, 2:09pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/25 "2020-07-28T14:09:46Z")

</div>

@jbisanz Thank you for your insight. Starting a new session worked for me.

Second, is there a way to show features on a heatmap at the higher taxonomical level (Class, Order)?

Thanks,  
Irshad

---

<div class="post-metadata">

### Author: ![Irshad](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/i/8797f3/32.png) [@Irshad](https://forum.qiime2.org/u/Irshad)
#### Post date: [July 28, 2020, 2:46pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/26 "2020-07-28T14:46:00Z")

</div>

Hi @jbisanz,

I get an error with the following while making a taxa barplot. The metadata file has two columns i.e. first coulmn = Sample ID, second column = category (Ff, Pb, and NA). Can I get rid of the following error? If I remove the "category" then the script works but I want the bar plots to be separated (facet grids) based on the above categories.

> metadata\<-read\_q2metadata("qiime2/metadata.tsv")  
> SVs\<-read\_qza("table-with-no-mt-no-chlp.qza")$data  
> taxonomy\<-read\_qza("qiime2/taxonomy-single-end.qza")$data %\>% parse\_taxonomy()  
> taxasums\<-summarize\_taxa(SVs, taxonomy)$Genus  
> taxa\_barplot(taxasums, metadata, "category")  
> Error in get(category) : invalid first argument

---

<div class="post-metadata">

### Author: ![jbisanz](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jbisanz/32/1720_2.png) [@jbisanz](https://forum.qiime2.org/u/jbisanz)
#### Post date: [July 28, 2020, 7:11pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/27 "2020-07-28T19:11:07Z")

</div>

Ha, this is a very funny error which appears to be caused by the fact that the variable inside the function is named category. Please rename the column to anything but "category" and it should work. I will patch this in the future.

---

<div class="post-metadata">

### Author: ![stinaroche](https://forum.qiime2.org/user_avatar/forum.qiime2.org/stinaroche/32/4823_2.png) [@stinaroche](https://forum.qiime2.org/u/stinaroche)
#### Post date: [August 13, 2020, 2:40am UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/28 "2020-08-13T02:40:40Z")

</div>

Hello,  
Your tutorial has been very helpful. We were able to make volcano plots and CLR bar plots for our differential taxa using your script. However, I was inputting the commands for the differential abundance volcano plot again, but this time trying to take out the leading higher taxonomy levels (K, P, O) to only label the lowest unambiguous taxonomic names (usually family and genus, but sometimes class) and it seems that our taxonomy file is not formatted specifically for your script adjustment mutate(Feature=paste(Phylum, Genus)). Similarly, when we try to parse our taxonomy file: it gives the error:

taxonomy\<-parse\_taxonomy(taxonomy)  
**Error in parse\_taxonomy(taxonomy) :**  
**Table does not match expected format (colnames(obj) are Feature.ID, Taxon, (Confidence OR Consensus))**

#so maybe the datatype in the second column (Taxon) is incorrect, or maybe it doesn't like the spaces in between the taxon names.

head(taxonomy)

# A tibble: 6 x 2

Feature.ID Taxon  
  
1 TACGAAGGGGGCTAGCGTTGTTCGGAATCACTGGGCGTAAAG… k\_ _Bacteria; p_ _Proteobacteria; c\_\_Alph…  
2 TACGTAGGGGGCAAGCGTTGTCCGGAATCATTGGGCGTAAAG… k_ _Bacteria; p_ _Actinobacteria; c\_\_Ther…  
3 TCCTGTTTGCTCCCCACGCTTTCGCGCCTCAGCGTCAGTAAT… k_ _Bacteria; p_ _Proteobacteria; c\_\_Delt…  
4 TACGTAGGGGGCGAGCGTTGTCCGGAATGACTGGGCGTAAAG… k_ _Bacteria; p_ _Firmicutes; c\_\_Clostrid…  
5 TACGGAGGGGGCTAGCGTTGTTCGGAATTACTGGGCGTAAAG… k_ _Bacteria; p_ _Proteobacteria; c\_\_Alph…  
6 TCCTGTTTGCTACCCACACTTTCGTGCCTGAGCGTCAGTTAC… k_ _Bacteria; p_ \_Bacteroidetes; c\_\_Ignav…

There isn't a third column data (confidence/consensus) because to the original taxonomy file was exported out of R by a third party service and then I imported the taxonomy file into Qiime2 to create .qza format used here. Below is the script we used. Could this error be circumvented with some creative R script using the current format? If the third column is the problem, is there a way to disregard the empty third column or would be have to create a bogus third column to use this script as is? Or is the issue with the first or second column?

Thanks,  
Christina

metadata\<-readr::read\_tsv("Modified-Macaque-skinmicrobiome-metadata-LB-July2020-R.tsv")  
SVs\<-read\_qza("asv\_feature-table\_2013\_2015TS\_75.qza")$data  
results\<-read\_qza("ALDEx2\_TS\_75animals/differentials\_75TS.qza")$data  
taxonomy\<-read\_qza("taxonomy\_for\_qiime.qza")$data  
tree\<-read\_qza("rooted-tree\_17May2020.qza")$data  
#Find significantly different taxa (less than .01 p-value) and volcano plot  
results %\>%  
left\_join(taxonomy) %\>%  
mutate(Significant=if\_else(we.eBH\<0.01, TRUE, FALSE)) %\>%  
mutate(Taxon=as.character(Taxon)) %\>%  
mutate(Taxon=gsub("[[kpco]\_\_\*;]", "", Taxon)) %\>%  
mutate(TaxonToPrint=if\_else(we.eBH\<0.01, Taxon, "")) %\>% #only provide a label to signifcant results  
ggplot(aes(x=diff.btw, y=-log10(we.ep), color=Significant, label=TaxonToPrint)) +  
geom\_text\_repel(size=3, nudge\_y=0.1) +  
geom\_point(alpha=0.6, shape=16) +  
theme\_q2r() +  
xlab("log2(fold change); Differences Between") +  
ylab("-log10(P-value)") +  
theme(legend.position="none") +  
scale\_color\_manual(values=c("black","red"))  
ggsave("volcano\_75TS\_0.01\_shorter\_taxa\_d.pdf", height=9, width=9, device="pdf")

---

<div class="post-metadata">

### Author: ![jbisanz](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jbisanz/32/1720_2.png) [@jbisanz](https://forum.qiime2.org/u/jbisanz)
#### Post date: [August 13, 2020, 9:57pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/29 "2020-08-13T21:57:30Z")

</div>

Hi Christina,

Easiest fix would be to just add a dummy column with something like:

```auto
taxonomy<-read_qza(“taxonomy_for_qiime.qza”)$data %>% mutate(Confidence=1)

```

---

<div class="post-metadata">

### Author: ![Zach\_Burcham](https://forum.qiime2.org/user_avatar/forum.qiime2.org/zach_burcham/32/18784_2.png) [@Zach\_Burcham](https://forum.qiime2.org/u/Zach_Burcham)
#### Post date: [August 31, 2020, 6:00pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/30 "2020-08-31T18:00:49Z")

</div>

Thanks @jbisanz , a quick question: in taxa\_barplot function the example command given is:

```auto
taxa_barplot(taxasums, metadata, "body-site")

```

is there an easy way to sort the order of the samples by another metadata column? For example if we have a variable of time and wanted to show the samples faceted by body-site and ordered by increasing time within the facets?

---

<div class="post-metadata">

### Author: ![jbisanz](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jbisanz/32/1720_2.png) [@jbisanz](https://forum.qiime2.org/u/jbisanz)
#### Post date: [August 31, 2020, 6:23pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/31 "2020-08-31T18:23:32Z")

</div>

If you sort your table by time and then convert sample ID to be a factor with that sorted order it should print out as you are looking for!

---

<div class="post-metadata">

### Author: ![LiiBotero](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/l/e68b1a/32.png) [@LiiBotero](https://forum.qiime2.org/u/LiiBotero)
#### Post date: [October 21, 2020, 6:19am UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/32 "2020-10-21T06:19:33Z")

</div>

Hi! right now i'm using this Package(qiime2R) and following one of your tutorials, but the function taxa\_barplot it's not available? does any other function that i can use for build up my taxonomy bar plot?  
Thank you!!!

---

<div class="post-metadata">

### Author: ![sbslee](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sbslee/32/9039_2.png) [@sbslee](https://forum.qiime2.org/u/sbslee)
#### Post date: [October 22, 2020, 12:18pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/33 "2020-10-22T12:18:54Z")

</div>

Hello @LiiBotero,

Welcome to the QIIME 2 forum! If you don't mind a Python solution, you can take a look at the `taxa_abundance_bar_plot ` [method](https://github.com/sbslee/dokdo/wiki/Dokdo-API#taxa_abundance_bar_plot) I wrote.

---

<div class="post-metadata">

### Author: ![Javad32](https://forum.qiime2.org/user_avatar/forum.qiime2.org/javad32/32/8799_2.png) [@Javad32](https://forum.qiime2.org/u/Javad32)
#### Post date: [October 22, 2020, 3:51pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/34 "2020-10-22T15:51:49Z")

</div>

> [@Tutorial: Integrating QIIME2 and R for data visualization and analysis using qiime2R](https://forum.qiime2.org/t/tutorial-integrating-qiime2-and-r-for-data-visualization-and-analysis-using-qiime2r/4121/1):
>
> ```auto
> taxonomy<-parse_taxonomy(taxonomy$data)
> head(taxonomy)
> 
> ```

Thank you so much for such a useful Tutorial. I was able to generate all the graphs, but I am more interested in having A graph base on Family level (group the family base on their names), not feature ID. Is there a way to do that?

 ![1](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/d/d56d861c6ad14503b72cd3ea3a5481a1c68b578d.jpeg)

---

<div class="post-metadata">

### Author: ![Javad32](https://forum.qiime2.org/user_avatar/forum.qiime2.org/javad32/32/8799_2.png) [@Javad32](https://forum.qiime2.org/u/Javad32)
#### Post date: [October 22, 2020, 4:37pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/35 "2020-10-22T16:37:22Z")

</div>

Is it also possible to get a picture like this (please see figure 4 end of this page) ([BatMP/Figure4\_Scatterplots.ipynb at master · hollylutz/BatMP · GitHub](https://github.com/hollylutz/BatMP/blob/master/Figure4_Scatterplots.ipynb)) with QiimeR?

---

<div class="post-metadata">

### Author: ![jbisanz](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jbisanz/32/1720_2.png) [@jbisanz](https://forum.qiime2.org/u/jbisanz)
#### Post date: [October 26, 2020, 2:59am UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/36 "2020-10-26T02:59:23Z")

</div>

Yes, just use the `summarize_taxa()` command first and pass the Family-summarized abundance table to the heatmap function.

---

<div class="post-metadata">

### Author: ![jbisanz](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jbisanz/32/1720_2.png) [@jbisanz](https://forum.qiime2.org/u/jbisanz)
#### Post date: [October 26, 2020, 3:01am UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/37 "2020-10-26T03:01:53Z")

</div>

It should be relatively straight forward to reproduce the plot using ggplot2 with data imported using qiime2R.

---

<div class="post-metadata">

### Author: ![Jack](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@Jack](https://forum.qiime2.org/u/Jack)
#### Post date: [November 17, 2020, 7:43pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/38 "2020-11-17T19:43:54Z")

</div>

Hello,

I have gotten to the stage where I have a heat map!! But, it has no colour on it? I presume I have done something wrong in the code at some point?

---

<div class="post-metadata">

### Author: ![jbisanz](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jbisanz/32/1720_2.png) [@jbisanz](https://forum.qiime2.org/u/jbisanz)
#### Post date: [November 17, 2020, 8:41pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/39 "2020-11-17T20:41:00Z")

</div>

No colour eh? Could you maybe post what you get and the code as you wrote it? I imagine it could be scaling issue or somehow NAs are getting introduced.

---

<div class="post-metadata">

### Author: ![Jack](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/j/cc9497/32.png) [@Jack](https://forum.qiime2.org/u/Jack)
#### Post date: [November 17, 2020, 10:38pm UTC](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818/40 "2020-11-17T22:38:37Z")

</div>

![image](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/6/6308a8bdd211b7748f979b5752383c202c683d2b.png)  
Hello, I have attached an image of the code.

[Previous page](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818.md?page=1)

[Next page](https://forum.qiime2.org/t/general-discussion-of-qiime2r-tutorial/17818.md?page=3)
