I'm using the CATALYST package to analyze CYTOF data.
One of the commands requires a table in the format of a binary matrix.
I made the table in a .csv document and read it into R, which returned a dataframe-
#DEBARCODING
#read in the debarcoding sample key
key <- read.csv('10.9.20.5choose1.barcode_key_tube1.csv', check.names = FALSE)
key
The output was a data.frame that looked like
89 104 106 108 110
1 B6_CD451 1 0 0 0 0
2 Balb_CD451 0 1 0 0 0
3 STING_B6 0 0 1 0 0
4 STING_Balb 0 0 0 1 0
5 A960F 0 0 0 0 1
How do I convert this into a binary matrix/table that looks exactly the same.
I tried as.matrix
#The debarcoding scheme should be a binary table with sample IDs as row and numeric barcode masses as column names:
as.matrix(key)
and my output was
> as.matrix(key)
89 104 106 108 110
[1,] "B6_CD451" "1" "0" "0" "0" "0"
[2,] "Balb_CD451" "0" "1" "0" "0" "0"
[3,] "STING_B6" "0" "0" "1" "0" "0"
[4,] "STING_Balb" "0" "0" "0" "1" "0"
[5,] "A960F" "0" "0" "0" "0" "1"
every row was covered in quotation marks.
#DEBARCODING
> #read in the debarcoding sample key
> key <- read.csv('10.9.20.5choose1.barcode_key_tube1.csv', check.names = FALSE)
> key
89 104 106 108 110
1 B6_CD451 1 0 0 0 0
2 Balb_CD451 0 1 0 0 0
3 STING_B6 0 0 1 0 0
4 STING_Balb 0 0 0 1 0
5 A960F 0 0 0 0 1
> dput(key)
structure(list(c("B6_CD451", "Balb_CD451", "STING_B6", "STING_Balb",
"A960F"), `89` = c(1L, 0L, 0L, 0L, 0L), `104` = c(0L, 1L, 0L,
0L, 0L), `106` = c(0L, 0L, 1L, 0L, 0L), `108` = c(0L, 0L, 0L,
1L, 0L), `110` = c(0L, 0L, 0L, 0L, 1L)), class = "data.frame", row.names = c(NA,
-5L))