Split a chromosome name and location type string into its constituent parts in R

Easy to do with a regular expression and the strsplit function in R. The | operator means “or”. For example for “chr15:88120587-88121480″:

> unlist(strsplit("chr15:88120587-88121480", "chr|:|-"))[2:4]
[1] "15" "88120587" "88121480"

Leave a Reply