have a list of files that contain specific genes, and I want to create a binary relation matrix in R that shows the presence of each gene in each file.
For example, here are my files aaa
, bbb
, ccc
, and ddd
and the genes associated to them.
aaa=c("HERC1")
bbb=c("MYO9A", "PKHD1L1", "PQLC2", "SLC7A2")
ccc=c("HERC1")
ddd=c("MACC1","PKHD1L1")
I need to generate another table that where, for each pair of genes, I assign the value 1 if both of them present in the specific file, and 0 other wise. Following the example that I gave earlier, this new table should look like the following one:
Does anybody know a quick way to obtain this new bigenic table in R? Thanks!
Assuming you can read the the files into a named list, here's one way using
tidyverse
-