| 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 new
TrackHubGenomeobject, representinggenomein the repositorytrackhub(a URI string or aTrackHubobject).The
genomeargument can be an ID corresponding to a genome (potentially) intrackhubor an installedBSgenomepackage.If
createisTRUE, 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 the
ListofTrackfrom 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 the
valueoffieldfornametrack. trackField(x, name, field) <- value-
Store the
fieldandvaluefornametrack. writeTrackHub(x)-
Write tracks from memory representation to the trackDb file.
Data Access
track(x, name), x$name-
get the track called
name track(x, name, format = bestFileFormat(value)) <- value, x$name <- value-
store the track
valueundername. Note that track storing is only supported for local repositories, i.e., those with afile://URI scheme.Currently, supported
valuetypes include aGenomicRanges,GRangesList, or a file resource (copied to the repository). The file resource may be represented as a path, URL,BiocFileorRsamtoolsFile. If not a file name,valueis 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. ForUCSCDatavalues, the format is chosen according to the type of track line. ForRsamtoolsFileobjects, the file and its index are copied. referenceSequence(x)-
Get the reference sequence, as a
DNAStringSet. referenceSequence(x) <- value-
Set the reference sequence, as a
DNAStringSet. 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)