TrackHubGenome-class {rtracklayer} | R Documentation |
TrackHub Genome Access
Description
A TrackHub data source is a collection of tracks and sequences,
separated by genome. This class, TrackHubGenome
provides
direct access to the data for one particular genome.
Constructor
-
TrackHubGenome(trackhub, genome, create = FALSE
: Constructs a newTrackHubGenome
object, representinggenome
in the repositorytrackhub
(a URI string or aTrackHub
object).The
genome
argument can be an ID corresponding to a genome (potentially) intrackhub
or an installedBSgenome
package.If
create
isTRUE
, and the trackDb file does not already exist, it will be created. Creation only works if the repository is local and writeable.
Accessor Methods
In the code snippets below, x
represent a TrackHubGenome
object.
-
uri(x)
: Get the uri pointing to the genome directory in the TrackHub repository. -
genome(x)
: Get the name of the genome, e.g. “hg19”. -
length(x)
: number of tracks -
names(x), trackNames(x)
: names of the tracks -
getTracks(x)
: Get theList
ofTrack
from the tracks -
trackhub(x)
: Get the TrackHub object that contains this genome. -
organism(x)
: Get the organism name for this genome, e.g., “H sapiens”. -
trackField(x, name, field)
: Get thevalue
offield
forname
track. -
trackField(x, name, field) <- value
: Store thefield
andvalue
forname
track. writeTrackHub(x)
: Write tracks from memory representation to the trackDb file.
Data Access
-
track(x, name), x$name
: get the track calledname
-
track(x, name, format = bestFileFormat(value)) <- value, x$name <- value
: store the trackvalue
undername
. Note that track storing is only supported for local repositories, i.e., those with afile://
URI scheme.Currently, supported
value
types include aGenomicRanges
,GRangesList
, or a file resource (copied to the repository). The file resource may be represented as a path, URL,BiocFile
orRsamtoolsFile
. If not a file name,value
is written informat
. For generic interval data, this means a BigWig file (if there is a numeric “score” column) or a BED file otherwise. AnRleList
(e.g., coverage) is output as BigWig. ForUCSCData
values, the format is chosen according to the type of track line. ForRsamtoolsFile
objects, the file and its index are copied. -
referenceSequence(x)
: Get the reference sequence, as aDNAStringSet
. -
referenceSequence(x) <- value
: Set the reference sequence, as aDNAStringSet
. It is written as a 2bit file. This only works on local repositories.
Author(s)
Michael Lawrence
Examples
tests_dir <- system.file("tests", package = "rtracklayer")
th <- TrackHub(file.path(tests_dir, "trackhub"))
thg <- TrackHubGenome(th, "hg19")
length(thg)
organism(thg)
names(thg)
## Not run:
th <- TrackHub(file.path(tests_dir, "trackhub"), create = TRUE)
genomesFile(th) <- "genomes.txt"
genomeInfo(th) <- Genome(genome = "hg38", trackDb = "hg38/trackDb.txt")
genomeField(th, "hg38", "twoBitPath") <- "hg38/seq.2bit"
writeTrackHub(th)
thg <- TrackHubGenome(th, "hg38", create = TRUE)
seq <- import(file.path(tests_dir, "test.2bit"))
referenceSequence(thg) <- seq
track(thg, "PeaksData") <- paste0(tests_dir, "/test.bigWig")
trackField(thg, "wgEncodeUWDukeDnaseGM12878FdrPeaks", "bigDataUrl") <- "hg38/wgEncodeCshlShortRnaSeq.bigWig"
trackField(thg, "wgEncodeUWDukeDnaseGM12878FdrPeaks", "color") <- "8,104,172"
writeTrackHub(thg)
## End(Not run)