Biostar Beta. Not for public use.
How to plot proportions of syn/nonsynonymous alleles across the chromosome?
0
Entering edit mode
5.1 years ago
Ripeapple • 40
United States

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 • 1.3k views
ADD COMMENTlink
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 REPLYlink
1
Entering edit mode

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

ADD REPLYlink
1
Entering edit mode
4.8 years ago
David W 4.7k
New Zealand

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 COMMENTlink
0
Entering edit mode

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

ADD REPLYlink

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.3