R/get_true_freqs_1snp.R

Defines functions get_true_freqs_1snp

# Get true ancestry-specific allele frequencies

get_true_freqs_1snp <- function(alleles_1, ancestries_1){

    indices_anc_0 <- which(ancestries_1 == 0)
    anc0_freq <- sum(alleles_1[indices_anc_0]) / length(indices_anc_0)

    indices_anc_1 <- which(ancestries_1 == 1)
    anc1_freq <- sum(alleles_1[indices_anc_1]) / length(indices_anc_1)

    indices_anc_2 <- which(ancestries_1 == 2)
    anc2_freq <- sum(alleles_1[indices_anc_2]) / length(indices_anc_2)

    return(c(anc0_freq, anc1_freq, anc2_freq))
}

Try the ASAFE package in your browser

Any scripts or data that you put into this service are public.

ASAFE documentation built on Nov. 8, 2020, 10:59 p.m.