Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtracting taxa from a phyloseq object #1755

Open
GinaGizzi opened this issue May 30, 2024 · 0 comments
Open

Subtracting taxa from a phyloseq object #1755

GinaGizzi opened this issue May 30, 2024 · 0 comments

Comments

@GinaGizzi
Copy link

Hello everyone, I am new to R.
I have two subset phyloseq objects (ps.V and ps.P) composed as follows.

arth_ps
phyloseq-class experiment-level object
otu_table() OTU Table: [ 2312 taxa and 25 samples ]
sample_data() Sample Data: [ 25 samples by 7 sample variables ]
tax_table() Taxonomy Table: [ 2312 taxa by 8 taxonomic ranks ]
phy_tree() Phylogenetic Tree: [ 2312 tips and 2311 internal nodes ]

arth_ps_glom <- tax_glom(arth_ps, "Species")
arth_ps_glom
phyloseq-class experiment-level object
otu_table() OTU Table: [ 834 taxa and 25 samples ]
sample_data() Sample Data: [ 25 samples by 7 sample variables ]
tax_table() Taxonomy Table: [ 834 taxa by 8 taxonomic ranks ]
phy_tree() Phylogenetic Tree: [ 834 tips and 833 internal nodes ]

ps.V <- subset_samples(arth_ps_glom, SampleType == "V")
ps.V<- prune_taxa(taxa_sums(ps.V) > 0, ps.V)
ps.V
phyloseq-class experiment-level object
otu_table() OTU Table: [ 532 taxa and 15 samples ]
sample_data() Sample Data: [ 15 samples by 7 sample variables ]
tax_table() Taxonomy Table: [ 532 taxa by 8 taxonomic ranks ]
phy_tree() Phylogenetic Tree: [ 532 tips and 531 internal nodes ]

ps.P <- subset_samples(arth_ps_glom, SampleType == "P")
ps.P<- prune_taxa(taxa_sums(ps.P) > 0, ps.P) sample
ps.P
phyloseq-class experiment-level object
otu_table() OTU Table: [ 341 taxa and 10 samples ]
sample_data() Sample Data: [ 10 samples by 7 sample variables ]
tax_table() Taxonomy Table: [ 341 taxa by 8 taxonomic ranks ]
phy_tree() Phylogenetic Tree: [ 341 tips and 340 internal nodes ]

I have already calculated which species are common between the 2 phyloseq objects:

asv_list <- intersect(taxa_names(ps.V), taxa_names(ps.P))
taxa_sub <- arth_ps_glom@tax_table[rownames(arth_ps_glom@tax_table) %in% asv_list, ]
length(taxa_names(taxa_sub))
[1] 198

I would now like to subtract the 198 species from the ps.V object (532-198=334) and the ps.P object (341-198=143).
I would like a list of species that I only find in the ps.V object (334 taxa) and the ps.P object (143 taxa).

Can you give me some ideas? Is it possible to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant