list2im_value | R Documentation |
Optimized conversion of list to a value incidence matrix
list2im_value(
setlist,
empty = NULL,
do_sparse = FALSE,
force_sign = FALSE,
...
)
setlist |
|
empty |
default single value used for empty/missing entries,
the default |
do_sparse |
|
... |
additional arguments are ignored. |
coerce_sign |
|
This function converts a list of named vectors into
an incidence matrix with value for each entry
(row) present in each input list (column). This output
is called a "value incidence matrix" because the
value itself is included in the matrix as opposed to
a true incidence matrix that represents only TRUE
or FALSE
(1
or 0
) at each position.
The rownames of the output matrix represent items, encoded by the vector names. The colnames of the output matrix represent the list names.
The default value in the output matrix is 0
for
a numeric matrix, and ""
for a character matrix,
based on the input vector classes.
To override this behavior, use the argument empty
.
For example, it may be useful to encode missing entries
as NA
, which means "this entry was not observed", and
store true values of 0
to indicate "this entry was observed
and its value was 0
zero". In this case use empty=NA
.
This behavior can be useful with gene expression data, when a particular gene may not be observed in all data sets.
Matrix
object that contains signed direction encoded
as c(-1, 0, 1)
values.
Other venndir conversion:
counts2setlist()
,
im2list()
,
im_value2list()
,
list2im_opt()
,
overlaplist2setlist()
,
signed_counts2setlist()
setlist <- make_venn_test(100, 3, do_signed=TRUE)
imv <- list2im_value(setlist);
print(head(imv));
# convert back to list
im_value2list(imv);
# example showing empty=NA
setlist2 <- make_venn_test(20, 3, sizes=c(12, 14, 8), do_signed=TRUE)
setlist2 <- lapply(setlist2, function(i){
i[] <- sample(c(-1, 0, 1),
replace=TRUE,
size=length(i));
i
})
imv2 <- list2im_value(setlist2, empty=NA);
imv2;
# to convert back to list, define empty=NA so 0 is not considered as empty
im_value2list(imv2, empty=NA);
# make a simple character vector list
setlistv <- lapply(setlist, function(i){
j <- letters[i+3];
names(j) <- names(i);
j;
})
imv <- list2im_value(setlistv);
print(head(imv));
# convert back to list of character vectors
im_value2list(imv);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.