How to set track attributes in rtracklayer
1
0
Entering edit mode
foehn ▴ 80
@foehn-16281
Last seen 13 months ago
United States

Hello,

I'm trying to use rtracklayer to view my data in UCSC genome browser, but have no idea how to set track attributes such as color or description. Manually setting up color and description in UCSC browser is rather tedious, so I would best avoid it but do it in the program.

Here is an example.

> library(rtracklayer)
> gr1 <- GRanges("chr1", IRanges(100001, 102000))
> gr2 <- gr1 + 3000

> session <- browserSession("UCSC")

> track(session, name = "gr1") <- gr1
> track(session, name = "gr2") <- gr2

> browserView(session, track = c("gr1", "gr2")) # This works but no track color or description set in the script

When I tried to set arguments color and description in track, the tracks were not uploaded at all.

> library(rtracklayer)
> gr1 <- GRanges("chr1", IRanges(100001, 102000))
> gr2 <- gr1 + 3000

> session <- browserSession("UCSC")

> track(session, name = "gr1", color = col2rgb("red")[, 1], description = "gr1") <- gr1
> track(session, name = "gr2", color = col2rgb("green")[, 1], description = "gr2") <- gr2

> browserView(session, track = c("gr1", "gr2"))
Error in resolveTrackIndex(object, value) : Unknown track(s): gr1, gr2

> "gr1" %in% trackNames(session)
[1] FALSE
> "gr2" %in% trackNames(session)
[1] FALSE

Probably I didn't use the package the correct way. Anyway, does anybody know how to do it? Thanks,

rtracklayer browserView browserSession • 588 views
ADD COMMENT
2
Entering edit mode
@michael-lawrence-3846
Last seen 10 months ago
United States

Thanks, this should be fixed in rtracklayer 1.42.2. It should also try to report an error when an upload fails. But that's just a heuristic.

ADD COMMENT
0
Entering edit mode

Indeed, my current rtracklayer is version 1.42.1. I will try 1.42.2, thanks.

ADD REPLY
0
Entering edit mode

Note that 1.42.2 will become available after a couple of days.

ADD REPLY
0
Entering edit mode

This is the result from the latest version. It appears something is still wrong.... Any idea? Thanks again.

> gr1 <- GRanges("chr1", IRanges(100001, 102000))
> gr2 <- gr1 + 3000
> session <- browserSession("UCSC")
> track(session, name = "gr1", color = col2rgb("red")[, 1], description = "gr1") <- gr1
Warning message:
In readChar(f, 1) :
  text connection used with readChar(), results may be incorrect
> track(session, name = "gr2", color = col2rgb("green")[, 1], description = "gr2") <- gr2
Warning message:
In readChar(f, 1) :
  text connection used with readChar(), results may be incorrect
> browserView(session, track = c("gr1", "gr2"))
Error in resolveTrackIndex(object, value) : Unknown track(s): gr1, gr2

> packageVersion("rtracklayer")
[1] ‘1.43.2’
ADD REPLY
0
Entering edit mode

The version is 1.42.2, not 1.43.2. If you're using devel, then you'll need 1.43.3.

ADD REPLY
0
Entering edit mode

Very clear, thanks! Also, it seems bit tricky of bioconductor's versioning, as I would think 1.43.2 should naturally contain the bug fix from 1.42.2...

ADD REPLY
0
Entering edit mode

v1.42.2 works now.

ADD REPLY

Login before adding your answer.

Traffic: 501 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