I extended the subview function to support embed image file in a ggplot object.

set.seed(123)
d = data.frame(x=rnorm(10), y=rnorm(10))

imgfile <- tempfile(, fileext=".png")
download.file("https://avatars1.githubusercontent.com/u/626539?v=3&u=e731426406dd3f45a73d96dd604bc45ae2e7c36f&s=140",
	          destfile=imgfile, mode='wb')

p = ggplot(d, aes(x, y))
subview(p, imgfile, x=d$x[1], y=d$y[1]) + geom_point(size=5)

Continue reading

To answer the issue, I extend the covplot function to support viewing coverage of a list of GRanges objects or bed files.

library(ChIPseeker)
files <- getSampleFiles()
peak=GenomicRanges::GRangesList(CBX6=readPeakFile(files[[4]]),
                                CBX7=readPeakFile(files[[5]]))

p <- covplot(peak)
print(p)

Continue reading

Phylip is also a widely used tree format, which contains taxa sequences with Newick tree text.

In ggtree, we can use read.phylip() function to parse the file and use ggtree() to visualize the tree.

Continue reading

label edge number in ggtree

This is a question from ggtree user. In ape and phytools, it’s easy to label edge using the edgelabels function.

set.seed(1)
tr = rtree(30)
library(ape)
plot(tr, main="ape")
edgelabels()

Continue reading

ggtree implemented a function, subview, that can add subplots on a ggplot2 object. It had successful applied to plot pie graphs on map.

set.seed(2016-01-04)
tr <- rtree(30)
tr <- groupClade(tr, node=45)
p <- ggtree(tr, aes(color=group)) + geom_tippoint()
cpos <- get_clade_position(p, node=45)
p1 <- p + geom_hilight(node=45)
p2 <- with(cpos, p+xlim(xmin, xmax*1.01)+ylim(ymin, ymax))
with(cpos, subview(p2+geom_tiplab(), p1+theme_transparent(), x=xmin+(xmax-xmin)*.15, y=ymin+(ymax-ymin)*.85))

Continue reading

Author's picture

Guangchuang Yu

Bioinformatics Professor @ SMU

Bioinformatics Professor

Guangzhou