protein_list_to_gene: Summarize named character vector based on supplied mappings

Description Usage Arguments Value Author(s) Examples

Description

Renames a character vector based on a supplied mapping between symbols in the form of a named character vector. If the renamed vector contains duplicated names, and collapse.char is present, the elements are split by the character and the longest split element is kept as long as the shorter split elements are subsets of it. If collapse.char is NULL, the elements have to be equivalent. If these requirements are not met an error is thrown. Only the names in common between the two vectors are considered.

Usage

1
protein.list.to.gene(prot.list, node.names, collapse.char=NULL)

Arguments

prot.list

A named character vector with names corresponding to the names of node.names.

node.names

A named character vector.

collapse.char

Either NULL or a character.

Value

A potentially shorter version of prot.list with new names.

Author(s)

Daniel Bottomly

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
set.seed(123)

vector.1 <- paste("value", 1:10, sep=".")
names(vector.1) <- paste("sample", 1:10, sep=".")

vector.2 <- as.character(sapply(1:5, function(x) rep(paste("new.sample", x, sep="."),2)))
names(vector.2) <-  paste("sample", 1:10, sep=".")

## Not run: protein.list.to.gene(prot.list=vector.1, node.names=vector.2)##Not run; should fail as there are different values in the elements of vector.1 to be summarized

vector.1 <- as.character(sapply(1:5, function(x) rep(paste("value", x, sep="."),2)))
names(vector.1) <- paste("sample", 1:10, sep=".")

protein.list.to.gene(prot.list=vector.1, node.names=vector.2)

vector.1[1:2] <- paste(paste("value", 1:3, sep="."), collapse=",")

protein.list.to.gene(prot.list=vector.1, node.names=vector.2, collapse.char=",")

vector.1[2] <- "value.1"
protein.list.to.gene(prot.list=vector.1, node.names=vector.2, collapse.char=",")

vector.1[2] <- paste(paste("value", 4:6, sep="."), collapse=",")
## Not run: protein.list.to.gene(prot.list=vector.1, node.names=vector.2, collapse.char=",")##should fail as the elements are the same length but not the same

vector.1[2] <- "value.4"
## Not run: protein.list.to.gene(prot.list=vector.1, node.names=vector.2, collapse.char=",")##the value for vector.1 is not a subset of vector.2

dbottomly/HitWalker documentation built on May 15, 2019, 1:22 a.m.