Plot minor allele frequency distribution in R?
0
2
Entering edit mode
8.5 years ago
dam4l ▴ 200

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 • 9.0k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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)
ADD REPLY

Login before adding your answer.

Traffic: 1522 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6