[R] qplot: plotting precipitation data
Rui Barradas
ruipbarradas at sapo.pt
Sun Sep 16 14:13:47 CEST 2012
Hello,
Relative to the op's "request" for rectangls, I'm not understanding them.
In your plot using geom_bar, the levels of as.factor(start) are sorted
ascending. If both
> as.factor(mydata$start)
[1] 5291000 10988025 11767950 11840900 12267450 12276675
Levels: 5291000 10988025 11767950 11840900 12267450 12276675
> as.factor(mydata$end)
[1] 5291926 10988526 11768676 11841851 12268076 12277051
Levels: 5291926 10988526 11768676 11841851 12268076 12277051
also are, why isn't geom_rect ploting them by that order?
p2 <- ggplot(mydata, aes(x = as.factor(start), y = peak))
p2 + geom_rect(aes(xmin = as.factor(start), xmax = as.factor(end), ymin
= 0, ymax = peak))
The level 5291926 is place last. Shouldn't it be expected to plot as first?
Rui Barradas
Em 16-09-2012 00:20, John Kane escreveu:
> Thanks for the data. It makes things much easier.
>
> Do you want a bar chart (i.e. geom = bar in qplot or geom_bar in ggplot)? That sounds like what you mean when you speak of rectangles.
>
> If so try this ggplot) command -- I almost never use qplot() so I am not quite sure how to specify it there.
>
> p <- ggplot(mydata , aes(as.factor(start), peak )) + geom_bar(stat= "identity", )
> p
>
>
> John Kane
> Kingston ON Canada
>
>
>> -----Original Message-----
>> From: hnorpois at googlemail.com
>> Sent: Sat, 15 Sep 2012 18:39:54 +0200
>> To: r-help at r-project.org
>> Subject: [R] qplot: plotting precipitation data
>>
>> Dear list,
>>
>> I wish to plot chromatin precipitation data: I would like to have a
>> rectangles (x:end-start, y:peak) but I do not have an idea how to define
>> x
>> (in terms of qplot syntax) and to choose the correct geom.
>> mydata is a subset of a larger file.
>>
>>> mydata
>> chrom start end peak
>> 1 chr11 5291000 5291926 8
>> 2 chr11 10988025 10988526 7
>> 3 chr11 11767950 11768676 8
>> 4 chr11 11840900 11841851 8
>> 5 chr11 12267450 12268076 12
>> 6 chr11 12276675 12277051 7
>>> dput(mydata)
>> structure(list(chrom = structure(c(3L, 3L, 3L, 3L, 3L, 3L), .Label =
>> c("chr1",
>> "chr10", "chr11", "chr12", "chr13", "chr14", "chr15", "chr16",
>> "chr17", "chr18", "chr19", "chr2", "chr3", "chr4", "chr5", "chr6",
>> "chr7", "chr8", "chr9", "chrX"), class = "factor"), start = c(5291000L,
>> 10988025L, 11767950L, 11840900L, 12267450L, 12276675L), end = c(5291926L,
>> 10988526L, 11768676L, 11841851L, 12268076L, 12277051L), peak = c(8L,
>> 7L, 8L, 8L, 12L, 7L)), .Names = c("chrom", "start", "end", "peak"
>> ), row.names = c(NA, -6L), class = "data.frame")
>> Thanks for some instructions.
>>
>> Hermann Norpois
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> ____________________________________________________________
> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list