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/
567 stars 187 forks source link

Remove mitochondrial and chloroplastic taxons from my phyloseq object #1750

Open pailloufat-stack opened 1 month ago

pailloufat-stack commented 1 month ago

Hi,

I have my ps object :

phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 19747 taxa and 322 samples ]
sample_data() Sample Data:       [ 322 samples by 6 sample variables ]
tax_table()   Taxonomy Table:    [ 19747 taxa by 7 taxonomic ranks ]

I need to reduce this dataset, in order to infer a phylogeny later. What I did is to remove the chloroplastic and mitochondrials taxons from it (and the eukaryotic and unclassified taxons) :

ps %>%
  phyloseq::subset_taxa(Order != "Chloroplast") %>%
  phyloseq::subset_taxa(Family != "Mitochondria") %>%
  phyloseq::subset_taxa(Kingdom == "Bacteria") %>%
  phyloseq::subset_taxa(Phylum != "Unclassified ")

phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 14923 taxa and 322 samples ]
sample_data() Sample Data:       [ 322 samples by 6 sample variables ]
tax_table()   Taxonomy Table:    [ 14923 taxa by 7 taxonomic ranks ]

I would like to know what is the difference with this command and which one is the good one :

ps %>% 
 subset_taxa( Kingdom == "Bacteria" &   Family!= "Mitochondria" | is.na(Family) & Order!="Chloroplast" | is.na(Order) & Phylum != "Unclassified")

phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 18308 taxa and 322 samples ]
sample_data() Sample Data:       [ 322 samples by 6 sample variables ]
tax_table()   Taxonomy Table:    [ 18308 taxa by 7 taxonomic ranks ]

Thanks