Skip to contents

This function retrieves a single Q matrix from a gt_admix object based on the specified k value and run number.

Usage

get_q_matrix(x, ..., k, run)

Arguments

x

A gt_admix object containing multiple Q matrices

...

Not used

k

The k value of the desired Q matrix

run

The run number of the desired Q matrix

Value

A single Q matrix from the gt_admix object

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
get_q_matrix(admix_obj, k = 3, run = 1)
#>            .Q1       .Q2       .Q3
#> [1,] 9.999e-05 9.998e-01 9.999e-05
#> [2,] 9.998e-01 9.999e-05 9.999e-05
#> [3,] 9.998e-01 9.999e-05 9.999e-05
#> [4,] 9.999e-05 9.998e-01 9.999e-05
#> [5,] 9.999e-05 9.999e-05 9.998e-01
#> [6,] 9.999e-05 9.999e-05 9.998e-01
#> [7,] 9.998e-01 9.999e-05 9.999e-05
#> attr(,"class")
#> [1] "q_matrix" "q_matrix" "matrix"   "array"   
#> attr(,"id")
#> [1] "a" "b" "c" "d" "e" "f" "g"