The main objective of this function is to complete the
phyloseq::subset_samples()
function by propose a more easy
(but more prone to error) way of subset_samples.
It replace the subsetting expression which used the name of the variable
in the sam_data by a boolean vector.
Warnings: you must verify the result of this function as the
boolean condition must match the order of samples in the sam_data
slot.
This function is robust when you use the sam_data slot of the phyloseq object used in physeq (see examples)
Arguments
- physeq
(required): a
phyloseq-class
object obtained using thephyloseq
package.- condition
A boolean vector to subset samples. Length must fit the number of samples
Examples
cond_samp <- grepl("A1", data_fungi@sam_data[["Sample_names"]])
subset_samples_pq(data_fungi, cond_samp)
#> phyloseq-class experiment-level object
#> otu_table() OTU Table: [ 1420 taxa and 9 samples ]
#> sample_data() Sample Data: [ 9 samples by 7 sample variables ]
#> tax_table() Taxonomy Table: [ 1420 taxa by 12 taxonomic ranks ]
#> refseq() DNAStringSet: [ 1420 reference sequences ]
subset_samples_pq(data_fungi, data_fungi@sam_data[["Height"]] == "Low")
#> phyloseq-class experiment-level object
#> otu_table() OTU Table: [ 1420 taxa and 45 samples ]
#> sample_data() Sample Data: [ 45 samples by 7 sample variables ]
#> tax_table() Taxonomy Table: [ 1420 taxa by 12 taxonomic ranks ]
#> refseq() DNAStringSet: [ 1420 reference sequences ]