Question: Plot minor allele frequency distribution in R?
1
gravatar for dam4l
3.0 years ago by
dam4l140
dam4l140 wrote:

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.

R gwas maf • 4.0k views
ADD COMMENTlink written 3.0 years ago by dam4l140

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 REPLYlink written 3.0 years ago by leekaiinthesky170

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 REPLYlink written 3.0 years ago by dam4l140
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 712 users visited in the last hour