Skip to contents

Uses marker_candidates_v1 ranking.

Usage

extract_profile_v1(x)

Arguments

x

Data (potentially already filtered), including columns chr and pos

Examples

vcf <- vcf_example_data_v1 |> rename(chr = CHROM, pos = POS)
#> Error in rename(vcf_example_data_v1, chr = CHROM, pos = POS): could not find function "rename"
prof <- extract_profile(vcf)
#> Error in dplyr::inner_join(x, marker_cand, by = c("chr", "pos")): object 'vcf' not found
head(prof)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'head': object 'prof' not found
nrow(prof)
#> Error in nrow(prof): object 'prof' not found
table(prof$rank)
#> Error in table(prof$rank): object 'prof' not found

# Also using allele frequencies from `marker_candidates_v1`
prof_extra_info <- prof |> inner_join(marker_candidates_v1 |> 
  select(chr, pos, ref, alt, AF_afr, AF_eas, AF_nfe), by = c("chr", "pos"))
#> Error in inner_join(prof, select(marker_candidates_v1, chr, pos, ref,     alt, AF_afr, AF_eas, AF_nfe), by = c("chr", "pos")): could not find function "inner_join"
head(prof_extra_info)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'head': object 'prof_extra_info' not found

subset(prof_extra_info, ref != REF)
#> Error in subset(prof_extra_info, ref != REF): object 'prof_extra_info' not found
subset(prof_extra_info, alt != ALT)
#> Error in subset(prof_extra_info, alt != ALT): object 'prof_extra_info' not found
subset(prof_extra_info, alt != ALT & ALT != "?")
#> Error in subset(prof_extra_info, alt != ALT & ALT != "?"): object 'prof_extra_info' not found

X <- to012(prof_extra_info$GT)
#> Error in to012(prof_extra_info$GT): object 'prof_extra_info' not found
X
#> Error in eval(expr, envir, enclos): object 'X' not found
genoprob <- allele_probs_to_geno_probs(prof_extra_info$AF_nfe)
#> Error in lapply(x, function(q) {    c(q^2, 2 * q * (1 - q), (1 - q)^2)}): object 'prof_extra_info' not found

LRs <- calc_LRs(xs = X, xd = X, w = 0.01, p = genoprob)
#> Error in calc_LRs(xs = X, xd = X, w = 0.01, p = genoprob): could not find function "calc_LRs"
WoE <- sum(log10(LRs))
#> Error in eval(expr, envir, enclos): object 'LRs' not found
WoE
#> Error in eval(expr, envir, enclos): object 'WoE' not found

ws <- 10^(-(6:1))
LRs_ws <- sapply(ws, \(w) sum(log10(calc_LRs(xs = X, xd = X, w = w, p = genoprob))))
#> Error in calc_LRs(xs = X, xd = X, w = w, p = genoprob): could not find function "calc_LRs"
cbind(ws, LRs_ws)
#> Error in eval(quote(list(...)), env): object 'LRs_ws' not found

# Assume two errors
head(X)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'head': object 'X' not found
Xd <- X
#> Error in eval(expr, envir, enclos): object 'X' not found
Xd[1] <- 1
#> Error in Xd[1] <- 1: object 'Xd' not found
Xd[2] <- 1
#> Error in Xd[2] <- 1: object 'Xd' not found
LRs_ws_Xd <- sapply(ws, \(w) sum(log10(calc_LRs(xs = X, xd = Xd, w = w, p = genoprob))))
#> Error in calc_LRs(xs = X, xd = Xd, w = w, p = genoprob): could not find function "calc_LRs"
cbind(ws, LRs_ws_Xd)
#> Error in eval(quote(list(...)), env): object 'LRs_ws_Xd' not found

# Assume two more errors
head(X)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'head': object 'X' not found
Xd[3] <- 0
#> Error in Xd[3] <- 0: object 'Xd' not found
Xd[4] <- 0
#> Error in Xd[4] <- 0: object 'Xd' not found
LRs_ws_Xd4 <- sapply(ws, \(w) sum(log10(calc_LRs(xs = X, xd = Xd, w = w, p = genoprob))))
#> Error in calc_LRs(xs = X, xd = Xd, w = w, p = genoprob): could not find function "calc_LRs"
cbind(ws, LRs_ws_Xd4)
#> Error in eval(quote(list(...)), env): object 'LRs_ws_Xd4' not found