Learn R Programming

GeneScoreR (version 0.2.0)

geomean: Calculate Geometric Means from Count Tables

Description

This function computes the geometric mean for each sample in the given count table. Users can choose how to handle missing values.

Usage

geomean(count_table, na.action = c("omit", "fail"))

Value

A data frame with the geometric means per sample and the sample IDs.

Arguments

count_table

A data frame of gene count data (genes as rows, samples as columns). All columns must be numeric.

na.action

Character: how to handle NAs. Options are

  • "omit" (default): ignore NAs and compute the geometric mean with remaining values

  • "fail": return NA for the sample if any NA is present

Examples

Run this code
count_table <- data.frame(
  sample1 = c(1, 10, 100),
  sample2 = c(2, 20, 200),
  sample3 = c(3, 30, NA)
)
rownames(count_table) <- c("gene1", "gene2", "gene3")

geomean(count_table)

geomean(count_table, na.action = "fail")

Run the code above in your browser using DataLab