joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
582 stars 187 forks source link

tyring to subset phyloseq object - error sample data must have no zero dimensions #1467

Open Avtober opened 3 years ago

Avtober commented 3 years ago

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.

When I look at the head of my Sample data it looks like this: 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

Not sure if it is in the right format as it is a .txt file but it was working in qiime2

Thanks Anya

spholmes commented 3 years ago

Hi, I am not sure whether this is due to the new default to put stringsAsFactors to FALSE (see the essay https://developer.r-project.org/Blog/public/2020/02/16/stringsasfactors/index.html ) and that these are no longer levels of a categorical variable. I am not sure about this and would need you to check your data to see if the variable country is a factor, this could be worth a try.

let us know, Susan

On Thu, May 20, 2021 at 1:32 AM Avtober @.***> wrote:

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.

When I look at the head of my Sample data it looks like this: 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

Not sure if it is in the right format as it is a .txt file but it was working in qiime2

Thanks Anya

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joey711/phyloseq/issues/1467, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJFZPORAGGMZT3YT4JSF7LTOTCLTANCNFSM45GML7PQ .

-- Susan Holmes

Avtober commented 3 years ago

Hi Susan, Thanks for your reply, 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

spholmes commented 3 years ago

Oh dear, I would never have found that error! Well done.

On Thu, May 20, 2021, 11:32 Avtober @.***> wrote:

Hi Susan, Thanks for your reply, 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

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joey711/phyloseq/issues/1467#issuecomment-844964099, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJFZPNABIQBLCF6UH42TRTTOTQKDANCNFSM45GML7PQ .