subset sample in phyloseq
1
0
Entering edit mode
5.1 years ago
Bioinfonext ▴ 460

I do have three tissue and three treatment conditions in physeq object. My aim is to only want to use the soil sample and want to see the treatment effect on microbial abundance.

How should I remove other tissue and only retain the soil sample in phyloseq object.

sample details:

summary(sample_data(physeq)$Tissue)

Leaf   Root       Soil

And each tissue has given 3 treatment.

summary(sample_data(physeq)$Treatment)

T1     T2     T3

Thanks

R next-gen • 13k views
ADD COMMENT
2
Entering edit mode
5.1 years ago
Chris Fields ★ 2.2k

You should read the phyloseq documentation for this, there are a ton of examples for subsetting or pruning data. Also:

https://joey711.github.io/phyloseq/preprocess.html

More specifically, look up the online documentation in R for subset_samples, prune_samples, subset_taxa, and prune_taxa. I also recommend the F1000 paper which is a pretty great walkthrough for phyloseq.

ADD COMMENT
0
Entering edit mode

Thanks a lot, I tried below code but it is showing error, could please suggest how I can correct this mistake:

> physeq

phyloseq-class experiment-level object

otu_table()   OTU Table:         [ 67405 taxa and 162 samples ]

sample_data() Sample Data:       [ 162 samples by 5 sample variables ]

tax_table()   Taxonomy Table:    [ 67405 taxa by 7 taxonomic ranks ]

phy_tree()    Phylogenetic Tree: [ 67405 tips and 67229 internal nodes ]

> physeq_soil <- subset_samples(physeq, SampleType=="Soil")
Error in eval(e, x, parent.frame()) : object 'SampleType' not found
ADD REPLY
1
Entering edit mode

Thanks, I got it, if I replace SampleType with Tissue then its works:

physeq_soil <- subset_samples(physeq, Tissue=="Soil")

Thanks

ADD REPLY
0
Entering edit mode

Hello,

I subset my data (based on only one time point) in phyloseq and wanted to performed a PCoA only with this subset but I still have the all dataset that appear in my PCoA even if the unwanted samples are not any more labelled.

Global subset:

phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 1222 taxa and 40 samples ]
sample_data() Sample Data:       [ 40 samples by 10 sample variables ]
tax_table()   Taxonomy Table:    [ 1222 taxa by 7 taxonomic ranks ]
phy_tree()    Phylogenetic Tree: [ 1222 tips and 1219 internal nodes ]

After subsetting:

phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 1222 taxa and 20 samples ]
sample_data() Sample Data:       [ 20 samples by 10 sample variables ]
tax_table()   Taxonomy Table:    [ 1222 taxa by 7 taxonomic ranks ]
phy_tree()    Phylogenetic Tree: [ 1222 tips and 1219 internal nodes ]

Any idea? Thanks,

ADD REPLY
0
Entering edit mode

You only have subset samples not taxa, you need to remove taxa which have 0 counts in your all samples. look at the prune_taxa command.

ADD REPLY

Login before adding your answer.

Traffic: 1531 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6