format_ids: Format/convert the sample gene IDs

View source: R/data_formatting.R

format_idsR Documentation

Format/convert the sample gene IDs

Description

This function converts the gene IDs from given input and aggregates IDs if necessary for unique ID output (e.g multiple transcripts to a gene).

Usage

format_ids(X, IDs, from = 1, to = 2, aggr.fun = mean, verbose = TRUE)

Arguments

X

the sample gene expression matrix with genes as rows and individuals as columns

IDs

A dataframe holding current IDs for X and target IDs

from, to

defaults to 1 and 2 ; columns of IDs holding current and target IDs of X respectively

aggr.fun

the function used for aggregate

verbose

if TRUE (default), prints number of genes kept and aggregated

Value

a gene expression matrix, with new IDs as rownames

Examples

# make dummy data
ids <- data.frame(id.a = paste0('a', 1:10), id.b = paste0('b', 1:10), stringsAsFactors = FALSE)
X <- matrix(rnorm(50), ncol = 5)
rownames(X) <- ids$id.a


# format ids
format_ids(X, ids, from = "id.a", to = "id.b")


LBMC/wormAge documentation built on April 6, 2023, 3:52 a.m.