View source: R/phyloseq_otu_occurrence.R
phyloseq_otu_occurrence | R Documentation |
Estimate species occurrence (within groups of samples)
phyloseq_otu_occurrence(
physeq,
variable = NULL,
taxa_frequency = "percentage",
drop_zeroes = FALSE,
justdf = FALSE,
long = FALSE
)
physeq |
A phyloseq-class object |
variable |
Character string defining a variable name of the sample groups (this variable should be present in |
taxa_frequency |
Logical; if TRUE (default), relative frequency of species occurence within a sample group will be returned; if FALSE, number of samples within each sample group will be returned for each taxa |
drop_zeroes |
Logical; if TRUE, taxa with total zero abundance will be removed |
justdf |
Logical; if TRUE, return only a data frame with taxa occurrences; if FALSE (default), modified phyloseq object will be returned |
long |
Logical; if TRUE, data frame with taxa occurrences will be returned in long format (with a single column defining the sample group); if FALSE (default), species occurrences will be returned in a wide format (sample groups as columns) |
A phyloseq-class object (if justdf = FALSE) or a data frame (justdf = TRUE).
# Load data
data("GlobalPatterns")
## Return phyloseq-object with sample groups instead of samples
# With absolute counts (e.g., number of samples with the species)
gpa <- phyloseq_otu_occurrence(GlobalPatterns, variable = "SampleType", taxa_frequency = F)
gpa
head( otu_table(gpa) )
# With relative frequency of species occurence within a sample group
gpr <- phyloseq_otu_occurrence(GlobalPatterns, variable = "SampleType", taxa_frequency = T)
gpr
head( otu_table(gpr) )
## Return just a data frame with taxa occurrences
# In wide format (sample groups as columns)
gpw <- phyloseq_otu_occurrence(GlobalPatterns, variable = "SampleType", taxa_frequency = T, drop_zeroes = F, justdf = T, long = F)
head(gpw)
# In long format (with a single column with sample type)
gpl <- phyloseq_otu_occurrence(GlobalPatterns, variable = "SampleType", taxa_frequency = T, drop_zeroes = F, justdf = T, long = T)
head(gpl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.