This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Plot minor allele frequency distribution in R?

Hi,

I used PLINK (--freq) to get the minor allele frequencies for all SNPs in my GWAS. I would like to plot the distribution of MAFs in R with MAF on the x-axis and proportion of SNPs with a given MAF on the y-axis. I was able to plot the distribution of MAFs using the basic hist() function:

hist(maf_file$MAF, freq = TRUE)

This plots MAF on the x-axis and the frequency of each MAF on the y-axis. As I stated above, I want to be able to plot proportion rather than frequency on the y-axis.

Any input would be greatly appreciated.

gwas maf r

Have you tried freq = FALSE?

freq: logical; if TRUE, the histogram graphic is a representation of frequencies, the counts component of the result; if FALSE, probability densities, component density, are plotted (so that the histogram has a total area of one). Defaults to TRUE if and only if breaks are equidistant (and probability is not specified).

https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/hist.html

I managed to do it using freq = FALSE with some additional information:

h = hist(maf_file$MAF)
h$density = h$counts/sum(h$counts)
plot(h, freq = FALSE)

0 answers

No answers yet.

Log in to answer this question.