I have a matrix containing biological pathways (rows) and corresponding genes (columns). If a gene is present in a pathway the cell contains 1, otherwise 0. See example below:
mat=matrix(c(0,0,1,0,1,1,1,1,1), nrow = 3, ncol = 3)
row.names(mat) = c("pathwayX", "pathwayY", "pathwayZ")
colnames(mat) = c("Gene1", "Gene2", "Gene3")
| Gene1 | Gene2 | Gene3 | |
|---|---|---|---|
| pathwayX | 0 | 0 | 1 |
| pathwayY | 0 | 1 | 1 |
| pathwayZ | 1 | 1 | 1 |
What I need is a character vector for each pathway with constituting genes, holded in a list (e. g named gene_sets). In this example this would be:
> gene_sets
$pathwayX
"Gene3"
$pathwayY
"Gene2" "Gene3"
$pathwayZ
"Gene1" "Gene2" "Gene3"
Additionally, I need character vectors describing the pathway name, holded in a list (e. g. named description). In this example this would be:
> description
$pathwayX
"pathwayX"
$pathwayY
"pathwayY"
$pathwayZ
"pathwayZ"
Background: The vector lists are needed for the package pathfindR with costum input (https://github.com/egeulgen/pathfindR/wiki/Analysis-Using-Custom-Gene-Sets).