# Q2-perc-norm - ImportError: cannot import name ‘PercentileNormalized’

**URL:** https://forum.qiime2.org/t/q2-perc-norm-importerror-cannot-import-name-percentilenormalized/7191
**Category:** Library Support
**Created:** [November 1, 2018, 4:03pm UTC](https://forum.qiime2.org/t/q2-perc-norm-importerror-cannot-import-name-percentilenormalized/7191 "2018-11-01T16:03:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Hind\_Sbihi](https://forum.qiime2.org/user_avatar/forum.qiime2.org/hind_sbihi/32/3123_2.png) [@Hind\_Sbihi](https://forum.qiime2.org/u/Hind_Sbihi)
#### Post date: [November 1, 2018, 4:03pm UTC](https://forum.qiime2.org/t/q2-perc-norm-importerror-cannot-import-name-percentilenormalized/7191/1 "2018-11-01T16:03:54Z")

</div>

Hi @cduvallet  
Thank you so much for making this plug-in available.  
I would like to use it to correct for major batch effect we have in our data (apparent in PCoA plots and stat. sig when running ADONIS).  
After making the appropriate columns in the metadata ("#SampleID", "DiseaseState", "batch"), I imported the OTU table from phyloseq in biom format into Qiime2. I converted into qza file.  
The problem: I run the following code  
qiime perc-norm percentile-normalize --i-table ps\_r\_otu.qza --metadata-file child\_metadata\_perc\_r.txt --m-metadata-column DiseaseState --o-perc-norm-table ps\_r\_otu.percentile\_qiime.qza  
The error message:  
ImportError: cannot import name 'PercentileNormalized'

I am not sure what this message means or how to fix the issue. Your help would be greatly appreciated!

Hind

---

<div class="post-metadata">

### Author: ![cduvallet](https://forum.qiime2.org/user_avatar/forum.qiime2.org/cduvallet/32/1082_2.png) [@cduvallet](https://forum.qiime2.org/u/cduvallet)
#### Post date: [November 1, 2018, 4:29pm UTC](https://forum.qiime2.org/t/q2-perc-norm-importerror-cannot-import-name-percentilenormalized/7191/2 "2018-11-01T16:29:09Z")

</div>

Hi Hind,

Glad to hear you're using the plugin! What version of QIIME 2 are you using? You need to update to the latest version, since I moved the `PercentileNormalized` declaration to the `q2-types` plugin (in older versions of QIIME 2, it was contained within the `q2-perc-norm` plugin directly). Let me know if that fixes your problem!

---

<div class="post-metadata">

### Author: ![Hind\_Sbihi](https://forum.qiime2.org/user_avatar/forum.qiime2.org/hind_sbihi/32/3123_2.png) [@Hind\_Sbihi](https://forum.qiime2.org/u/Hind_Sbihi)
#### Post date: [November 1, 2018, 7:17pm UTC](https://forum.qiime2.org/t/q2-perc-norm-importerror-cannot-import-name-percentilenormalized/7191/3 "2018-11-01T19:17:02Z")

</div>

Hi @cduvallet

That was exactly the issue 🙂  
I am now using Qiime2-2018.8 and your plugin (almost) works...😔  
I hope you can help with this new bug. Here are my steps:

## Make appropriate columns in metadata file for percentile normalization

MetadataOct2018$batch \<- paste("batch",MetadataOct2018$batch, sep="" )  
MetadataOct2018$DiseaseState\<- ifelse(MetadataOct2018$A5Y==0, "control", "case")  
colnames(MetadataOct2018)[1]\<- paste("#", colnames(MetadataOct2018)[1], sep="")

## Ater creating the phyloseq object, Keep only cases and controls and extra OTU table

ps\<-subset\_samples(ps, A5Y!="NA")

### Note: Percentile Normalization is typically done on a rarefied object

ps\_r = rarefy\_even\_depth(ps, sample.size = 5000, replace = FALSE, verbose = TRUE, rngseed = 711)  
ps\_r.otu\<- as(otu\_table(ps\_r), "matrix")  
write.table(ps\_r.otu, "ps\_r\_otu.txt", sep="\t", col.names=NA)

### Extract the metadata for percentile normalization

Child\_metadata\_perc\_r\<-data.frame(sample\_data(ps\_r))  
write.table(Child\_metadata\_perc\_r, "child\_metadata\_perc\_r.txt", sep="\t")

## So everything is aligned

dim(ps\_r\_otu)

> 1428 5  
> dim(child\_metadata\_perc\_r)  
> 386 1428

## Using biom script, convert OTU object into biom format and import in Qiime2

$ biom convert -i ps\_r\_otu.txt -o ps\_r\_otu.biom --table-type="OTU table" --to-hdf5

$ qiime tools import --input-path ps\_r\_otu.biom --type 'FeatureTable[RelativeFrequency]' --source-format BIOMV210Format --output-path ps\_r\_otu.qza

## Run percentile normalization

$ qiime perc-norm percentile-normalize --i table ps\_r\_otu.qza --m-metadata-file childmeta.txt --m metadata-column DiseaseState --o-perc-norm-table ps\_r\_otu.percentile\_qiime.qza

## Here I get the following error message

Plugin error from perc-norm:

The following IDs are not present in the metadata: '"7104722413"', '"7104723114"', '"7104723314"', [..]

I cut the rest for brevity , it was the list of all samples

Any help at this point would be great!  
Many thanks Claire!!

---

<div class="post-metadata">

### Author: ![cduvallet](https://forum.qiime2.org/user_avatar/forum.qiime2.org/cduvallet/32/1082_2.png) [@cduvallet](https://forum.qiime2.org/u/cduvallet)
#### Post date: [November 1, 2018, 7:57pm UTC](https://forum.qiime2.org/t/q2-perc-norm-importerror-cannot-import-name-percentilenormalized/7191/4 "2018-11-01T19:57:45Z")

</div>

> [@Q2-perc-norm community plugin](https://forum.qiime2.org/t/q2-perc-norm-community-plugin/3922/5):
>
> The following IDs are not present in the metadata: ‘“7104722413”’, ‘“7104723114”’, ‘“7104723314”’, […]

This error means that you have sample IDs in the OTU table which are not in the metadata. You should double-check that the sample IDs in the biom file (or, if biom format confuses you like it does me, the column labels in the .txt OTU table) are found in the #SampleID column in the metadata file.

> [@Q2-perc-norm community plugin](https://forum.qiime2.org/t/q2-perc-norm-community-plugin/3922/5):
>
> write.table(ps\_r.otu, “ps\_r\_otu.txt”, sep="\t", col.names=NA)

It looks like this is probably the problem: I'm guessing that your `ps_r_otu.txt` file has no column names, given that you passed in `col.names=NA`.

---

<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: [November 28, 2018, 12:37am UTC](https://forum.qiime2.org/t/q2-perc-norm-importerror-cannot-import-name-percentilenormalized/7191/5 "2018-11-28T00:37:39Z")

</div>

An off-topic reply has been split into a new topic: [Q2-perc-norm - reduction in taxa](https://forum.qiime2.org/t/q2-perc-norm-reduction-in-taxa/7192)

Please keep replies on-topic in the future.
