Learn R Programming

Nematode (version 0.2.0)

rel_abundance: Calculate the Relative Abundance of Nematodes

Description

This function calculates the relative abundance of nematodes for each sample. The relative abundance is defined as the proportion of each nematode's count to the total count of all nematodes in a sample.

Usage

rel_abundance(data, ...)

# S3 method for data.frame rel_abundance(data, ...)

# S3 method for matrix rel_abundance(data, ...)

# S3 method for default rel_abundance(data, ...)

Value

A data.frame or matrix (matching the input type) containing the relative abundance of each nematode in each sample.

Arguments

data

data.frame or matrix. The nematode abundance table where rows represent samples and columns represent nematodes. Each element indicates the count of a specific nematode in the corresponding sample.

...

Additional arguments (currently unused).

Examples

Run this code
# Example with a data frame
df <- data.frame(
  Species1 = c(10, NA, 15),
  Species2 = c(5, 10, NA),
  Species3 = c(8, 12, 10),
  row.names = c("A", "B", "C")
)
rel_abundance(df)

# Example with a matrix
mat <- matrix(c(10, NA, 15, 5, 10, NA, 8, 12, 10), nrow = 3, byrow = TRUE)
colnames(mat) <- c("Species1", "Species2", "Species3")
row.names(mat) <- c("A", "B", "C")
rel_abundance(mat)

Run the code above in your browser using DataLab