I have a long list of genes. I have added a toy example below.
output of dput(list1)
list(ENDOSS = structure(list(ENDOSS = c("CDKN1C", "SOX6", "TGFB2"
)), row.names = c(NA, -3L), class = "data.frame"), ENDOSSSD = structure(list(
ENDOSSSD = c("CDKN1C", "SOX6", "TGFB2")), row.names = c(NA,
-3L), class = "data.frame"), GASTRIN = structure(list(GASTRIN = c("IKBKB",
"KIT", "SERPINE1")), row.names = c(NA, -3L), class = "data.frame"),
METCC = structure(list(METCC = character(0)), row.names = character(0), class = "data.frame"))
The toy list looks as so
list1
ENDOSS
"CDKN1C", "SOX6", "TGFB2"
ENDOSSSD
"CDKN1C", "SOX6", "TGFB2"
GASTRIN
"IKBKB", "KIT", "SERPINE1"
METCC
I would like to transform this list into a count matrix. Based on the example, the output should look like this.
CDKN1C IKBKB KIT SERPINE1 SOX6 TGFB2
ENDOSS 1 0 0 0 1 1
ENDOSSSD 1 0 0 0 1 1
GASTRIN 0 1 1 1 0 0
METCC 0 0 0 0 0 0
Any help would be appreciated. Thanks.