trackViewer assigning track colors
1
0
Entering edit mode
@tomasrodriguez-21656
Last seen 6 months ago
United States

I am having trouble assigning colors as lists to multiple tracks. As far as I can tell, my approach is identical to that of the ?setTrackStyleParam example for designating track colors. I am not the best at dealing with this list type, so any help would be appreciated.

> setTrackStyleParam(trackList,"color",value = c("red4","blue1","blue2","blue3","purple"))
#Error in (function (classes, fdef, mtable)  :

unable to find an inherited method for function 'setTrackStyleParam' for signature '"trackList", "character"'
> length(trackList)
#[1] 5

>setTrackStyleParam(trackList[[1]],"color",value = "red4")
#assigning colors to individual elements works fine

trackViewer track • 389 views
2
Entering edit mode
@james-w-macdonald-5106
Last seen 8 hours ago
United States

The first argument for setTrackStyleParam is a track object, not a trackList, which is why you get that error. Here is the code from the vignette:

setTrackStyleParam(trackList[[1]], "color", c("green", "black"))
setTrackStyleParam(trackList[[2]], "color", c("black", "blue"))
for(i in 3:length(trackList))
setTrackStyleParam(trackList[[i]], "color", "black")
viewTracks(trackList, gr=gr, viewerStyle=viewerStyle)


You can set it individually, or loop through the tracklist

0
Entering edit mode

Thanks for the tip! I am guessing that the 2-color vectors are for positive and negative values? I mistook these as tracklist elements.

1
Entering edit mode

Yes, the two colors are for dat and dat2. dat2 will be plotted as negative values.