# q2-gcn-norm: plugin for normalizing sequences by 16S rRNA gene copy number

**URL:** https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715
**Category:** Plugins
**Tags:** tutorial
**Created:** [December 3, 2019, 4:55pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715 "2019-12-03T16:55:33Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![jwchen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jwchen/32/3841_2.png) [@jwchen](https://forum.qiime2.org/u/jwchen)
#### Post date: [December 3, 2019, 4:55pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/1 "2019-12-03T16:55:33Z")

</div>

Thanks to the detailed [developer documentation](https://dev.qiime2.org/latest/), the plugin finally comes out 🥳  
If you find bugs or have suggestions, please make a post on this forum and on the [Github repository](https://github.com/Jiung-Wen/q2-gcn-norm/issues).

# q2-gcn-norm

QIIME 2 plugin for normalizing sequences by 16S rRNA gene copy number (GCN) based on rrnDB database

### Introduction:

This plugin normalizes sequences by 16S rRNA gene copy number (GCN) based on _rrn_DB database (version 5.6). The script matches the taxa of sequences with the `rrnDB-5.6_pantaxa_stats_NCBI.tsv` file, starting from the lowest rank. If a match is found, the mean of GCN for the taxon is assigned; if not, the script will try to match a higher rank until the highest rank is met. All the unassigned sequences are assumed to have one GCN.

Note that the **mean** column in the `rrnDB-5.6_pantaxa_stats_NCBI.tsv` is, according to the [_rrn_DB manual](https://rrndb.umms.med.umich.edu/help/), calculated from the means of the pan-taxa of immediate lower rank. Therefore, the mean of GCN might be different from the _rrn_db online search result. For example, the "mean" of GCN for bacteria is 2.02 in the downloading tsv file, whereas the mean of GCN for all the bacterial taxa is 5.0 if you search _rrn_DB online database.

### Install guide:

We assume you have a conda environment with the [QIIME 2 Core distribution](https://docs.qiime2.org/2019.10/install/) installed. First, activate the conda environment:

```auto
conda activate qiime2-2019.10

```

Next, install `q2-gcn-norm` with the following command:

```auto
conda install -c jiungwenchen q2-gcn-norm

```

### Running example:

We use artifacts from QIIME 2's "[Moving Pictures](https://docs.qiime2.org/2019.10/tutorials/moving-pictures/)" tutorial as test files. Use the following commands to download the files.

```auto
# DADA2 output artifact:
wget https://docs.qiime2.org/2019.10/data/tutorials/moving-pictures/table-dada2.qza

# Taxonomic analysis output artifact:
wget https://docs.qiime2.org/2019.10/data/tutorials/moving-pictures/taxonomy.qza

```

We can normalize the FeatureTable using the command below:

```auto
qiime gcn-norm copy-num-normalize \
  --i-table table-dada2.qza \
  --i-taxonomy taxonomy.qza \
  --o-gcn-norm-table table-normalized.qza

```

The output would be an artifact of type `FeatureTable[Frequency] % Properties('copy_number_normalized')`.

Note that the taxonomy format should be like Greengenes' `k __foo; p__ bar; c __... ` or SILVA's `D_0__ foo;D_1 __bar;D_2__...`. Other formats, e.g. `k __foo;p__ bar;c__...`(no space after semicolon) or `k__foo|p __bar|c__...`(use pipe as delimiter), are currently unsupported and will raise error.

Now you can perform analyses as you usually do in QIIME 2 with the GCN-normalized FeatureTable. For example, let's do the ANCOM analysis with the new FeatureTable and compare the result from this example with that from "Moving Pictures" tutorial.

```auto
# get the metadata from "Moving Pictures" tutorial
wget \
  -O "sample-metadata.tsv" \
  "https://data.qiime2.org/2019.10/tutorials/moving-pictures/sample_metadata.tsv"

# ANCOM analysis
qiime feature-table filter-samples \
  --i-table table-normalized.qza \
  --m-metadata-file sample-metadata.tsv \
  --p-where "[body-site]='gut'" \
  --o-filtered-table gut-table-normalized.qza
  
qiime taxa collapse \
  --i-table gut-table-normalized.qza \
  --i-taxonomy taxonomy.qza \
  --p-level 6 \
  --o-collapsed-table gut-table-l6-normalized.qza

qiime composition add-pseudocount \
  --i-table gut-table-l6-normalized.qza \
  --o-composition-table comp-gut-table-l6-normalized.qza

qiime composition ancom \
  --i-table comp-gut-table-l6-normalized.qza \
  --m-metadata-file sample-metadata.tsv \
  --m-metadata-column subject \
  --o-visualization l6-ancom-subject-normalized.qzv

```

**ANCOM output visualizations:**

- l6-ancom-subject.qzv (from official tutorial): [view](https://view.qiime2.org/visualization/?type=html&src=https%3A%2F%2Fdocs.qiime2.org%2F2019.10%2Fdata%2Ftutorials%2Fmoving-pictures%2Fl6-ancom-subject.qzv)  
Screenshot:  
 ![](https://imgur.com/UZwSquw.jpg)

- l6-ancom-subject\_normalized.qzv (from this example): [view](https://view.qiime2.org/visualization/?type=html&src=https://rawcdn.githack.com/Jiung-Wen/miscellaneous-/9dcb49b5a701e58b3b7d5538c0eff966b75bc320/16S_copy_num_normalize/l6-ancom-subject_normalized.qzv)  
Screenshot:  
 ![](https://imgur.com/R2y1tF5.jpg)

You may also want to compare the change in relative abundance using taxonomic bar plots:  
 ![](https://imgur.com/AkTMmWn.jpg)

Generally, the GCN normalization may not have a huge impact on your analysis results, but someone (e.g. reviewer or, in my case, supervisor) may ask you to do so. For more discussion about GCN normalization, check the [related topic](https://forum.qiime2.org/t/16s-copy-number-normalization/2575) in QIIME 2 forum.

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [December 3, 2019, 5:29pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/2 "2019-12-03T17:29:53Z")

</div>

Awesome! Please post this to the [Library](https://library.qiime2.org), that is the official place to share (and find) community plugins! 📚

---

<div class="post-metadata">

### Author: ![mpodar](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@mpodar](https://forum.qiime2.org/u/mpodar)
#### Post date: [December 7, 2019, 2:23pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/3 "2019-12-07T14:23:05Z")

</div>

Hello

This is a plugin that I was long hoping for, thank you! But there seems to be a problem with the installation, it appears it does not come with some reference files. This is the error that I get when tried to run it:

(qiime2-2019.10) $ qiime gcn-norm copy-num-normalize \

> --i-table table.qza \

> --i-taxonomy taxonomy.qza \

> --o-gcn-norm-table table-normalized.qza

**Plugin error from gcn-norm:**

**[Errno 2] File b'/Users/mpb/miniconda3/envs/qiime2-2019.10/lib/python3.6/site-packages/q2\_gcn\_norm/rrnDB-5.6\_pantaxa\_stats\_NCBI.tsv' does not exist: b'/Users/mpb/miniconda3/envs/qiime2-2019.10/lib/python3.6/site-packages/q2\_gcn\_norm/rrnDB-5.6\_pantaxa\_stats\_NCBI.tsv'**

These are the files in the q2\_gcn\_norm/ directory:  
$ ls  
**init**.py \_copy\_num\_normalize.py  
**pycache** plugin\_setup.py

I manually added the missing file from the github but then this is the error:

> --i-table table.qza \

> --i-taxonomy taxonomy.qza \

> --o-gcn-norm-table table-normalized.qza

**Plugin error from gcn-norm:**

**name 'df\_copy\_num' is not defined**

There seems to be a problem with the plugin?

Thank you!

Mircea

---

<div class="post-metadata">

### Author: ![jwchen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jwchen/32/3841_2.png) [@jwchen](https://forum.qiime2.org/u/jwchen)
#### Post date: [December 7, 2019, 3:54pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/4 "2019-12-07T15:54:11Z")

</div>

Hi @mpodar,

Thanks for reporting these problems! For the first one, I forgot to add the package data in the setup file and I have fixed it. And for the second one, it seems I accidentally deleted some codes and now I put it back. Can you re-install the plugin or copy the new `_copy_num_normalize.py` from my github and replace the previous one? Please let me know if it works.

Best,  
Jiung-Wen

---

<div class="post-metadata">

### Author: ![mpodar](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@mpodar](https://forum.qiime2.org/u/mpodar)
#### Post date: [December 7, 2019, 8:30pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/5 "2019-12-07T20:30:21Z")

</div>

hi Jiung-Wen

thanks for the quick response. I deleted and reinstalled though the  
conda install -c jiungwenchen q2-gcn-norm

The problem persists. I manually added the .tsv file and replaced the \_copy\_num\_normalize.py with the one from github as you sugegsted. Now again it says it cannot find the .tsv file even though its in the directory its looking at . I wish I was good at python to see where the problem is, but Im not 🙂

thanks  
Mircea

---

<div class="post-metadata">

### Author: ![jwchen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jwchen/32/3841_2.png) [@jwchen](https://forum.qiime2.org/u/jwchen)
#### Post date: [December 8, 2019, 3:32am UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/6 "2019-12-08T03:32:31Z")

</div>

Hi @mpodar ,

Sorry for the inconvenience. After inspecting the issue, I found that I failed to upload the new anaconda package last time 😬 I have uploaded the new one and now it should work through:

```auto
conda install -c jiungwenchen q2-gcn-norm

```

Alternatively, you can install from github repo. First, clone the repo:

```auto
git clone https://github.com/Jiung-Wen/q2-gcn-norm.git

```

then change to the main directory:

```auto
cd q2-gcn-norm/

```

and run the following command:

```auto
python setup.py install

```

I hope this solves the problem. Please let me know if it persists.

Best,  
Jiung-Wen

---

<div class="post-metadata">

### Author: ![mpodar](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@mpodar](https://forum.qiime2.org/u/mpodar)
#### Post date: [December 8, 2019, 2:12pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/7 "2019-12-08T14:12:51Z")

</div>

> [@jwchen](#):
>
> conda install -c jiungwenchen q2-gcn-norm

Perfect, now works like a charm, thank you ! 😊  
Best,  
Mircea

---

<div class="post-metadata">

### Author: ![przemekiljan](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/p/d9b06d/32.png) [@przemekiljan](https://forum.qiime2.org/u/przemekiljan)
#### Post date: [April 7, 2021, 2:28pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/8 "2021-04-07T14:28:48Z")

</div>

Hello,  
Great job with this tool but I worry that it may be slightly outdated considering newly gathered data. Is the reference file for this plug-in updated along with official _rrn_DB's data releases, or is there manual way for users to do it by themselves?

Kind regards,  
Przemek

---

<div class="post-metadata">

### Author: ![jwchen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jwchen/32/3841_2.png) [@jwchen](https://forum.qiime2.org/u/jwchen)
#### Post date: [April 7, 2021, 2:45pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/9 "2021-04-07T14:45:04Z")

</div>

Hi Przemek,  
Thank you for using the plug-in. It has recently been updated to the latest version (v5.7) in Anaconda and I am planing to update the github along with the citation in the near future (probably this week).  
[https://anaconda.org/jiungwenchen/q2-gcn-norm](https://anaconda.org/jiungwenchen/q2-gcn-norm)

[Edit] The github repo has been updated.

Best,  
Jiung-Wen

---

<div class="post-metadata">

### Author: ![przemekiljan](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/p/d9b06d/32.png) [@przemekiljan](https://forum.qiime2.org/u/przemekiljan)
#### Post date: [April 8, 2021, 11:12am UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/10 "2021-04-08T11:12:53Z")

</div>

Great! Thanks for quick response 🙂

---

<div class="post-metadata">

### Author: ![nickbenn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nickbenn/32/14897_2.png) [@nickbenn](https://forum.qiime2.org/u/nickbenn)
#### Post date: [October 11, 2023, 9:43pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/11 "2023-10-11T21:43:22Z")

</div>

Is it possible to update the plug-in for rrnDB latest version v5.8?

---

<div class="post-metadata">

### Author: ![cherman2](https://forum.qiime2.org/user_avatar/forum.qiime2.org/cherman2/32/17129_2.png) [@cherman2](https://forum.qiime2.org/u/cherman2)
#### Post date: [October 11, 2023, 11:09pm UTC](https://forum.qiime2.org/t/q2-gcn-norm-plugin-for-normalizing-sequences-by-16s-rrna-gene-copy-number/12715/12 "2023-10-11T23:09:32Z")

</div>

Hi @nickbenn,  
Id recommend creating an issue on their github for this: [Issues · Jiung-Wen/q2-gcn-norm · GitHub](https://github.com/Jiung-Wen/q2-gcn-norm/issues)
