Calculation of founder allele frequency at the chromosome level

17 views
Skip to first unread message

Saikat Bandyopadhyay

unread,
Aug 5, 2024, 11:48:38 AM8/5/24
to R/qtl2 discussion
I am trying to compute the global frequency of the founder haplotypes from a cross object. Essentially I need the percentage of the founder haplotypes across the chromosomes. I think `calc_raw_founder_maf` function will serve the purpose, but I could not figure out how to do this for each chromosome.

Alternatively, I think, the `calc_geno_freq(by = "marker")` can also be used.

I am just wondering what is the best approach.


Karl Broman

unread,
Aug 5, 2024, 12:19:27 PM8/5/24
to R/qtl2 discussion
calc_raw_founder_maf calculates the minor allele frequency using the raw SNP genotypes in the founders, so that's not what you want.

calc_geno_freq(by="marker") would be the thing. It can give you founder haplotype frequencies at each marker, as a big matrix (markers as rows and founders as columns).
You'd want to then split that by chromosome and take column averages.

Or you could loop over chromosomes and call calc_geno_freq() for each chromosome.

Here's an example:

# load example data
file <- "https://raw.githubusercontent.com/rqtl/qtl2data/main/DOex/DOex.zip"
DOex <- read_cross2(file)

# calculate genotype probabilities
pr <- calc_genoprob(DOex)

# convert to allele dosages
apr <- genoprob_to_alleleprob(pr)

# object to take output
founder_freq <- matrix(nrow=n_chr(DOex), ncol=length(DOex$alleles))
dimnames(founder_freq) <- list(chrnames(DOex), DOex$alleles)

# loop over chromosomes: subset allele dosages, calculate allale frequencies, and then take column means
for(chr in chrnames(DOex)) {
    apr_sub <- apr[,chr]
    afreq <-  calc_geno_freq(apr_sub, by="marker")
    founder_freq[chr,] <- colMeans( afreq )
}

karl

Saikat Bandyopadhyay

unread,
Aug 5, 2024, 12:45:33 PM8/5/24
to R/qtl2 discussion
Thank you, Dr Broman,

I appreciate the prompt response.
This is very helpful. This is exactly what I wanted.

Best,
Saikat

Dan Gatti

unread,
Aug 6, 2024, 8:52:25 AM8/6/24
to rqtl2...@googlegroups.com

I think that you can use the genoprobs from calc_genoprob() for this. You’d sum the frequencies across all chromosomes (perhaps with lapply or a loop) and then divide by the number of markers. You might have to think more carefully about the X chromosome. But that should work for the autosomes.

--
You received this message because you are subscribed to the Google Groups "R/qtl2 discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rqtl2-disc+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rqtl2-disc/5fdc23f7-c23b-4487-94ea-291505e56482n%40googlegroups.com.

---

The information in this email, including attachments, may be confidential and is intended solely for the addressee(s). If you believe you received this email by mistake, please notify the sender by return email as soon as possible.
Reply all
Reply to author
Forward
0 new messages