Takes a q_matrix
object, which is a matrix, and returns a tidied tibble.
Usage
# S3 method for class 'q_matrix'
tidy(x, data, ...)
Arguments
- x
A Q matrix object (as returned by
q_matrix
).- data
An associated tibble (e.g. a
gen_tibble
), with the individuals in the same order as the data used to generate the Q matrix- ...
not currently used
Value
A tidied tibble containing columns:
row
ID of the original observation (i.e. rowname from original data).
Q
Integer indicating a Q component.
value
The proportion for that particular Q value.
Examples
example_gt <- example_gt("gen_tbl")
# Create a gt_admix object
admix_obj <- example_gt %>% gt_snmf(k = 1:3, project = "force")
# Extract a Q matrix
q_mat_k3 <- get_q_matrix(admix_obj, k = 3, run = 1)
tidy(q_mat_k3, data = example_gt)
#> # A tibble: 21 × 3
#> id q percentage
#> <chr> <chr> <dbl>
#> 1 a .Q1 0.000100
#> 2 a .Q2 1.00
#> 3 a .Q3 0.000100
#> 4 b .Q1 0.000100
#> 5 b .Q2 1.00
#> 6 b .Q3 0.000100
#> 7 c .Q1 0.000100
#> 8 c .Q2 0.000100
#> 9 c .Q3 1.00
#> 10 d .Q1 0.000100
#> # ℹ 11 more rows