How to plot proportions of syn/nonsynonymous alleles across the chromosome?
1
0
Entering edit mode
9.6 years ago
Ripeapple ▴ 40

Hi, All,

I want to plot the synonymous and non-synonymous allele frequency over chromosomes, like this plot attached, which the non-synonymous and synonymous SNPs add up to the whole space. https://dl.dropboxusercontent.com/u/88399787/F2.medium.gif

My data looks like this:

ID  Chr pos Type    Allelefrequency
SNP1    1   3245    SYN 0.12
SNP2    1   3569    SYN 0.13
SNP3    1   4503    SYN 0.03
SNP4    1   11590   NONSYN  0.22
SNP5    1   11983   NONSYN  0.14
SNP6    1   12030   NONSYN  0.33

Any input is appreciated

Thanks

Rplot • 2.8k views
ADD COMMENT
0
Entering edit mode

"Any input is appreciated," -- the same could be said by someone trying to answer this question :)
What data do you have for this plot, and what form is it in?

ADD REPLY
1
Entering edit mode

Sorry for the vague question, I've updated it, thanks

ADD REPLY
1
Entering edit mode
9.6 years ago
David W 4.9k

You can get something pretty similar using R and ggplot2.

First, let's fake up some data similar to yours:

df0 <- data.frame(
   pos = sort(sample(1:10000, 1000)),
   type = sample(c("Syn", "NonSyn"), 1000, prob=c(3/4, 1/4), replace=TRUE)
)

Now, use geom_bar() and percent_format() (from the cales library) to make the plot:

library(ggplot2)
library(scales)
p <- ggplot(df0, aes(pos, fill=type))
p + geom_bar(position="fill", binwidth=100) + scale_y_continuous(labels=percent_format())

You can change the binwidth argument to make the window size smaller or larger, and add colour=white if you want the windows to be distinct.

ADD COMMENT
0
Entering edit mode

Thank you so much, David, I finally nailed the plot,

ADD REPLY

Login before adding your answer.

Traffic: 2450 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