| Title: | igvShiny: a wrapper of Integrative Genomics Viewer (IGV - an interactive tool for visualization and exploration integrated genomic data) |
|---|---|
| Description: | This package is a wrapper of Integrative Genomics Viewer (IGV). It comprises an htmlwidget version of IGV. It can be used as a module in Shiny apps. |
| Authors: | Paul Shannon [aut], Arkadiusz Gladki [aut, cre] (ORCID: <https://orcid.org/0000-0002-7059-6378>), Karolina Scigocka [aut], Carolina Heimann [ctb], Steffen Klasberg [ctb], Vincent Carey [ctb], Parv Sachdeva [ctb], Mateusz Gladki [ctb], R Consortium [fnd] |
| Maintainer: | Arkadiusz Gladki <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.9.53 |
| Built: | 2026-11-15 20:42:26 UTC |
| Source: | https://github.com/bioc/igvShiny |
Pack junction attributes into a bed name column
.packJunctionAttributes(tbl).packJunctionAttributes(tbl)
tbl |
A data.frame of junctions. |
A character vector, one packed name field per row.
Sanitize and merge track configuration options
.sanitizeAndMergeOptions( baseOptions, userOptions, allowed = .validIgvTrackOptions ).sanitizeAndMergeOptions( baseOptions, userOptions, allowed = .validIgvTrackOptions )
baseOptions |
A list of default options set by the R function. |
userOptions |
A list of options provided by the user via trackConfig. |
allowed |
character, the option names igv.js reads for this kind of track; defaults to the global allowlist |
A merged and sanitized list of options ready to be sent to JavaScript.
Check a chromosome color map before it reaches igv.js
.sanitizeChromosomeColorMap(map).sanitizeChromosomeColorMap(map)
map |
a named list or character vector of colors, possibly empty |
the map as a named list, empty if nothing was supplied
Sanitize one startup track specification
.sanitizeTrack(track, depth).sanitizeTrack(track, depth)
track |
A named list, one igv.js track configuration. |
depth |
An integer, how deep this track sits in a merged track. |
The sanitized track, or NULL if it cannot be used.
Sanitize a list of startup track specifications
.sanitizeTracks(tracks, depth = 1L).sanitizeTracks(tracks, depth = 1L)
tracks |
A list of named lists, each an igv.js track configuration. |
depth |
An integer, how deep this list sits in a merged track; 1 for the startup list itself. |
A sanitized list of track configurations; invalid entries or keys are dropped with a warning.
A DataFrameAnnotationTrack whose table is bedpe: chrom1,
start1, end1, chrom2, start2, end2 (0-based starts), optionally followed by
name and score. igv.js draws it as an "interact" track of arcs between the
two anchors. Display it with loadTrack; color and height are
sent to igv.js.
BedpeInteractionsTrack( trackName, table, color = "darkBlue", trackHeight = 50, displayMode = "EXPANDED", visibilityWindow = 1e+05 )BedpeInteractionsTrack( trackName, table, color = "darkBlue", trackHeight = 50, displayMode = "EXPANDED", visibilityWindow = 1e+05 )
trackName |
A character string, used as track label by igv |
table |
a bedpe data.frame, at least 6 columns |
color |
A CSS color name (e.g., "red" or "#FF0000"), or "random" |
trackHeight |
track height in pixels |
displayMode |
"COLLAPSED", "SQUISHED" or "EXPANDED"; stored, not sent |
visibilityWindow |
Maximum window size in base pairs; stored, not sent |
An object of class BedpeInteractionsTrack
f <- system.file(package = "igvShiny", "extdata", "sixColumn-demo1.bedpe") tbl <- utils::read.table(f, sep = "\t", header = TRUE, stringsAsFactors = FALSE) track <- BedpeInteractionsTrack("interactions", tbl) trackSize(track)f <- system.file(package = "igvShiny", "extdata", "sixColumn-demo1.bedpe") tbl <- utils::read.table(f, sep = "\t", header = TRUE, stringsAsFactors = FALSE) track <- BedpeInteractionsTrack("interactions", tbl) trackSize(track)
Compares contig naming conventions (e.g. UCSC chr1 vs
Ensembl 1), contig lengths (e.g. hg19 vs hg38), and coordinate
boundaries between a track (BAM, CRAM, VCF, BED, or Bioconductor object)
and the active reference genome.
checkReferenceCompatibility( target, genomeName = NULL, genomeSpec = NULL, session = NULL, id = NULL )checkReferenceCompatibility( target, genomeName = NULL, genomeSpec = NULL, session = NULL, id = NULL )
target |
A file path (.bam, .cram, .vcf, .vcf.gz, .bed) or data object (data.frame, GenomicAlignments, VCF, GRanges) |
genomeName |
Character string, e.g. "hg38", "hg19", "mm10" |
genomeSpec |
Named list of genome options, as produced by
|
session |
Optional Shiny session object |
id |
Optional widget element ID |
A list with:
checked: logical indicating whether both inputs could be inspected
compatible: logical indicating if no critical mismatches were
found, or NA when the inputs could not be checked
mismatches: character vector of descriptive warning messages
details: list of specific detected anomalies (naming, length, out-of-bounds)
targetAssembly: detected assembly of track, if recognized
referenceAssembly: reference genome name
bamFile <- system.file(package = "igvShiny", "extdata", "tumor.bam") # tumor.bam is GRCh38: compatible with hg38, incompatible with hg19 res1 <- checkReferenceCompatibility(bamFile, genomeName = "hg38") res1$compatible # TRUE res2 <- checkReferenceCompatibility(bamFile, genomeName = "hg19") res2$compatible # FALSEbamFile <- system.file(package = "igvShiny", "extdata", "tumor.bam") # tumor.bam is GRCh38: compatible with hg38, incompatible with hg19 res1 <- checkReferenceCompatibility(bamFile, genomeName = "hg38") res1$compatible # TRUE res2 <- checkReferenceCompatibility(bamFile, genomeName = "hg19") res2$compatible # FALSE
display the already constructed and configured track
## S4 method for signature 'GWASTrack' display(obj, session, id, deleteTracksOfSameName = TRUE)## S4 method for signature 'GWASTrack' display(obj, session, id, deleteTracksOfSameName = TRUE)
obj |
An object of class GWASTrack |
session |
a Shiny session object |
id |
character the identifier of the target igv object in the browser |
deleteTracksOfSameName |
logical to avoid duplications in track names |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
GenomicAlignmentTrack holds a GAlignments
object (GenomicAlignments, written to a bam file at display time; needs the
suggested packages GenomicAlignments, rtracklayer and Rsamtools).
RemoteAlignmentTrack and CramTrack point igv.js at a served
bam or cram file and its index. Display them with loadTrack;
color, height and visibilityWindow are sent to igv.js.
GenomicAlignmentTrack( trackName, alignment, trackHeight = 50, visibilityWindow = 30000, color = "gray" ) RemoteAlignmentTrack( trackName, bamUrl, bamIndex = paste0(bamUrl, ".bai"), trackHeight = 50, visibilityWindow = 30000, color = "gray" ) CramTrack( trackName, cramUrl, indexUrl, trackHeight = 50, visibilityWindow = 30000, color = "gray" )GenomicAlignmentTrack( trackName, alignment, trackHeight = 50, visibilityWindow = 30000, color = "gray" ) RemoteAlignmentTrack( trackName, bamUrl, bamIndex = paste0(bamUrl, ".bai"), trackHeight = 50, visibilityWindow = 30000, color = "gray" ) CramTrack( trackName, cramUrl, indexUrl, trackHeight = 50, visibilityWindow = 30000, color = "gray" )
trackName |
A character string, used as track label by igv |
alignment |
a |
trackHeight |
track height in pixels |
visibilityWindow |
Maximum window size in base pairs for which reads are displayed |
color |
A CSS color name (e.g., "red" or "#FF0000"), or "random" |
bamUrl |
url of a bam file |
bamIndex |
url of its index; by default |
cramUrl |
url of a cram file |
indexUrl |
url of its crai index |
An object of the named class
alignmenta GAlignments object
bamUrlcharacter, url of the bam file
bamIndexcharacter, url of its index
cramUrlcharacter, url of the cram file
indexUrlcharacter, url of its crai index
track <- CramTrack("cram demo", "https://example.com/reads.cram", "https://example.com/reads.cram.crai") trackInfo(track)track <- CramTrack("cram demo", "https://example.com/reads.cram", "https://example.com/reads.cram.crai") trackInfo(track)
a helper function for basic genomes, obtains the genome codes (e.g. 'hg38')
get_basic_genomes()get_basic_genomes()
an list of short genome codes, e.g., "hg38", "dm6"
bs <- get_basic_genomes()bs <- get_basic_genomes()
a helper function for common always available stock genomes, obtains the genome codes (e.g. 'hg38')
get_cas_genomes()get_cas_genomes()
an list of short genome codes, e.g., "hg38", "dm6"
cas <- get_cas_genomes()cas <- get_cas_genomes()
a helper function for mostly internal use, obtains the genome codes (e.g. 'hg38') supported by igv.js
get_css_genomes(test = FALSE)get_css_genomes(test = FALSE)
test |
logical(1) defaults to FALSE |
an list of short genome codes, e.g., "hg38", "dm6", "tair10"
css <- get_css_genomes(test = TRUE)css <- get_css_genomes(test = TRUE)
get_tracks_dir Get the directory where tracks are stored. The directory can be defined with environmental variable. If not defined the default is a directory called "tracks" in the temp directory. We need a local directory to write files - for instance, a vcf file representing a genomic region of interest. We then tell shiny about that directory, so that shiny's built-in http server can serve up files we write there, ultimately consumed by igv.js
get_tracks_dir(env_var = "TRACKS_DIR")get_tracks_dir(env_var = "TRACKS_DIR")
env_var |
The name of the environmental variable to use. |
string with the path to the tracks directory.
gtd <- get_tracks_dir(env_var = "TRACKS_DIR")gtd <- get_tracks_dir(env_var = "TRACKS_DIR")
the url of the gwas table
## S4 method for signature 'GWASTrack' getUrl(obj)## S4 method for signature 'GWASTrack' getUrl(obj)
obj |
An object of class GWASTrack |
character
file <- # a local gwas file system.file(package = "igvShiny", "extdata", "gwas-5k.tsv.gz") tbl.gwas <- read.table(file, sep = "\t", header = TRUE, quote = "") track <- GWASTrack( "gwas 5k", tbl.gwas, chrom.col = 12, pos.col = 13, pval.col = 28 ) getUrl(track)file <- # a local gwas file system.file(package = "igvShiny", "extdata", "gwas-5k.tsv.gz") tbl.gwas <- read.table(file, sep = "\t", header = TRUE, quote = "") track <- GWASTrack( "gwas 5k", tbl.gwas, chrom.col = 12, pos.col = 13, pval.col = 28 ) getUrl(track)
A GFF3Track holds either a 9-column GFF3 table
(tbl), served as a file, or the url of a GFF3 file and optionally
its index. Features are colored by trackColor, or by the
colorByAttribute attribute through colorTable. Display it
with loadTrack.
GFF3Track( trackName, tbl.track = data.frame(), url = NA_character_, indexURL = NA_character_, trackColor = "black", colorByAttribute = NA_character_, colorTable = list(), displayMode = "EXPANDED", trackHeight = 50, visibilityWindow = 1e+05 )GFF3Track( trackName, tbl.track = data.frame(), url = NA_character_, indexURL = NA_character_, trackColor = "black", colorByAttribute = NA_character_, colorTable = list(), displayMode = "EXPANDED", trackHeight = 50, visibilityWindow = 1e+05 )
trackName |
A character string, used as track label by igv |
tbl.track |
a data.frame in standard 9-column GFF3 format |
url |
url of a GFF3 file, used when |
indexURL |
url of its index |
trackColor |
A CSS color, used unless colorTable is given |
colorByAttribute |
name of a GFF3 attribute in column 9, e.g. "biotype" |
colorTable |
a named list mapping attribute values to colors |
displayMode |
"COLLAPSED", "SQUISHED" or "EXPANDED" |
trackHeight |
track height in pixels |
visibilityWindow |
Maximum window size in base pairs for which features are displayed |
An object of class GFF3Track
tbldata.frame, the GFF3 table, or an empty data.frame
urlcharacter, the GFF3 url, or NA
indexURLcharacter, the index url, or NA
colorByAttributecharacter, a column 9 attribute, or NA
colorTablelist, attribute value to color; a "default" entry is renamed "*", igv.js's fallback key
f <- system.file(package = "igvShiny", "extdata", "GRCh38.94.NDUFS2.gff3") tbl <- utils::read.table(f, sep = "\t", header = FALSE, quote = "", stringsAsFactors = FALSE) track <- GFF3Track("NDUFS2", tbl, colorByAttribute = "biotype", colorTable = list(protein_coding = "blue", default = "gray")) trackSize(track)f <- system.file(package = "igvShiny", "extdata", "GRCh38.94.NDUFS2.gff3") tbl <- utils::read.table(f, sep = "\t", header = FALSE, quote = "", stringsAsFactors = FALSE) track <- GFF3Track("NDUFS2", tbl, colorByAttribute = "biotype", colorTable = list(protein_coding = "blue", default = "gray")) trackSize(track)
GWASTrack creates an IGV manhattan track from GWAS data
GWASTrack( trackName, data, chrom.col, pos.col, pval.col, chromosomeColorMap = list(), trackHeight = 50, autoscale = TRUE, minY = 0, maxY = 30 )GWASTrack( trackName, data, chrom.col, pos.col, pval.col, chromosomeColorMap = list(), trackHeight = 50, autoscale = TRUE, minY = 0, maxY = 30 )
trackName |
A character string, used as track label by igv, we recommend unique names per track. |
data |
a data.frame or a url pointing to one, whose structure is described by chrom.col, pos.col, pval.col |
chrom.col |
numeric, the column number of the chromosome column |
pos.col |
numeric, the column number of the position column |
pval.col |
numeric, the column number of the GWAS pvalue column |
chromosomeColorMap |
a named list or character vector mapping
chromosome names, as they are spelled in the data, to colors,
e.g. |
trackHeight |
numeric in pixels |
autoscale |
logical |
minY |
numeric for explicit (non-auto) scaling |
maxY |
numeric for explicit (non-auto) scaling |
A GWASTrack object
file <- # a local gwas file system.file(package = "igvShiny", "extdata", "gwas-5k.tsv.gz") tbl.gwas <- read.table(file, sep = "\t", header = TRUE, quote = "") dim(tbl.gwas) track <- GWASTrack( "gwas 5k", tbl.gwas, chrom.col = 12, pos.col = 13, pval.col = 28 ) getUrl(track) # a remote gwas file: the constructor checks that the url resolves, so this # block reaches the network and stays out of R CMD check url <- "https://gladki.pl/igvShiny/gwas_sample.tsv.gz" track <- GWASTrack( "remote url gwas", url, chrom.col = 3, pos.col = 4, pval.col = 10, autoscale = FALSE, minY = 0, maxY = 300, trackHeight = 100 ) getUrl(track) # colors picked per chromosome, with "*" covering the rest track <- GWASTrack( "gwas 5k, custom colors", tbl.gwas, chrom.col = 12, pos.col = 13, pval.col = 28, chromosomeColorMap = list("1" = "red", "2" = "blue", "*" = "gray") )file <- # a local gwas file system.file(package = "igvShiny", "extdata", "gwas-5k.tsv.gz") tbl.gwas <- read.table(file, sep = "\t", header = TRUE, quote = "") dim(tbl.gwas) track <- GWASTrack( "gwas 5k", tbl.gwas, chrom.col = 12, pos.col = 13, pval.col = 28 ) getUrl(track) # a remote gwas file: the constructor checks that the url resolves, so this # block reaches the network and stays out of R CMD check url <- "https://gladki.pl/igvShiny/gwas_sample.tsv.gz" track <- GWASTrack( "remote url gwas", url, chrom.col = 3, pos.col = 4, pval.col = 10, autoscale = FALSE, minY = 0, maxY = 300, trackHeight = 100 ) getUrl(track) # colors picked per chromosome, with "*" covering the rest track <- GWASTrack( "gwas 5k, custom colors", tbl.gwas, chrom.col = 12, pos.col = 13, pval.col = 28, chromosomeColorMap = list("1" = "red", "2" = "blue", "*" = "gray") )
igvR's igvAnnotationTrack() built a track that held no
data. Here it picks the subclass that fits annotation: a data.frame
gives a DataFrameAnnotationTrack, a UCSCData a
UCSCBedAnnotationTrack and any other GRanges a
GRangesAnnotationTrack.
igvAnnotationTrack(trackName, annotation, ...)igvAnnotationTrack(trackName, annotation, ...)
trackName |
A character string, used as track label by igv |
annotation |
a data.frame, |
... |
further arguments of the subclass constructor, e.g. color, displayMode, trackHeight |
an object of a subclass of igvAnnotationTrack
tbl <- data.frame(chrom = "chr1", start = 100, end = 200, stringsAsFactors = FALSE) class(igvAnnotationTrack("demo", tbl))tbl <- data.frame(chrom = "chr1", start = 100, end = 200, stringsAsFactors = FALSE) class(igvAnnotationTrack("demo", tbl))
igvAnnotationTrack adds the slots of igv.js annotation
tracks to Track. Its subclasses carry the features in
a coreObject slot: DataFrameAnnotationTrack (a bed-like
data.frame, written as is), GRangesAnnotationTrack (a
GRanges; 1-based starts become 0-based bed starts) and
UCSCBedAnnotationTrack (an rtracklayer UCSCData, needs
the suggested package rtracklayer). Display one with
loadTrack, which sends displayMode,
expandedRowHeight, squishedRowHeight, maxRows,
searchable and visibilityWindow to igv.js. nameField
is stored for igvR compatibility, not sent.
DataFrameAnnotationTrack( trackName, annotation, color = "", displayMode = "SQUISHED", trackHeight = 50, expandedRowHeight = 30, squishedRowHeight = 15, maxRows = 500, searchable = FALSE, visibilityWindow = 1e+05 ) GRangesAnnotationTrack( trackName, annotationData, color = "darkGrey", displayMode = "SQUISHED", trackHeight = 50, expandedRowHeight = 30, squishedRowHeight = 15, maxRows = 500, searchable = FALSE, visibilityWindow = 1e+05 ) UCSCBedAnnotationTrack( trackName, annotation, color = "darkGrey", displayMode = "SQUISHED", trackHeight = 50, expandedRowHeight = 30, squishedRowHeight = 15, maxRows = 500, searchable = FALSE, visibilityWindow = 1e+05 )DataFrameAnnotationTrack( trackName, annotation, color = "", displayMode = "SQUISHED", trackHeight = 50, expandedRowHeight = 30, squishedRowHeight = 15, maxRows = 500, searchable = FALSE, visibilityWindow = 1e+05 ) GRangesAnnotationTrack( trackName, annotationData, color = "darkGrey", displayMode = "SQUISHED", trackHeight = 50, expandedRowHeight = 30, squishedRowHeight = 15, maxRows = 500, searchable = FALSE, visibilityWindow = 1e+05 ) UCSCBedAnnotationTrack( trackName, annotation, color = "darkGrey", displayMode = "SQUISHED", trackHeight = 50, expandedRowHeight = 30, squishedRowHeight = 15, maxRows = 500, searchable = FALSE, visibilityWindow = 1e+05 )
trackName |
A character string, used as track label by igv; we recommend unique names per track |
annotation |
for |
color |
A CSS color name (e.g., "red" or "#FF0000"), or "random"; for a data.frame, leave the default "" if supplying bed9 with itemRgb |
displayMode |
"COLLAPSED", "SQUISHED" or "EXPANDED" |
trackHeight |
track height in pixels |
expandedRowHeight |
Height of each row of features in "EXPANDED" mode |
squishedRowHeight |
Height of each row of features in "SQUISHED" mode |
maxRows |
maximum number of feature rows to display |
searchable |
If TRUE, labels on annotation elements may be used in search |
visibilityWindow |
Maximum window size in base pairs for which features are displayed |
annotationData |
a |
An object of the named class
classTypeOfSuppliedObjectcharacter
displayModecharacter, "COLLAPSED", "SQUISHED" or "EXPANDED"
expandedRowHeightnumeric, row height in "EXPANDED" mode
squishedRowHeightnumeric, row height in "SQUISHED" mode
nameFieldcharacter; stored for igvR compatibility, not sent
maxRowsnumeric
searchablelogical
coreObjectthe features: data.frame, GRanges or UCSCData
tbl <- data.frame(chrom = rep("chr5", 3), start = c(88883100, 88883200, 88883350), end = c(88883150, 88883220, 88883390), name = c("a", "b", "c"), stringsAsFactors = FALSE) track <- DataFrameAnnotationTrack("data.frame demo", tbl, color = "red") gr <- GenomicRanges::GRanges(c("chr5:100-149", "chr5:300-349")) track2 <- GRangesAnnotationTrack("GRanges demo", gr) trackSize(track2)tbl <- data.frame(chrom = rep("chr5", 3), start = c(88883100, 88883200, 88883350), end = c(88883150, 88883220, 88883390), name = c("a", "b", "c"), stringsAsFactors = FALSE) track <- DataFrameAnnotationTrack("data.frame demo", tbl, color = "red") gr <- GenomicRanges::GRanges(c("chr5:100-149", "chr5:300-349")) track2 <- GRangesAnnotationTrack("GRanges demo", gr) trackSize(track2)
This function is called in the server function of your shiny app
igvShiny( genomeOptions, width = NULL, height = NULL, elementId = NULL, displayMode = "squished", tracks = list() )igvShiny( genomeOptions, width = NULL, height = NULL, elementId = NULL, displayMode = "squished", tracks = list() )
genomeOptions |
a list with these fields: genomeName, initialLocus, annotation, dataMode, fasta, fastaIndex, stockGenome, validated |
width |
a character string, standard css notations, either e.g., "1000px" or "95%" |
height |
a character string, needs to be an explicit pixel measure, e.g., "800px" |
elementId |
a character string, the html element id within which igv is created |
displayMode |
a character string, default "SQUISHED". |
tracks |
a list of track specifications to be created and displayed
at startup. Each element is itself a named list of igv.js track options
(e.g. |
the created widget
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
This function is called in the ui function of your shiny app
igvShinyOutput(outputId, width = "100%", height = NULL)igvShinyOutput(outputId, width = "100%", height = NULL)
outputId |
a character string, specifies the html element id |
width |
a character string, standard css notations, either e.g., "1000px" or "95%", "100%" by default |
height |
a character string, needs to be an explicit pixel measure, e.g., "800px", "400px" by default |
the created widget's html
io <- igvShinyOutput("igvOut")io <- igvShinyOutput("igvOut")
load GenomicAlignments data as an igv.js alignment track
loadBamTrackFromLocalData( session, id, trackName, data, deleteTracksOfSameName = TRUE, displayMode = "EXPANDED", trackConfig = list(), validateReference = TRUE, trackHeight = NULL )loadBamTrackFromLocalData( session, id, trackName, data, deleteTracksOfSameName = TRUE, displayMode = "EXPANDED", trackConfig = list(), validateReference = TRUE, trackHeight = NULL )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
data |
GenomicAlignments object |
deleteTracksOfSameName |
logical, default TRUE |
displayMode |
character string, possible values are "EXPANDED"(default), "SQUISHED" or "COLLAPSED" |
trackConfig |
a named list of additional igv.js track configuration
options, |
validateReference |
logical flag, default TRUE: checks track contigs against the active reference genome and emits warnings/toasts on mismatch. |
trackHeight |
numeric, track height in pixels (default: NULL, igv.js defaults to 300) |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
Streams a local BAM file and its index directly from disk using HTTP 206 Partial Content requests handled by the Shiny session. This allows viewing multi-gigabyte BAM files without loading them into R memory.
loadBamTrackFromLocalFile( session, id, trackName, bamFile, indexFile = paste0(bamFile, ".bai"), deleteTracksOfSameName = TRUE, displayMode = "EXPANDED", trackConfig = list(), validateReference = TRUE, trackHeight = NULL )loadBamTrackFromLocalFile( session, id, trackName, bamFile, indexFile = paste0(bamFile, ".bai"), deleteTracksOfSameName = TRUE, displayMode = "EXPANDED", trackConfig = list(), validateReference = TRUE, trackHeight = NULL )
session |
an environment or list, provided and managed by shiny (ShinySession) |
id |
character string, the html element id of this widget instance |
trackName |
character string, display name for the track |
bamFile |
character string, path to an existing, readable .bam file |
indexFile |
character string, path to the corresponding .bai index file
(default: |
deleteTracksOfSameName |
logical, whether to delete any existing track with the same name (default: TRUE) |
displayMode |
character string, display mode for alignments ("EXPANDED", "COLLAPSED", or "SQUISHED"), default "EXPANDED" |
trackConfig |
list, additional track options passed to igv.js |
validateReference |
logical flag, default TRUE: checks track contigs against the active reference genome and emits warnings/toasts on mismatch. |
trackHeight |
numeric, track height in pixels (default: NULL, igv.js defaults to 300) |
None, sends a message to the browser
## Not run: # Inside a Shiny server function: bamFile <- system.file(package = "igvShiny", "extdata", "A_2_A24_02_01_01.nanopore.minimap.sorted.bam") baiFile <- paste0(bamFile, ".bai") loadBamTrackFromLocalFile(session, "igvShiny_0", "Nanopore Reads", bamFile, baiFile, displayMode = "SQUISHED", trackHeight = 100) ## End(Not run)## Not run: # Inside a Shiny server function: bamFile <- system.file(package = "igvShiny", "extdata", "A_2_A24_02_01_01.nanopore.minimap.sorted.bam") baiFile <- paste0(bamFile, ".bai") loadBamTrackFromLocalFile(session, "igvShiny_0", "Nanopore Reads", bamFile, baiFile, displayMode = "SQUISHED", trackHeight = 100) ## End(Not run)
load a remote bam track
loadBamTrackFromURL( session, id, trackName, bamURL, indexURL, deleteTracksOfSameName = TRUE, displayMode = "EXPANDED", showAllBases = FALSE, trackConfig = list(), trackHeight = NULL )loadBamTrackFromURL( session, id, trackName, bamURL, indexURL, deleteTracksOfSameName = TRUE, displayMode = "EXPANDED", showAllBases = FALSE, trackConfig = list(), trackHeight = NULL )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
bamURL |
character string http url for the bam file, typically very large |
indexURL |
character string http url for the bam file index, typically small |
deleteTracksOfSameName |
logical, default TRUE |
displayMode |
character string, possible values are "EXPANDED"(default), "SQUISHED" or "COLLAPSED" |
showAllBases |
logical, show all bases in the alignment, default FALSE |
trackConfig |
a named list of additional igv.js track configuration
options. Alignment tracks read |
trackHeight |
numeric, track height in pixels (default: NULL, igv.js defaults to 300) |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
load a genome annotation track provided as a data.frame
loadBedGraphTrack( session, id, trackName, tbl, color = "gray", trackHeight = 30, autoscale, autoscaleGroup = -1, min = NA_real_, max = NA_real_, deleteTracksOfSameName = TRUE, quiet = TRUE, trackConfig = list(), validateReference = TRUE )loadBedGraphTrack( session, id, trackName, tbl, color = "gray", trackHeight = 30, autoscale, autoscaleGroup = -1, min = NA_real_, max = NA_real_, deleteTracksOfSameName = TRUE, quiet = TRUE, trackConfig = list(), validateReference = TRUE )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
tbl |
data.frame, with at least "chrom" "start" "end" "score" columns |
color |
character string, a legal CSS color, or "random", "gray" by default |
trackHeight |
an integer, 30 (pixels) by default |
autoscale |
logical |
autoscaleGroup |
numeric(1) defaults to -1 |
min |
numeric, consulted when autoscale is FALSE |
max |
numeric, consulted when autoscale is FALSE |
deleteTracksOfSameName |
logical, default TRUE |
quiet |
logical, default TRUE, controls verbosity |
trackConfig |
a named list of additional igv.js track configuration options. |
validateReference |
logical flag, default TRUE: checks track contigs and coordinates against the active reference genome and emits warnings/toasts on mismatch. |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
load a bedgraph track provided as a data.frame
loadBedGraphTrackFromURL( session, id, trackName, url, color = "gray", trackHeight = 30, autoscale = TRUE, min = 0, max = 1, autoscaleGroup = -1, deleteTracksOfSameName = TRUE, quiet = TRUE, trackConfig = list() )loadBedGraphTrackFromURL( session, id, trackName, url, color = "gray", trackHeight = 30, autoscale = TRUE, min = 0, max = 1, autoscaleGroup = -1, deleteTracksOfSameName = TRUE, quiet = TRUE, trackConfig = list() )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
url |
character |
color |
character string, a legal CSS color, or "random", "gray" by default |
trackHeight |
an integer, 30 (pixels) by default |
autoscale |
logical |
min |
numeric, consulted when autoscale is FALSE |
max |
numeric, consulted when autoscale is FALSE |
autoscaleGroup |
numeric(1) defaults to -1 |
deleteTracksOfSameName |
logical(1) defaults to TRUE |
quiet |
logical, default TRUE, controls verbosity |
trackConfig |
a named list of additional igv.js track configuration options. |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
load a bed track provided as a data.frame
loadBedTrack( session, id, trackName, tbl, color = "", trackHeight = 50, deleteTracksOfSameName = TRUE, quiet = TRUE, trackConfig = list(), validateReference = TRUE )loadBedTrack( session, id, trackName, tbl, color = "", trackHeight = 50, deleteTracksOfSameName = TRUE, quiet = TRUE, trackConfig = list(), validateReference = TRUE )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
tbl |
data.frame, with at least "chrom" "start" "end" columns |
color |
character string, a legal CSS color, or "random", "gray" by default |
trackHeight |
an integer, 50 (pixels) by default |
deleteTracksOfSameName |
logical, default TRUE |
quiet |
logical, default TRUE, controls verbosity |
trackConfig |
a named list of additional igv.js track configuration options. |
validateReference |
logical flag, default TRUE: checks track contigs and coordinates against the active reference genome and emits warnings/toasts on mismatch. |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
load a local cram track. Unlike loadBamTrackFromLocalData
this loader takes file paths, not an R object: no bioconductor package parses
cram, so the file and its index are handed to igv.js untouched, through the
directory shiny serves as "tracks".
loadCramTrackFromLocalData( session, id, trackName, cramFile, indexFile = paste0(cramFile, ".crai"), deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE, trackHeight = NULL ) loadCramTrackFromLocalFile( session, id, trackName, cramFile, indexFile = paste0(cramFile, ".crai"), deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE, trackHeight = NULL )loadCramTrackFromLocalData( session, id, trackName, cramFile, indexFile = paste0(cramFile, ".crai"), deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE, trackHeight = NULL ) loadCramTrackFromLocalFile( session, id, trackName, cramFile, indexFile = paste0(cramFile, ".crai"), deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE, trackHeight = NULL )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
cramFile |
character string, path to a cram file |
indexFile |
character string, path to its crai index, by default the cram file with ".crai" appended |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration
options, |
validateReference |
logical flag, default TRUE: checks track contigs against the active reference genome and emits warnings/toasts on mismatch. |
trackHeight |
numeric, track height in pixels (default: NULL, igv.js defaults to 300) |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
load a remote cram track
loadCramTrackFromURL( session, id, trackName, cramURL, indexURL, deleteTracksOfSameName = TRUE, trackConfig = list(), trackHeight = NULL )loadCramTrackFromURL( session, id, trackName, cramURL, indexURL, deleteTracksOfSameName = TRUE, trackConfig = list(), trackHeight = NULL )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
cramURL |
character string http url for the bam file, typically very large |
indexURL |
character string http url for the bam file index, typically small |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration
options, |
trackHeight |
numeric, track height in pixels (default: NULL, igv.js defaults to 300) |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
load a local GFF3 track file
loadGFF3TrackFromLocalData( session, id, trackName, tbl.gff3, color = "gray", colorTable, colorByAttribute, displayMode, trackHeight = 50, visibilityWindow, deleteTracksOfSameName = TRUE, trackConfig = list() )loadGFF3TrackFromLocalData( session, id, trackName, tbl.gff3, color = "gray", colorTable, colorByAttribute, displayMode, trackHeight = 50, visibilityWindow, deleteTracksOfSameName = TRUE, trackConfig = list() )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
tbl.gff3 |
data.frame in standard 9-column GFF3 format |
color |
character #RGB or a recognized color name. ignored if colorTable and colorByAttribute provided |
colorTable |
list, mapping a gff3 attribute, typically biotype, to a color |
colorByAttribute |
character, name of a gff3 attribute in column 9, typically "biotype" |
displayMode |
character, "EXPANDED", "SQUISHED" or "COLLAPSED" |
trackHeight |
numeric defaults to 50 |
visibilityWindow |
numeric, Maximum window size in base pairs for which indexed annotations or variants are displayed |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration options. |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "demos", "local-data.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "demos", "local-data.R") if (interactive()) { shiny::runApp(demo_app_file) }
load a remote GFF3 track
loadGFF3TrackFromURL( session, id, trackName, gff3URL, indexURL, color = "gray", colorTable, colorByAttribute, displayMode, trackHeight = 50, visibilityWindow, deleteTracksOfSameName = TRUE, trackConfig = list() )loadGFF3TrackFromURL( session, id, trackName, gff3URL, indexURL, color = "gray", colorTable, colorByAttribute, displayMode, trackHeight = 50, visibilityWindow, deleteTracksOfSameName = TRUE, trackConfig = list() )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
gff3URL |
character string http url for the bam file, typically very large |
indexURL |
character string http url for the bam file index, typically small |
color |
character #RGB or a recognized color name. ignored if colorTable and colorByAttribute provided |
colorTable |
list, mapping a gff3 attribute, typically biotype, to a color |
colorByAttribute |
character, name of a gff3 attribute in column 9, typically "biotype" |
displayMode |
character, "EXPANDED", "SQUISHED" or "COLLAPSED" |
trackHeight |
numeric defaults to 50 |
visibilityWindow |
numeric, Maximum window size in base pairs for which indexed annotations or variants are displayed |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration options. |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "demos", "local-data.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "demos", "local-data.R") if (interactive()) { shiny::runApp(demo_app_file) }
load a GWAS (genome-wide association study) track provided as a data.frame
loadGwasTrack( session, id, trackName, tbl.gwas, ymin = 0, ymax = 35, deleteTracksOfSameName = TRUE, trackConfig = list() )loadGwasTrack( session, id, trackName, tbl.gwas, ymin = 0, ymax = 35, deleteTracksOfSameName = TRUE, trackConfig = list() )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
tbl.gwas |
data.frame, with at least "chrom" "start" "end" columns |
ymin |
numeric defaults to 0 |
ymax |
numeric defaults to 35 |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration
options. A table whose headers igv.js does not recognize needs its layout
spelled out, 1-based, as
|
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
load a SEG track provided as a data.frame. igv "displays segmented data as a blue-to-red heatmap where the data range is -1.5 to 1.5... The segmented data file format is the output of the Circular Binary Segmentation algorithm (Olshen et al., 2004)".
loadSegTrack( session, id, trackName, tbl, deleteTracksOfSameName = TRUE, trackConfig = list() )loadSegTrack( session, id, trackName, tbl, deleteTracksOfSameName = TRUE, trackConfig = list() )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
tbl |
data.frame, with at least "chrom" "start" "end" "score" columns |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration options. |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
load splice junctions held in R. The table is written as the six-column bed igv.js draws junctions from, and served from the same directory as the other local-data tracks.
Coordinates are taken as bed coordinates and written out unchanged, as the
other *FromLocalData loaders take theirs. STAR reports the first and
last intron base of a junction 1-based in SJ.out.tab, so a table read
straight from that file needs its start shifted by one first; a bed already
converted from it, which is what STAR wrappers and the igv.js test fixtures
ship, is passed in as is.
Columns chrom (or chr), start and end are
required. score and strand are used when present. The
per-junction attributes motif, uniquely_mapped,
multi_mapped, maximum_spliced_alignment_overhang and
annotated_junction are packed into the bed name column, which is
where the track reads its filters and labels from; supply the ones you
want to filter or label on. A name column, if you have already
packed it yourself, is written through untouched.
Without uniquely_mapped or an explicit score the arcs all
draw at the same thickness: igv.js has nothing to size them by.
loadSpliceJunctionTrackFromLocalData( session, id, trackName, tbl, trackHeight = 100, displayMode = "COLLAPSED", deleteTracksOfSameName = TRUE, trackConfig = list() )loadSpliceJunctionTrackFromLocalData( session, id, trackName, tbl, trackHeight = 100, displayMode = "COLLAPSED", deleteTracksOfSameName = TRUE, trackConfig = list() )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
tbl |
data.frame, with at least "chrom" "start" "end" columns, in bed coordinates: a 0-based start and an exclusive end |
trackHeight |
an integer, 100 (pixels) by default |
displayMode |
character, "COLLAPSED", "EXPANDED" or "SQUISHED" |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration
options, the junction ones among them; see
|
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
load splice junctions from a BED file reachable by URL, as
written by STAR (SJ.out.tab converted to BED). Six columns, with the
per-junction attributes packed into the name column as key=value
pairs separated by semicolons: motif, uniquely_mapped,
multi_mapped, maximum_spliced_alignment_overhang and
annotated_junction. The track reads its filters and labels from
those attributes.
igv.js draws junctions from a file of that shape only - it derives none of them from a bam file, and it has no sashimi plot. Show this track above a coverage track (bigWig, bedGraph) for the same sample to get the arcs-over-coverage view sashimi plots are wanted for.
loadSpliceJunctionTrackFromURL( session, id, trackName, url, indexURL = "", trackHeight = 100, displayMode = "COLLAPSED", deleteTracksOfSameName = TRUE, trackConfig = list() )loadSpliceJunctionTrackFromURL( session, id, trackName, url, indexURL = "", trackHeight = 100, displayMode = "COLLAPSED", deleteTracksOfSameName = TRUE, trackConfig = list() )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
url |
character string http url for the bed file of junctions |
indexURL |
character string http url for a tabix index, needed only for a bgzipped bed; "" by default, which loads the file whole |
trackHeight |
an integer, 100 (pixels) by default |
displayMode |
character, "COLLAPSED", "EXPANDED" or "SQUISHED" |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration
options. The junction ones are read straight off it:
|
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
loadTrack is the one loader for every track class: it
turns track into a payload with the builder of its class and sends
it to the browser, removing an earlier track of the same name first.
Annotation tracks are served as a bed file, quantitative tracks travel
inline, exactly as with loadBedTrack and
loadBedGraphTrack.
track can also be a plain igv.js track configuration, a named list
with at least name, url and one of type or
format. It loads any track type igv.js reads from a url, e.g. a
bigBed file, without a dedicated loader. Keys igv.js does not read are
dropped with a warning, as with trackConfig; a trackConfig
passed with a config list is ignored with a logged warning.
loadTrack(session, id, track, ...) ## S4 method for signature 'Track' loadTrack(session, id, track, ...) ## S4 method for signature 'igvAnnotationTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'QuantitativeTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'GenomicAlignmentTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'RemoteAlignmentTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'CramTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'VariantTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'GFF3Track' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'BedpeInteractionsTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'GWASTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'list' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE )loadTrack(session, id, track, ...) ## S4 method for signature 'Track' loadTrack(session, id, track, ...) ## S4 method for signature 'igvAnnotationTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'QuantitativeTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'GenomicAlignmentTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'RemoteAlignmentTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'CramTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'VariantTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'GFF3Track' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'BedpeInteractionsTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'GWASTrack' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE ) ## S4 method for signature 'list' loadTrack( session, id, track, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
track |
an object of a Track subclass, e.g.
|
... |
arguments of the methods: |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration options |
validateReference |
logical flag, default TRUE |
nothing
tbl <- data.frame(chrom = "chr1", start = c(100, 300), end = c(200, 400), stringsAsFactors = FALSE) track <- DataFrameAnnotationTrack("demo", tbl, color = "red") if (interactive()) { # inside a shiny server function, with an igvShiny output "igvShiny_0": # loadTrack(session, "igvShiny_0", track) } # any igv.js track type from a url, here a bigBed file; nothing is # fetched until the browser draws the track bigBed <- list(name = "genes", type = "annotation", format = "bigBed", url = "https://example.org/genes.bb") if (interactive()) { # loadTrack(session, "igvShiny_0", bigBed) }tbl <- data.frame(chrom = "chr1", start = c(100, 300), end = c(200, 400), stringsAsFactors = FALSE) track <- DataFrameAnnotationTrack("demo", tbl, color = "red") if (interactive()) { # inside a shiny server function, with an igvShiny output "igvShiny_0": # loadTrack(session, "igvShiny_0", track) } # any igv.js track type from a url, here a bigBed file; nothing is # fetched until the browser draws the track bigBed <- list(name = "genes", type = "annotation", format = "bigBed", url = "https://example.org/genes.bb") if (interactive()) { # loadTrack(session, "igvShiny_0", bigBed) }
load a VCF (variant) track provided as a Bioconductor VariantAnnotation object
loadVcfTrack( session, id, trackName, vcfData, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE )loadVcfTrack( session, id, trackName, vcfData, deleteTracksOfSameName = TRUE, trackConfig = list(), validateReference = TRUE )
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackName |
character string |
vcfData |
VariantAnnotation object |
deleteTracksOfSameName |
logical, default TRUE |
trackConfig |
a named list of additional igv.js track configuration options. |
validateReference |
logical flag, default TRUE: checks track contigs against the active reference genome and emits warnings/toasts on mismatch. |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "demos", "local-data.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "demos", "local-data.R") if (interactive()) { shiny::runApp(demo_app_file) }
a helper function for internal use by the igvShiny constructor, but possible also of use to those building an igvShiny app, to test their genome specification for validity
parseAndValidateGenomeSpec( genomeName, initialLocus = "all", stockGenome = TRUE, dataMode = NA, fasta = NA, fastaIndex = NA, genomeAnnotation = NA )parseAndValidateGenomeSpec( genomeName, initialLocus = "all", stockGenome = TRUE, dataMode = NA, fasta = NA, fastaIndex = NA, genomeAnnotation = NA )
genomeName |
character usually one short code of a supported ("stock") genome (e.g., "hg38") or for a user-supplied custom genome, the name you wish to use |
initialLocus |
character default "all", otherwise "chrN:start-end" or a recognized gene symbol |
stockGenome |
logical default TRUE |
dataMode |
character either "stock", "localFile" or "http" |
fasta |
character when supplying a custom (non-stock) genome, either a file path or a URL |
fastaIndex |
character when supplying a custom (non-stock) genome, either a file path or a URL, essential for all but the very small custom genomes. |
genomeAnnotation |
character when supplying a custom (non-stock) genome, a file path or URL pointing to a genome annotation file in a gff3 format |
an options list directly usable by igvApp.js, and thus igv.js
[get_css_genomes()] for stock genomes we support.
genomeSpec <- parseAndValidateGenomeSpec("hg38", "APOE") # the simplest case # a custom genome, read from the files shipped with the package: every # resource is checked for existence, and "http" would check it over the # network on each R CMD check base.dir <- system.file(package = "igvShiny", "extdata", "sarsGenome") fasta.file <- file.path(base.dir, "Sars_cov_2.ASM985889v3.dna.toplevel.fa") fastaIndex.file <- paste0(fasta.file, ".fai") annotation.file <- file.path(base.dir, "Sars_cov_2.ASM985889v3.101.gff3") custom.genome.title <- "SARS-CoV-2" genomeOptions <- parseAndValidateGenomeSpec( genomeName = custom.genome.title, initialLocus = "all", stockGenome = FALSE, dataMode = "localFiles", fasta = fasta.file, fastaIndex = fastaIndex.file, genomeAnnotation = annotation.file )genomeSpec <- parseAndValidateGenomeSpec("hg38", "APOE") # the simplest case # a custom genome, read from the files shipped with the package: every # resource is checked for existence, and "http" would check it over the # network on each R CMD check base.dir <- system.file(package = "igvShiny", "extdata", "sarsGenome") fasta.file <- file.path(base.dir, "Sars_cov_2.ASM985889v3.dna.toplevel.fa") fastaIndex.file <- paste0(fasta.file, ".fai") annotation.file <- file.path(base.dir, "Sars_cov_2.ASM985889v3.101.gff3") custom.genome.title <- "SARS-CoV-2" genomeOptions <- parseAndValidateGenomeSpec( genomeName = custom.genome.title, initialLocus = "all", stockGenome = FALSE, dataMode = "localFiles", fasta = fasta.file, fastaIndex = fastaIndex.file, genomeAnnotation = annotation.file )
QuantitativeTrack adds y-axis scaling to
Track; it carries no data, so build tracks with its
subclasses: DataFrameQuantitativeTrack (a data.frame of chrom,
start, end, value in bedGraph coordinates), GRangesQuantitativeTrack
(a GRanges with exactly one numeric metadata column) and
UCSCBedGraphQuantitativeTrack (an rtracklayer UCSCData
imported from bedGraph, needs the suggested package rtracklayer). Display
one with loadTrack, which also sends
visibilityWindow to igv.js.
QuantitativeTrack( trackName, quantitativeData, fileFormat = c("wig", "bigWig", "bedGraph", "gwas"), color = "gray", sourceType = c("file", "url"), trackHeight = 50, autoscale = TRUE, min = NA_real_, max = NA_real_, visibilityWindow = 1e+05 ) DataFrameQuantitativeTrack( trackName, quantitativeData, color = "blue", trackHeight = 50, autoscale, min = NA_real_, max = NA_real_, visibilityWindow = 1e+05 ) GRangesQuantitativeTrack( trackName, quantitativeData, color = "blue", trackHeight = 50, autoscale = TRUE, min = NA_real_, max = NA_real_, visibilityWindow = 1e+05 ) UCSCBedGraphQuantitativeTrack( trackName, quantitativeData, color = "blue", trackHeight = 50, autoscale = TRUE, min = NA_real_, max = NA_real_, visibilityWindow = 1e+05 )QuantitativeTrack( trackName, quantitativeData, fileFormat = c("wig", "bigWig", "bedGraph", "gwas"), color = "gray", sourceType = c("file", "url"), trackHeight = 50, autoscale = TRUE, min = NA_real_, max = NA_real_, visibilityWindow = 1e+05 ) DataFrameQuantitativeTrack( trackName, quantitativeData, color = "blue", trackHeight = 50, autoscale, min = NA_real_, max = NA_real_, visibilityWindow = 1e+05 ) GRangesQuantitativeTrack( trackName, quantitativeData, color = "blue", trackHeight = 50, autoscale = TRUE, min = NA_real_, max = NA_real_, visibilityWindow = 1e+05 ) UCSCBedGraphQuantitativeTrack( trackName, quantitativeData, color = "blue", trackHeight = 50, autoscale = TRUE, min = NA_real_, max = NA_real_, visibilityWindow = 1e+05 )
trackName |
A character string, used as track label by igv; we recommend unique names per track |
quantitativeData |
the scored intervals; ignored by
|
fileFormat |
One of "wig", "bigWig", "bedGraph", "gwas" |
color |
A CSS color name (e.g., "red" or "#FF0000"), or "random" |
sourceType |
"file" or "url" |
trackHeight |
track height in pixels |
autoscale |
Autoscale track to maximum value in view |
min |
Sets the minimum value for the data (y-axis) scale |
max |
Sets the maximum value for the data (y-axis) scale; ignored if autoscale is TRUE |
visibilityWindow |
Maximum window size in base pairs for which data is displayed |
An object of the named class
autoscalelogical, scale the track to the maximum value in view
minnumeric, y-axis minimum, used when autoscale is FALSE
maxnumeric, y-axis maximum, used when autoscale is FALSE
coreObjectthe scores: data.frame, GRanges or UCSCData
tbl <- data.frame(chrom = "chr1", start = c(100, 200), end = c(200, 300), value = c(0.5, 2), stringsAsFactors = FALSE) track <- DataFrameQuantitativeTrack("bedGraph demo", tbl, autoscale = TRUE) gr <- GenomicRanges::GRanges(c("chr1:101-200", "chr1:201-300"), score = c(0.5, 2)) track2 <- GRangesQuantitativeTrack("GRanges demo", gr) trackSize(track2)tbl <- data.frame(chrom = "chr1", start = c(100, 200), end = c(200, 300), value = c(0.5, 2), stringsAsFactors = FALSE) track <- DataFrameQuantitativeTrack("bedGraph demo", tbl, autoscale = TRUE) gr <- GenomicRanges::GRanges(c("chr1:101-200", "chr1:201-300"), score = c(0.5, 2)) track2 <- GRangesQuantitativeTrack("GRanges demo", gr) trackSize(track2)
delete tracks on the browser
removeTracksByName(session, id, trackNames) ## S4 method for signature 'ANY' removeTracksByName(session, id, trackNames)removeTracksByName(session, id, trackNames) ## S4 method for signature 'ANY' removeTracksByName(session, id, trackNames)
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
trackNames |
a vector of character strings |
An S4 generic dispatching on session; the default method
(signature "ANY") sends the message through a shiny session.
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
remove only those tracks explicitly added by your app. stock tracks (i.e., #' Refseq Genes) remain
removeUserAddedTracks(session, id)removeUserAddedTracks(session, id)
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
nothing
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
This function is called in the server function of your shiny app
renderIgvShiny(expr, env = parent.frame(), quoted = FALSE)renderIgvShiny(expr, env = parent.frame(), quoted = FALSE)
expr |
an expression that generates an HTML widget |
env |
the environment in which to evaluate expr |
quoted |
logical flag indicating if expr a quoted expression |
an output or render function that enables the use of the widget within Shiny applications
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
Registers a local file with the active Shiny session so that igv.js
can stream chunks of the file using HTTP 206 Partial Content requests.
This allows random-access binary formats (such as BAM, BAI, CRAM, CRAI,
BigWig, and Tabix-indexed files) of arbitrary size to be viewed in igvShiny
without loading them into R memory or copying them to temporary directories.
serveLocalFile(session, filePath)serveLocalFile(session, filePath)
session |
Shiny session object (must be an active Shiny session) |
filePath |
character string, path to an existing, readable local file |
The returned URL is relative to the Shiny application root and is routed through the same HTTP port as the Shiny session, ensuring compatibility with Posit Connect, shinyapps.io, reverse proxies, and local development.
A character string containing the relative URL to access the file
from the browser (e.g. "session/<token>/dataobj/<filename>?...")
## Not run: # Inside a Shiny server function: server <- function(input, output, session) { bam_url <- serveLocalFile(session, "data/sample.bam") bai_url <- serveLocalFile(session, "data/sample.bam.bai") tracks <- list( list( name = "Sample BAM", type = "alignment", format = "bam", url = bam_url, indexURL = bai_url ) ) output$igv <- renderIgvShiny({ igvShiny(genomeOptions, tracks = tracks) }) } ## End(Not run)## Not run: # Inside a Shiny server function: server <- function(input, output, session) { bam_url <- serveLocalFile(session, "data/sample.bam") bai_url <- serveLocalFile(session, "data/sample.bam.bai") tracks <- list( list( name = "Sample BAM", type = "alignment", format = "bam", url = bam_url, indexURL = bai_url ) ) output$igv <- renderIgvShiny({ igvShiny(genomeOptions, tracks = tracks) }) } ## End(Not run)
Display a short summary of a GWASTrack object
## S4 method for signature 'GWASTrack' show(object)## S4 method for signature 'GWASTrack' show(object)
object |
An object of class GWASTrack |
nothing; called for the side effect of printing a summary
file <- system.file(package = "igvShiny", "extdata", "gwas-5k.tsv.gz") tbl.gwas <- read.table(file, sep = "\t", header = TRUE, quote = "") track <- GWASTrack("gwas 5k", tbl.gwas, chrom.col = 12, pos.col = 13, pval.col = 28) trackfile <- system.file(package = "igvShiny", "extdata", "gwas-5k.tsv.gz") tbl.gwas <- read.table(file, sep = "\t", header = TRUE, quote = "") track <- GWASTrack("gwas 5k", tbl.gwas, chrom.col = 12, pos.col = 13, pval.col = 28) track
One method for the whole Track hierarchy:
class, name, type, format, source and, when the track holds data, its size.
## S4 method for signature 'Track' show(object)## S4 method for signature 'Track' show(object)
object |
a |
nothing; called for the side effect of printing a summary
DataFrameAnnotationTrack("demo", data.frame(chr = "chr1", start = 10, end = 20))DataFrameAnnotationTrack("demo", data.frame(chr = "chr1", start = 10, end = 20))
zoom in or out to show the nominated region, by chromosome locus or gene symbol
return the current region displayed by your igv instance
showGenomicRegion(session, id, region) ## S4 method for signature 'ANY' showGenomicRegion(session, id, region) getGenomicRegion(session, id) ## S4 method for signature 'ANY' getGenomicRegion(session, id)showGenomicRegion(session, id, region) ## S4 method for signature 'ANY' showGenomicRegion(session, id, region) getGenomicRegion(session, id) ## S4 method for signature 'ANY' getGenomicRegion(session, id)
session |
an environment or list, provided and managed by shiny |
id |
character string, the html element id of this widget instance |
region |
a character string, either e.g. "chr5:92,221,640-92,236,523" or "MEF2C" |
showGenomicRegion, getGenomicRegion and
removeTracksByName are S4 generics dispatching on their first
argument. The default method (signature "ANY") handles a shiny
session (a ShinySession, a module session_proxy or any
object with a sendCustomMessage method), so packages that build on
igvShiny can add methods for their own classes without masking these
functions.
a character string of format "chrom:start-end"
library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) } library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) } library(igvShiny) demo_app_file <- system.file(package = "igvShiny", "showcase", "igvShinyDemo.R") if (interactive()) { shiny::runApp(demo_app_file) }
Track holds the slots every igv.js track shares. It is
the parent of igvAnnotationTrack and
QuantitativeTrack; build tracks with their subclass
constructors, e.g. DataFrameAnnotationTrack, and display them
with loadTrack.
Track( trackType = c("annotation", "quantitative", "alignment", "variant", "gwas", "genomicAlignment", "remoteAlignment", "pairedEndAnnotation"), sourceType = c("file", "url", "gcs", "ga4gh"), fileFormat = c("bed", "gff", "gff3", "gtf", "wig", "bigWig", "bedGraph", "bam", "vcf", "seg", "gwas", "cram", "bedpe"), trackName, onScreenOrder = NA_real_, color = "gray", height = 50, autoTrackHeight = FALSE, minTrackHeight = 50, maxTrackHeight = 500, visibilityWindow = 1e+05 )Track( trackType = c("annotation", "quantitative", "alignment", "variant", "gwas", "genomicAlignment", "remoteAlignment", "pairedEndAnnotation"), sourceType = c("file", "url", "gcs", "ga4gh"), fileFormat = c("bed", "gff", "gff3", "gtf", "wig", "bigWig", "bedGraph", "bam", "vcf", "seg", "gwas", "cram", "bedpe"), trackName, onScreenOrder = NA_real_, color = "gray", height = 50, autoTrackHeight = FALSE, minTrackHeight = 50, maxTrackHeight = 500, visibilityWindow = 1e+05 )
trackType |
One of "annotation", "quantitative", "alignment", "variant", "gwas", "genomicAlignment", "remoteAlignment", "pairedEndAnnotation" |
sourceType |
One of "file", "url", "gcs", "ga4gh" |
fileFormat |
One of "bed", "gff", "gff3", "gtf", "wig", "bigWig", "bedGraph", "bam", "vcf", "seg", "gwas", "cram", "bedpe" |
trackName |
A character string, used as track label by igv; we recommend unique names per track |
onScreenOrder |
Numeric, for explicit placement of track within the current set |
color |
A CSS color name (e.g., "red" or "#FF0000"), or "random" |
height |
track height in pixels |
autoTrackHeight |
If TRUE, track height is adjusted dynamically, within the bounds set by minTrackHeight and maxTrackHeight |
minTrackHeight |
In pixels, minimum allowed |
maxTrackHeight |
In pixels, maximum allowed |
visibilityWindow |
Maximum window size in base pairs for which indexed annotations or variants are displayed |
An object of class Track
trackTypecharacter, e.g. "annotation" or "quantitative"
sourceTypecharacter, e.g. "file" or "url"
fileFormatcharacter, e.g. "bed" or "bedGraph"
trackNamecharacter, the track label
onScreenOrdernumeric, explicit placement of the track
colorcharacter, a CSS color
heightnumeric, track height in pixels
autoTrackHeightlogical; stored, not sent to igv.js yet
minTrackHeightnumeric, pixels; stored, not sent to igv.js yet
maxTrackHeightnumeric, pixels; stored, not sent to igv.js yet
visibilityWindownumeric, base pairs; sent to igv.js by the
annotation and quantitative loadTrack methods (NA: not sent)
https://igv.org/doc/igvjs/#tracks/Tracks/
track <- Track(trackType = "annotation", sourceType = "file", fileFormat = "bed", trackName = "demo", color = "red") trackInfo(track)track <- Track(trackType = "annotation", sourceType = "file", fileFormat = "bed", trackName = "demo", color = "red") trackInfo(track)
Basic facts about a track
trackInfo(obj) trackSize(obj) ## S4 method for signature 'Track' trackInfo(obj) ## S4 method for signature 'Track' trackSize(obj) ## S4 method for signature 'GenomicAlignmentTrack' trackSize(obj) ## S4 method for signature 'VariantTrack' trackSize(obj) ## S4 method for signature 'GFF3Track' trackSize(obj)trackInfo(obj) trackSize(obj) ## S4 method for signature 'Track' trackInfo(obj) ## S4 method for signature 'Track' trackSize(obj) ## S4 method for signature 'GenomicAlignmentTrack' trackSize(obj) ## S4 method for signature 'VariantTrack' trackSize(obj) ## S4 method for signature 'GFF3Track' trackSize(obj)
obj |
An object of base class Track |
trackInfo: a list with trackType, fileFormat, source and
class. trackSize: the number of features, or NA when the
track holds no data of its own
tbl <- data.frame(chrom = "chr1", start = c(100, 300), end = c(200, 400), stringsAsFactors = FALSE) track <- DataFrameAnnotationTrack("demo", tbl) trackInfo(track) trackSize(track)tbl <- data.frame(chrom = "chr1", start = c(100, 300), end = c(200, 400), stringsAsFactors = FALSE) track <- DataFrameAnnotationTrack("demo", tbl) trackInfo(track) trackSize(track)
A VariantTrack holds a VCF object (needs the
suggested package VariantAnnotation), written to a vcf file at display
time, or the urls of a served vcf and its index. Display it with
loadTrack, which sends color (from anchorColor),
the three genotype colors, displayMode, trackHeight (as height) and
visibilityWindow to igv.js. Url tracks have no igvShiny browser handler
yet, so loadTrack refuses them.
VariantTrack( trackName, vcf, trackHeight = 50, anchorColor = "pink", homvarColor = "rgb(17,248,254)", hetvarColor = "rgb(34,12,253)", homrefColor = "rgb(200,200,200)", displayMode = "EXPANDED", visibilityWindow = 1e+05 )VariantTrack( trackName, vcf, trackHeight = 50, anchorColor = "pink", homvarColor = "rgb(17,248,254)", hetvarColor = "rgb(34,12,253)", homrefColor = "rgb(200,200,200)", displayMode = "EXPANDED", visibilityWindow = 1e+05 )
trackName |
A character string, used as track label by igv |
vcf |
a |
trackHeight |
track height in pixels |
anchorColor |
CSS color of the variant row |
homvarColor |
CSS color of homozygous variant genotypes |
hetvarColor |
CSS color of heterozygous variant genotypes |
homrefColor |
CSS color of homozygous reference genotypes |
displayMode |
"COLLAPSED", "SQUISHED" or "EXPANDED" |
visibilityWindow |
Maximum window size in base pairs for which variants are displayed |
An object of class VariantTrack
displayModecharacter, "COLLAPSED", "SQUISHED" or "EXPANDED"
vcf.obja VCF object, or NULL for a url track
vcf.urllist with the urls data and index, or empty
anchorColorcharacter, the variant color
homvarColorcharacter, homozygous variant genotype color
hetvarColorcharacter, heterozygous variant genotype color
homrefColorcharacter, homozygous reference genotype color
if (requireNamespace("VariantAnnotation", quietly = TRUE)) { f <- system.file(package = "igvShiny", "extdata", "chr19-cebpaRegion.vcf.gz") vcf <- VariantAnnotation::readVcf(f, "hg38") track <- VariantTrack("cebpa variants", vcf) trackSize(track) }if (requireNamespace("VariantAnnotation", quietly = TRUE)) { f <- system.file(package = "igvShiny", "extdata", "chr19-cebpaRegion.vcf.gz") vcf <- VariantAnnotation::readVcf(f, "hg38") track <- VariantTrack("cebpa variants", vcf) trackSize(track) }