str_to_gene: convert string vector to list/vector of genes

Description Usage Arguments Value Examples

View source: R/utils.R

Description

convert string vector to list/vector of genes

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
str_to_gene(
  x,
  tolower = F,
  capitalize = F,
  toupper = F,
  to_clipboard = F,
  as_list = F,
  print = F,
  REGEX = "[^a-zA-Z0-9\\-\\.]"
)

Arguments

x

a string with multiple gene symbols seperated by non-numeric/letter/hyphen (Depends on REGEX parameter below); numeric/letter/hyphen charactor will be treated as parts of gene symbols. A vector of strings is also supported, in which case you can choose to return list. If missing of x, the string will be read from system clipboard automately (I like it!).

tolower

1st prior.

capitalize

2nd prior. Use both tolower and capitalize to get mouse gene symbol.

toupper

3nd prior

to_clipboard

If 'False' return a charactor vector of gene symbols (default), if 'TRUE' return value to clipboard

as_list

If 'FALSE' (default) return value is a vector. If 'TRUE' reutrn value is structured in list, this is useful when 'to_clipboard=T' so that you can paste the return (symbols with quoted) to python.

print

print the return or not. (default: FALSE)

REGEX

a regular expression used for identifying chars of gene symbols. Default setting should work in most cases. You can also customize it yourself.

Value

A charactor vector of gene symbols or A list of vectors (with names if x named) in case of as_list=T

Examples

1
2
3
4
5
# you can copy some text from anywhere (a research article for example) and then str_to_gene() will help to parse it into gene vector.
str_to_gene()
# custom string of genes
str_to_gene(x = "Runx1, Gata4 Gata1;, Dll4, Nkx2-5, NOTAGENE") # note: the function does not check validity of gene symbols
str_to_gene(x = c(Hematopoietic ="Runx1 Gata4 GATA1", Ery = "Gypa Gype Ptprc", Endothelial = "Pecam1 Cdh5"), as_list = T)

zzwch/convgene documentation built on July 11, 2021, 9:41 a.m.