While tibbles are great for interactive data science, matrices are more practical for the algebra used by WExT. Therefore, these two functions mutationmatrix_to_tibble() and tibble_to_mutationmatrix(), make switching between the two formats much easier.

matrix_to_tibble(dat, columns_name = "sample_id", rows_name = "gene")

Arguments

dat

a matrix object with column and row names

columns_name

title for the data in the column names (default "sample_id")

rows_name

title for the data in the row names (default "gene")

Examples

set.seed(0) mat <- matrix(sample(c(0,1), 12, replace = TRUE), nrow = 3) colnames(mat) <- LETTERS[1:4] rownames(mat) <- letters[1:3] matrix_to_tibble(mat)
#> # A tibble: 12 x 3 #> gene columns_name mutated #> <chr> <chr> <dbl> #> 1 a A 1 #> 2 b A 0 #> 3 c A 0 #> 4 a B 1 #> 5 b B 1 #> 6 c B 0 #> 7 a C 1 #> 8 b C 1 #> 9 c C 1 #> 10 a D 1 #> 11 b D 0 #> 12 c D 0