GViz, different group colours
1
0
Entering edit mode
p1990 • 0
@p1990-11044
Last seen 6.8 years ago

Hi,

I have read through the Gviz vignette extensively. I have two data tracks (dot plot) in my overlay, how can I change colour of the groups from something other than the standard blue and pink?

Ideally I would be able to set the colour for each specific dot using a vector - in an overlay and also single datatrack!

Finally I also want to label specific data points.

Any help is very much appreciated, I've spent a long time reading through documentation!

 

Current working code (sorry, looks a bit complicated than it is!)

library(Gviz)
library(GenomicRanges)
library(GenomicFeatures)
library(gridExtra)
library(trackViewer)
library(biomaRt)

start = 700e3; end = 1e6;
chr = 1
gen = "hg19"
df1_trait = "first"
df2_trait = "second"
gtrack <- GenomeAxisTrack(col="black", fontsize=17)
df1 <- data.frame(Y=rnorm(100), BP=seq(start,end, length.out=100))
df2 <- data.frame(Y=rnorm(100), BP=seq(start,end, length.out=100))

dtrack1 <- DataTrack(data = df2$Y, start = df2$BP, end = df2$BP+1, chromosome = chr, genome = gen, groups = factor(df2_trait,levels = c(df1_trait, df2_trait)), name="Log10P", legend=TRUE)
dtrack <- DataTrack(data = df1$Y, start = df1$BP, end = df1$BP+1, chromosome = chr, genome = gen, groups = factor(df1_trait,levels = c(df1_trait, df2_trait)), name="Log10P", legend=TRUE)

overlapTracks <- OverlayTrack(trackList = list(dtrack, dtrack1), background.title = "#001f4d", legend=TRUE)

grtrack <- BiomartGeneRegionTrack(genome="hg19", chromosome=chr, start=start, end=end, name="Ensembl", transcriptAnnotation="symbol", stacking="squish", collapseTranscripts="longest", background.title="brown", background.panel = "#FFFEDB", col="black", fill="salmon", fontcolor="black")

ylims <- extendrange(range(c(values(dtrack), values(dtrack1))))

png(file="saveit.png", height=600, width=700)
plotTracks(list(overlapTracks, gtrack, grtrack), from=start, to=end, col.line=NULL, ylim=ylims, fontsize=14, groupAnnotation = "group")
dev.off()
gviz gviz-package • 1.5k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 6 hours ago
United States

Use the col argument. See p. 30 of the Gviz user's guide for a list of all useful arguments.

ADD COMMENT
0
Entering edit mode

ah done, i was just confused by the fact that it wanted a vector when i was passing in a single colour for each plot.
Do you have any ideas for my other two questions?

Thanks James!

ADD REPLY

Login before adding your answer.

Traffic: 536 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6