list2imSigned: convert list to signeddirectional incidence matrix

list2imSignedR Documentation

convert list to signeddirectional incidence matrix

Description

convert list to directional incidence matrix

Usage

list2imSigned(x, emptyValue = NA, verbose = FALSE, ...)

Arguments

x

list of named vectors, where the names are used to identify each element, and become rownames in the output incidence matrix. The vector values become values in the incidence matrix.

verbose

logical indicating whether to print verbose output.

...

additional arguments are passed to list2im().

Details

This function extends list2im() in that it stores the value associated with each element in the list. As such, the input format is a named vector, where the names of the vector are the items, and the numeric values are the values to be stored in the incidence matrix.

A common scenario is to generate a vector of genes, with values c(-1, 0, 1) indicating the direction of gene expression changes, named by the gene symbol. Each vector in the list represents one statistical test. Here, list2imSigned() will convert this list into a directional matrix representing the gene changes across the comparisons.

Note that this function currently does not combine multiple values, instead only the last occurring value is stored in the resulting matrix. This decision is partly due to efficiency, and partly because there are multiple possible methods to combine multiple values. For example, taking the mean(x) for a given gene, which has a value 1 and -1 would result in 0 and might suggest the gene is not a statistical hit. Instead, when multiple values are anticipated per named vector entry, use functions in a package like data.table or dplyr to apply a function to combine values.

Value

numeric matrix with rownames defined by vector names from each vector in the input list. The colnames are defined by names of the input list if they exist. list. Values in the matrix are values from each vector.

See Also

Other jam list functions: colors_from_list(), im2list_dep(), im2list(), imSigned2list_dep(), imSigned2list(), list2concordance(), list2im()

Examples

L1 <- list(A=c("C","A","B","A"),
   D=c("D","E","F","D"),
   A123=c(1:8,3,5),
   T=LETTERS[7:9]);
L1;

# Convert each vector to a signed vector
set.seed(123);
L2 <- lapply(L1, function(i){
   i <- unique(i);
   jamba::nameVector(sample(c(-1,1), size=length(i), replace=TRUE), i);
});
L2;

# Convert to signed incidence matrix
list2imSigned(L2);


jmw86069/jamenrich documentation built on Nov. 6, 2024, 7:07 p.m.