Open tengfei opened 12 years ago
hello, I was trying to generate heatmap for gene density (i.e. number of genes in non-overlapping 500kb bins) in a genome and display in circular view. I was hoping to get a plot that each colored bar/box represent one 500kb bin in the genome and the color for each heatmap bar/box represents the amount of genes in that bin(i.e. the box is white if the bin contains fewer genes and the box is blue if more genes are in the bin), however it seemed that rect geom argument or the geom = "heatmap" argument was giving me back something like a scatter plot instead. Do you mind explain in more detail how to generate a heatmap on a circular plot using ggbio? Thank you very much!
Hi,
I have very similar data and aim, had to bump this old post :)
I have SNP counts as "score" in my GRanges object:
> relist(tiles.gr, tiles)
GRangesList object of length 19:
$chrA01
GRanges object with 3005 ranges and 1 metadata column:
seqnames ranges strand | score
<Rle> <IRanges> <Rle> | <numeric>
chrA01.chrA01 chrA01 82924-92921 * | 2
chrA01.chrA01 chrA01 92922-102920 * | 0
chrA01.chrA01 chrA01 102921-112918 * | 0
chrA01.chrA01 chrA01 112919-122917 * | 0
chrA01.chrA01 chrA01 122918-132916 * | 0
... ... ... ... . ...
chrA01.chrA01 chrA01 30078762-30088760 * | 14
chrA01.chrA01 chrA01 30088761-30098759 * | 7
chrA01.chrA01 chrA01 30098760-30108757 * | 16
chrA01.chrA01 chrA01 30108758-30118756 * | 0
chrA01.chrA01 chrA01 30118757-30128755 * | 4
And wanted to plot a circular heatmap based on the scores.
Did you manage to figure out how to use it @XinyiZhu1007 ?
Thanks! Cheers Jenny
The code below gives me a scatterplot, like what was mentioned
ggbio() +
circle(tiles.gr, aes(y=score), geom = "heatmap", grid=TRUE) + ##most inner circle
circle(express.gr, geom = "ideo", fill = "gray70") + ##plot genome as blocks
circle(express.gr, geom = "scale", size = 2) + ##add scale
circle(express.gr, geom = "text", aes(label = seqnames), vjust = 0, size = 3)
It was achieved using geom rect (filled by score) and scale_fill_gradient:
ggbio() +
circle(tiles.gr, aes(fill=score, colour=NULL), geom="rect")+ ##most inner circle
scale_fill_gradient(low = "white", high = "red") +
circle(express.gr, geom = "ideo", fill = "gray70") + ##plot genome as blocks
circle(express.gr, geom = "scale", size = 2) + ##add scale
circle(express.gr, geom = "text", aes(label = seqnames), vjust = 0, size = 3)
Now of course you can use rect geom to mimic heat map easily, maybe a more general heartmap geom should be there for circular view too.