tyring to subset phyloseq object - error sample data must have no zero dimensions
Closed this issue · 4 comments
Hi, I imported my files from qiime2 into a phyloseq object:
physeq1<-qza_to_phyloseq(
features="DADA2-table4.qza",
tree="rooted-tree4.qza",
"NCBI_LSURef_97_10_uniq_5-8-300_classification_blast.qza",
metadata = "metadata-1.txt")
physeq1
phyloseq-class experiment-level object
otu_table() OTU Table: [ 1842 taxa and 192 samples ]
sample_data() Sample Data: [ 192 samples by 5 sample variables ]
tax_table() Taxonomy Table: [ 1842 taxa by 7 taxonomic ranks ]
phy_tree() Phylogenetic Tree: [ 1842 tips and 1840 internal nodes ]
I then tried to split my data into samples from Namibia and from South Africa and used the following code:
Namdata <- subset_samples(physeq1, country %in% c("Namibia"))
and got the following error message:
Error in validObject(.Object) :
invalid class “sample_data” object: Sample Data must have non-zero dimensions.
Please help
Anya
Believe it or not, I do not use phyloseq directly very often but I can try to help. I think the error is suggesting after applying the filter there are no samples. If you look at sample_data(physeq1)
is there a column called country and does it have "Namibia" for at least one sample?
Hi @jbisanz,
Thanks for your reply. I had a look at the sample data and it looks like Namibia is there. My table looks a bit weird tho, it is a .txt file so not sure if this is the problem, it worked fine in qiime2 though.
head(sample_data(physeq1))
Sample Data: [6 samples by 5 sample variables]:
snail.id country site morph.id.genus
020221-AT-1 N.1A.Lym1.5 Namibia 1A Lymnaea/Radix
020221-AT-10 N.1D.Bul1.3 Namibia 1D Bulinus
020221-AT-100 SA.1Db.Biom.un South Africa 1D Biomphlaria
020221-AT-101 SA.1D.Bmp.1 South Africa 1D Biomphlaria
020221-AT-102 SA.5A.Bmp.1 South Africa 5A Biomphlaria
020221-AT-103 SA.5A.Bmp.2 South Africa 5A Biomphlaria
shedding
020221-AT-1 no
020221-AT-10 no
020221-AT-100 no
020221-AT-101 no
020221-AT-102 no
020221-AT-103 no
Thanks, Anya
Hi @jbisanz I had a look at my data and noticed that "Namibia" was actually "Namibia ". Adding the space into my code fixed the problem!
Best
Anya
Great to hear!