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/
586 stars 186 forks source link

Removing phy_tree from phyloseq object #1672

Open Marcelara opened 1 year ago

Marcelara commented 1 year ago

Hello! I would like to remove the phylogenetic tree from two of my phyloseq objects in order to merge them later on. If I try to do it now I get the Error in FUN(X[[i]], ...) : one tree has a different number of tips error.

I've tried phy_tree(ps) <- NA but I get Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘phy_tree<-’ for signature ‘"phyloseq", "logical"’

So far I've looked everywhere but I haven't found how to remove one item from a phyloseq object (i.e. if you want to remove the OTU table for instance or in my case now the phylogenetic tree).

Many thanks in advance!

gmteunisse commented 1 year ago

You can set the phy_tree slot of the phyloseq object to null:

require("phyloseq")
data("GlobalPatterns")
GlobalPatterns@phy_tree <- NULL

Alternatively, you can create a new object from your existing object without the tree:

ps_no_tree <- phyloseq(otu_table(GlobalPatterns), tax_table(GlobalPatterns), sample_data(GlobalPatterns))