Learn R Programming

GeneScoreR (version 0.2.0)

zscore: Calculate Z-Scores from Count Tables

Description

This function computes a Z-score sum for each sample in the given "scored" count table, based on the means and SDs of the genes in the control table. Users can choose how to handle missing values.

Usage

zscore(scored_table, control_table, na.action = c("omit", "fail"))

Value

A data frame with the sum of Z-scores per sample and the sample IDs.

Arguments

scored_table

Data frame of samples to be scored (genes as rows, samples as columns). All columns must be numeric.

control_table

Data frame of control samples (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 calculate using available values

  • "fail": return NA if any value is missing

Examples

Run this code
scored_table <- data.frame(
  sample1 = c(1, 2, 3),
  sample2 = c(4, NA, 6),
  sample3 = c(7, 8, 9)
)
rownames(scored_table) <- c("gene1", "gene2", "gene3")

control_table <- data.frame(
  control1 = c(1, 1, 1),
  control2 = c(2, 2, 2),
  control3 = c(3, 3, 3)
)
rownames(control_table) <- c("gene1", "gene2", "gene3")

zscore(scored_table, control_table)

zscore(scored_table, control_table, na.action = "fail")

Run the code above in your browser using DataLab