sample_id_filter: Filter Samples Ids from Taxmap Objects

Description Usage Arguments Details Value See Also Examples

View source: R/metacoder.R

Description

This function provides a flexible way to filter unwanted samples from the "otu_abundance" and "sample_data" observations of a MicrobiomeR formatted object.

Usage

1
2
sample_id_filter(obj, .f_transform = NULL, .f_filter = NULL,
  .f_condition = NULL, validated = FALSE, ...)

Arguments

obj

A Taxmap object.

.f_transform

A function used for transforming the data. Default: NULL

.f_filter

A function used for summarising the data like 'sum' or 'mean'. Default: NULL

.f_condition

A function that takes the summarised data and applied a condition like x > 10000. Default: NULL

validated

This parameter provides a way to override validation steps. Use carefully. Default: FALSE

...

An optional list of parameters to use in the .f_filter function specified

Details

Get the samples to keep by using purr and the user supplied transform and filter + condition formulas. The purr package allows the use of anonymous functions as described in the link below:

https://jennybc.github.io/purrr-tutorial/ls03_map-function-syntax.html#anonymous_function,_formula

Value

Returns a Taxmap object with samples that pass the filters.

See Also

validate_MicrobiomeR_format, transformer

get_dataset

select_all, select, filter

map, keep

Other Basic Metacoder Filters: otu_id_filter, taxon_id_filter

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Not run: 
if(interactive()){
# Use the sample_id_filter early on in your analysis
library(MicrobiomeR)
library(metacoder)
library(taxa)
# Convert Phyloseq object to Taxmap object
metacoder_obj <- as_MicrobiomeR_format(obj = phyloseq_silva_2, format = "raw_format")

# Remove Archaea from the Taxmap object
metacoder_obj <- filter_taxa(
  obj = metacoder_obj,
  taxon_names == "Archaea",
  subtaxa = TRUE,
  invert = TRUE)

# Ambiguous Annotation Filter - Remove taxonomies with ambiguous names
metacoder_obj <- filter_ambiguous_taxa(metacoder_obj, subtaxa = TRUE)

# Low Sample Filter - Remove the low samples
metacoder_obj <- sample_id_filter(obj          = metacoder_obj,
                               .f_filter    = ~sum(.),
                               .f_condition = ~.>= 20, validated = TRUE)
 }

## End(Not run)

vallenderlab/MicrobiomeR documentation built on Aug. 30, 2019, 11:24 p.m.