Learn R Programming

rbiom (version 3.1.0)

biom_relativize: Relativize Counts to Proportions

Description

This function normalizes the data by dividing each observation by the total library size of its sample. The resulting values represent the proportion (0 to 1) of the sample composed of that specific feature.

This is a common transformation for microbiome data, as it accounts for differences in sequencing depth across samples, allowing for comparison of community composition.

Usage

biom_relativize(biom, clone = TRUE)

Value

An rbiom object.

Arguments

biom

An rbiom object, or any value accepted by as_rbiom().

clone

Create a copy of biom before modifying. If FALSE, biom is modified in place as a side-effect. See speed ups for use cases. Default: TRUE

Details

Convert absolute counts to relative abundances (proportions) where each sample sums to 1.

See Also

Other transformations: biom_inflate(), biom_rescale(), modify_metadata, rarefy(), slice_metadata, subset(), with()

Examples

Run this code
    library(rbiom)
    
    biom <- hmp50[1:5]
    
    # Raw counts sum to different library sizes
    sample_sums(biom)
    
    # Relativized counts sum to 1
    biom_rel <- biom_relativize(biom)
    sample_sums(biom_rel)

Run the code above in your browser using DataLab