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


(Hind Sbihi) #1

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


Q2-perc-norm community plugin
(Claire Duvallet) #2

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!


(Hind Sbihi) #3

Hi @cduvallet

That was exactly the issue :slight_smile:
I am now using Qiime2-2018.8 and your plugin (almost) works…:pensive:
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!!


(Claire Duvallet) #4

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.

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.


(Matthew Ryan Dillon) #5

An off-topic reply has been split into a new topic: Q2-perc-norm - reduction in taxa

Please keep replies on-topic in the future.