Probably needs to be added. Might make sense as a stat, e.g., +
stat_mirror_strand().

Thanks for the suggestion,
Michael


On Sat, Dec 7, 2013 at 2:09 PM, Thomas Girke <thomas.girke@ucr.edu> wrote:

> Dear ggbio experts,
>
> ggbio is an excellent package. Thanks for providing it. - One thing I
> have not been able to figure out though is how to create mirrored
> (~lacking better term here~) representations of coverage data. It is not
> hard to achieve this with ggplot2, but a ggbio solution would be much
> more elegant and efficient. Here is an example illustrating what I mean:
>
> ## Plotting coverage with ggbio using faceting for +/-
> library(GenomicRanges); library(ggbio)
> set.seed(1); N <- 100;
> gr <- GRanges(seqnames = sample(c("chr1", "chr2", "chr3"), size = N,
>         replace = TRUE), IRanges(start = sample(1:300, size = N, replace =
>         TRUE), width = sample(70:75, size = N,replace = TRUE)), strand =
>         sample(c("+", "-"), size = N, replace = TRUE), value = rnorm(N,
> 10, 3),
>         score = rnorm(N, 100, 30), sample = sample(c("Normal", "Tumor"),
> size =
>         N, replace = TRUE), pair = sample(letters, size = N, replace =
> TRUE))
> autoplot(gr, aes(color = strand, fill = strand), facets = strand ~
> seqnames, stat = "coverage")
>
> ## What if I want the following mirrored layout for +/- instead:
> pos <- sapply(coverage(gr[strand(gr)=="+"]), as.numeric)
> pos <- data.frame(Chr=rep(names(pos), sapply(pos, length)),
> Strand=rep("+", length(unlist(pos))), Position=1:length(unlist(pos)),
> Coverage=as.numeric(unlist(pos)))
> neg <- sapply(coverage(gr[strand(gr)=="-"]), as.numeric)
> neg <- data.frame(Chr=rep(names(neg), sapply(neg, length)),
> Strand=rep("-", length(unlist(neg))), Position=1:length(unlist(neg)),
> Coverage=-as.numeric(unlist(neg)))
> covdf <- rbind(pos, neg)
> p <- ggplot(covdf, aes(Position, Coverage, fill=Strand)) +
>             geom_bar(stat="identity", position="identity") +
> facet_wrap(~Chr)
> p
>
> Is there a way achieving the latter with ggbio directly? Most biologists
> would
> prefer this mirrored over the faceted +/- representation. If this is
> already
> possible then perhaps this could be added to the ggbio documentation?
>
> Thanks,
>
> Thomas
>
>
> > sessionInfo()
> R version 3.0.2 (2013-09-25)
> Platform: x86_64-apple-darwin10.8.0 (64-bit)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] parallel  stats     graphics  grDevices utils     datasets  methods
> [8] base
>
> other attached packages:
> [1] ggbio_1.10.10        ggplot2_0.9.3.1      GenomicRanges_1.14.3
> [4] XVector_0.2.0        IRanges_1.20.6       BiocGenerics_0.8.0
>
> loaded via a namespace (and not attached):
>  [1] AnnotationDbi_1.24.0    Biobase_2.22.0          biomaRt_2.18.0
>  [4] Biostrings_2.30.1       biovizBase_1.10.5       bitops_1.0-6
>  [7] BSgenome_1.30.0         cluster_1.14.4          colorspace_1.2-4
> [10] DBI_0.2-7               dichromat_2.0-0         digest_0.6.3
> [13] Formula_1.1-1           GenomicFeatures_1.14.2  grid_3.0.2
> [16] gridExtra_0.9.1         gtable_0.1.2            Hmisc_3.13-0
> [19] labeling_0.2            lattice_0.20-24         MASS_7.3-29
> [22] munsell_0.4.2           plyr_1.8                proto_0.3-10
> [25] RColorBrewer_1.0-5      RCurl_1.95-4.1          reshape2_1.2.2
> [28] Rsamtools_1.14.2        RSQLite_0.11.4          rtracklayer_1.22.0
> [31] scales_0.2.3            splines_3.0.2           stats4_3.0.2
> [34] stringr_0.6.2           survival_2.37-4         tools_3.0.2
> [37] VariantAnnotation_1.8.7 XML_3.95-0.2            zlibbioc_1.8.0
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>

	[[alternative HTML version deleted]]

