Learn R Programming

tidypopgen (version 0.4.3)

tidy.q_matrix: Tidy a Q matrix

Description

Takes a q_matrix object, which is a matrix, and returns a tidied tibble.

Usage

# S3 method for q_matrix
tidy(x, data, ...)

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.

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

Examples

Run this code
# run the example only if we have the package installed
if (requireNamespace("LEA", quietly = TRUE)) {
  example_gt <- load_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)
}

Run the code above in your browser using DataLab