Hi Tengfei,
Great, thanks! Works like a charm.
Best wishes
Julian
On 26/03/14 17:46, Tengfei Yin wrote:
> Here is a workaround for your request, I need to implement an better
> option for plotGrandLinear function. I basically get current data
frame
> and compute border manually.
>
> #####
> p <- plotGrandLinear(gr.snp, aes(y = pvalue), color = c("#7fc97f",
> "#fdc086"))
> vline.df <- p at ggpplot$data
> vline.df <- do.call(rbind, by(vline.df, vline.df$seqnames,
function(dd){
> data.frame(start = min(dd$start),
> end = max(dd$end))
> }))
> ## compute gap
> gap <- (vline.df$start[-1] + vline.df$end[-nrow(vline.df)])/2
> p + geom_vline(xintercept = gap, alpha = 0.5, color = 'gray70') +
> theme(panel.grid = element_blank())
>
> #####
> Inline image 1
>
>
> On Wed, Mar 26, 2014 at 11:03 AM, Tengfei Yin
> <tengfei.yin at="" sbgenomics.com="" <mailto:tengfei.yin="" at="" sbgenomics.com="">> wrote:
>
> exactly, I realize the color maybe used for mapping, I am
working on
> a solution like this
>
> step 1. clear the panel grid first by using theme()
> step 2. add grid line manually, this is very tricky, because the
> data is transformed to not over integer limits, check out
> metadata(p at data)
> you will see some meta data come from
> biovizBase::transformToGenome() function, also space between
> chromosome added, case even get complicated when your original
data
> has or doesn't have seqlengths,
>
> I will get back to you on this asap this afternoon
>
> cheers
>
> Tengfei
>
>
> On Wed, Mar 26, 2014 at 10:50 AM, Julian Gehring
> <julian.gehring at="" embl.de="" <mailto:julian.gehring="" at="" embl.de="">>
wrote:
>
> Hi Tengfei,
>
> Separating by color works nicely, but becomes problematic
here
> because I
> want to encode another entity by color.
>
> Is it possible to add 'vlines' on top of the existing plot?
I have
> tried it with
>
> p + autoplot(x, aes(xintercept = start), geom = "vline",
coord
> = "genome")
>
> but without success.
>
> Best wishes
> Julian
>
>
> On 26/03/14 15:30, Tengfei Yin wrote:
> > first existing 'official' solution to separate group
easily is
> to use
> > 'color' parameters in "plotGrandLinear" function, you can
assign a
> > vector of color (2, or 3 or length of chromosome) and this
will be
> > cycled and assigned to each group
> >
> > plotGrandLinear(gr.snp, aes(y = pvalue), color =
c("#7fc97f",
> "#fdc086"))
> >
> > I forget to document this color parameters in
plotGrandLinear,
> I do have
> > them in the example of manual, but autoplot() doesn't
support this
> > special color assignment yet.
> >
> > Inline image 1
> > I need to work on a theme() solution if you still want to
put line
> > between chromosome.
> >
> > cheers
> >
> > Tengfei
> >
> >
> >
> > On Wed, Mar 26, 2014 at 10:15 AM, Tengfei Yin
> > <tengfei.yin at="" sbgenomics.com=""> <mailto:tengfei.yin at="" sbgenomics.com="">
> <mailto:tengfei.yin at="" sbgenomics.com=""> <mailto:tengfei.yin at="" sbgenomics.com="">>> wrote:
> >
> > oh wait, sorry, you are talking about plotGranlinear,
not
> layout
> > karyogram... I guess I need a coffee in the morning
first
> :) let me
> > check to see if there is any quick workaround.
> >
> > cheers
> >
> > Tengfei
> >
> >
> > On Wed, Mar 26, 2014 at 10:08 AM, Tengfei Yin
> > <tengfei.yin at="" sbgenomics.com=""> <mailto:tengfei.yin at="" sbgenomics.com="">
> <mailto:tengfei.yin at="" sbgenomics.com=""> <mailto:tengfei.yin at="" sbgenomics.com="">>> wrote:
> >
> > Hi Julian,
> >
> > yes, you could use ylim parameter in
layout_karyogram() to
> > control this and to layout different group at
> different height
> > layer by layer, because by default the chromosome
> height limits
> > are [0, 10], if you set ylim outside the region
like
> [10, 15],
> > it will plot them outside, an example to plot
> different group at
> > different height is shown below, I know it's just
a
> workaround,
> > I probably need to provide a simpler way
> >
> > ########
> > library(ggbio)
> > data(hg19IdeogramCyto, package = "biovizBase")
> > data(hg19Ideogram, package = "biovizBase")
> > library(GenomicRanges)
> > ## simul_snp
> > chrs <-
as.character(levels(seqnames(hg19IdeogramCyto)))
> > seqlths <- seqlengths(hg19Ideogram)[chrs]
> > set.seed(1)
> > nchr <- length(chrs)
> > nsnps <- 100
> > gr.snp <- GRanges(rep(chrs,each=nsnps),
> > IRanges(start =
> > do.call(c,
lapply(chrs,
> function(chr){
> > N <- seqlths[chr]
> > runif(nsnps,1,N)
> > })), width = 1),
> > SNP=sapply(1:(nchr*nsnps),
function(x)
> > paste("rs",x,sep='')),
> > pvalue =
-log10(runif(nchr*nsnps)),
> > group = sample(c("Normal",
"Tumor"),
> size =
> > nchr*nsnps,
> > replace = TRUE)
> > )
> > gr.snp
> > ##names(seqlths) <- gsub("chr", "",
names(seqlths))
> > seqlths
> > seqlengths(gr.snp) <-
seqlths[names(seqlengths(gr.snp))]
> > gr.snp.bac <- gr.snp
> > seqinfo(gr.snp)
> > gr.snp <- keepSeqlevels(gr.snp, c("chr1", "chr2",
> "chr3", "chr4"))
> >
> > ## above this line is just creating simulated data
> > ## suppose you have your snp data store in gr.snp
> > ## you have to split the group for now, sorry
> > grl.snp <- split(gr.snp, gr.snp$group)
> > grl.snp
> >
> > autoplot(seqinfo(grl.snp)) + layout_karyogram(data
=
> > grl.snp[[1]], color = "red", ylim = c(0, 10) ) +
> > layout_karyogram(data = grl.snp[[2]], color =
> "blue", ylim =
> > c(10, 20) )
> >
> > #########
> >
> > HTH
> >
> > Tengfei
> >
> >
> > On Wed, Mar 26, 2014 at 8:49 AM, Julian Gehring
> > <julian.gehring at="" embl.de=""> <mailto:julian.gehring at="" embl.de=""> <mailto:julian.gehring at="" embl.de=""> <mailto:julian.gehring at="" embl.de="">>> wrote:
> >
> > Hi,
> >
> > The 'plotGrandLinear' or the respective
'autoplot'
> function
> > of the
> > 'ggbio' package make it easy to visualize all
the
> > chromosomes of a
> > genomes together. For example:
> >
> > autoplot(gr.snp, coord = "genome", geom =
"point",
> aes(y =
> > pvalue),
> > space.skip = 0.01) ## taken from
> 'example(plotGrandLinear'
> >
> > produces a plot for all human chromosomes with
> vertical
> > lines in the
> > middle of each chromosome. Can one easily
adapt
> this, in
> > the way that
> > the vertical lines fall between the
chromosomes?
> This would
> > be helpful
> > for distinguishing/separating them.
> >
> > Best wishes
> > Julian
> >
> >
_______________________________________________
> > Bioconductor mailing list
> > Bioconductor at r-project.org
> <mailto:bioconductor at="" r-project.org="">
> <mailto:bioconductor at="" r-project.org=""> <mailto:bioconductor at="" r-project.org="">>
> >
https://stat.ethz.ch/mailman/listinfo/bioconductor
> > Search the archives:
> >
>
http://news.gmane.org/gmane.science.biology.informatics.conductor
> >
> >
> >
> >
> > --
> > Tengfei Yin, PhD
> > Seven Bridges Genomics
> > sbgenomics.com <http: sbgenomics.com="">
> <http: sbgenomics.com=""/>
> > 625 Mt. Auburn St. Suite #208
> > Cambridge, MA 02138
> > (617) 866-0446 <tel:%28617%29%20866-0446>
> >
> >
> >
> >
> > --
> > Tengfei Yin, PhD
> > Seven Bridges Genomics
> > sbgenomics.com <http: sbgenomics.com="">
> <http: sbgenomics.com=""/>
> > 625 Mt. Auburn St. Suite #208
> > Cambridge, MA 02138
> > (617) 866-0446 <tel:%28617%29%20866-0446>
> >
> >
> >
> >
> > --
> > Tengfei Yin, PhD
> > Seven Bridges Genomics
> > sbgenomics.com <http: sbgenomics.com="">
<http: sbgenomics.com=""/>
> > 625 Mt. Auburn St. Suite #208
> > Cambridge, MA 02138
> > (617) 866-0446 <tel:%28617%29%20866-0446>
>
>
>
>
> --
> Tengfei Yin, PhD
> Seven Bridges Genomics
> sbgenomics.com <http: sbgenomics.com=""/>
> 625 Mt. Auburn St. Suite #208
> Cambridge, MA 02138
> (617) 866-0446
>
>
>
>
> --
> Tengfei Yin, PhD
> Seven Bridges Genomics
> sbgenomics.com <http: sbgenomics.com=""/>
> 625 Mt. Auburn St. Suite #208
> Cambridge, MA 02138
> (617) 866-0446