trim_prevalence: Trimming samples or features whose prevalence is less than...

View source: R/process_trim_prevalence.R

trim_prevalenceR Documentation

Trimming samples or features whose prevalence is less than threshold

Description

trim samples or features in profile by Prevalence, which means the samples or features will be discarded if they could not pass the cutoff.

Usage

trim_prevalence(
    object,
    level = c(NULL, "Kingdom", "Phylum", "Class",
           "Order", "Family", "Genus",
           "Species", "Strain", "unique"),
    cutoff = 0.1,
    group = NULL,
    trim = c("none",
      "both",
      "feature", "feature_group",
      "sample"),
    at_least_one = FALSE)

Arguments

object

(Required). a matrix, otu_table, phyloseq::phyloseq or SummarizedExperiment

level

(Optional). character. taxonomic level to summarize, default the top level rank of the ps. taxonomic level(Kingdom, Phylum, Class, Order, Family, Genus, Species, Strains; default: NULL).

cutoff

(Optional). Numeric. the Prevalence threshold (default: 0.1).

group

(Optional). character. filtering features or samples by group (default: NULL).

trim

(Optional). Character. trimming to apply, the options include:

  • "none", return the original data without any actions.

  • "both", prevalence of features and samples more than cutoff.

  • "feature", prevalence of features more than cutoff.

  • "feature_group", prevalence of features more than cutoff by groups.

  • "sample", prevalence of samples more than cutoff.

at_least_one

(Optional). Logical. prevalence of at least one group meets cutoff (FALSE means all groups meet cutoff, default: FALSE).

Value

A trimed object whose prevalence of features or samples more than cutoff.

Author(s)

Created by Hua Zou (11/30/2021 Shenzhen China)

Examples


# phyloseq object
data("Zeybel_2022_gut")
trim_prevalence(
  Zeybel_2022_gut,
  level = "Phylum",
  cutoff = 0.1,
  trim = "feature")

# SummarizedExperiment object
data("Zeybel_2022_protein")
trim_prevalence(
  Zeybel_2022_protein,
  level = NULL,
  cutoff = 0.1,
  trim = "feature")



HuaZou/MicrobiomeAnalysis documentation built on May 13, 2024, 11:10 a.m.