| Title: | Genomic Track Visualization and Haplotype Analysis |
|---|---|
| Description: | Provides tools to read, validate, query, transform, write, and visualize gene annotations, genomic signal tracks, and variant tracks using a shared genomic coordinate framework. Supports GenePred, GTF, GFF3, and BED annotations; bedGraph, wig, and bigWig signals; VCF variants; integrated locus visualization; haplotype construction; phenotype association; linkage disequilibrium; haplotype refinement; and variant-effect analysis. The package interoperates with GenomicRanges objects and uses a pure-R signal I/O layer so core workflows do not require a compiled extension. |
| Authors: | Shuchao Ren [aut, cre] |
| Maintainer: | Shuchao Ren <[email protected]> |
| License: | GPL-3 |
| Version: | 0.99.2 |
| Built: | 2026-10-01 12:58:21 UTC |
| Source: | https://github.com/BiocStaging/GeneTrackR |
Extract exon table from a GenePred object
as_exon_table(object)as_exon_table(object)
object |
A GenePred object. |
A data.table with exon-level annotation.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) head(as_exon_table(gp))gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) head(as_exon_table(gp))
Coerce an annotation object to a unified Feature object
as_feature(object) ## S3 method for class 'Feature' as_feature(object) ## S3 method for class 'FeatureTrack' as_feature(object) ## S3 method for class 'GenePred' as_feature(object) ## S3 method for class 'data.frame' as_feature(object)as_feature(object) ## S3 method for class 'Feature' as_feature(object) ## S3 method for class 'FeatureTrack' as_feature(object) ## S3 method for class 'GenePred' as_feature(object) ## S3 method for class 'data.frame' as_feature(object)
object |
A GenePred, FeatureTrack, or data.frame-like object. |
A Feature object.
x <- data.frame(chrom = "chr1", start = 1L, end = 100L) as_feature(x) gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) feature <- as_feature(gp) featurex <- data.frame(chrom = "chr1", start = 1L, end = 100L) as_feature(x) gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) feature <- as_feature(gp) feature
Extract the standardized feature table
as_feature_table(object)as_feature_table(object)
object |
A Feature, FeatureTrack, or GenePred object. |
A data.table with standardized feature columns.
x <- Feature(data.frame(chrom = "chr1", start = 1L, end = 100L)) as_feature_table(x)x <- Feature(data.frame(chrom = "chr1", start = 1L, end = 100L)) as_feature_table(x)
Extract gene table from a GenePred object
as_gene_table(object)as_gene_table(object)
object |
A GenePred object. |
A data.table with gene-level annotation.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) head(as_gene_table(gp))gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) head(as_gene_table(gp))
Convert a Feature object with gene-model information to GenePred
as_genepred(object)as_genepred(object)
object |
A Feature object containing transcript and exon features. |
A GenePred object.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) as_genepred(gp)gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) as_genepred(gp)
Converts GeneTrackR annotation, signal, and variant objects to
GenomicRanges::GRanges so they can be used directly with Bioconductor
genomic interval infrastructure. Annotation objects support gene,
transcript, exon, and feature levels. In-memory BwgTrack objects expose
sample_id and signal score metadata, while VariantTrack objects retain
their VCF-derived metadata columns. Lazy signal or variant objects should be
retrieved by genomic region before conversion.
as_granges(object, level = c("gene", "transcript", "exon", "feature"))as_granges(object, level = c("gene", "transcript", "exon", "feature"))
object |
A GenePred, Feature, FeatureTrack, BwgTrack, or VariantTrack object. |
level |
Annotation feature level. One of |
A GenomicRanges::GRanges object.
gp_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") gp <- read_genepred(gp_file, format = "genePredExt", verbose = FALSE) as_granges(gp, level = "gene") signal <- BwgTrack( samples = data.frame(sample_id = "sampleA"), data = data.frame( sample_id = "sampleA", chrom = "chr1", start = 10L, end = 12L, value = 1.5, strand = "*" ) ) as_granges(signal) vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) as_granges(vcf)gp_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") gp <- read_genepred(gp_file, format = "genePredExt", verbose = FALSE) as_granges(gp, level = "gene") signal <- BwgTrack( samples = data.frame(sample_id = "sampleA"), data = data.frame( sample_id = "sampleA", chrom = "chr1", start = 10L, end = 12L, value = 1.5, strand = "*" ) ) as_granges(signal) vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) as_granges(vcf)
Extract transcript table from a GenePred object
as_transcript_table(object)as_transcript_table(object)
object |
A GenePred object. |
A data.table with transcript-level annotation.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) head(as_transcript_table(gp))gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) head(as_transcript_table(gp))
Test whether a bedGraph tabix query returns records without full-file fallback
benchmark_tabix_query(object, chrom, start, end, samples = NULL)benchmark_tabix_query(object, chrom, start, end, samples = NULL)
object |
A BwgTrack object. |
chrom |
Chromosome name. |
start |
Region start. |
end |
Region end. |
samples |
Optional sample IDs. |
A data.table with per-sample query timing and number of records.
signal_file <- system.file( "extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR" ) signal <- read_bwg( signal_file, format = "bedgraph", sample_names = "RNA_plus", strand = "+", mode = "lazy", verbose = FALSE ) benchmark_tabix_query(signal, "chr1", 12339001L, 12340000L)signal_file <- system.file( "extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR" ) signal <- read_bwg( signal_file, format = "bedgraph", sample_names = "RNA_plus", strand = "+", mode = "lazy", verbose = FALSE ) benchmark_tabix_query(signal, "chr1", 12339001L, 12340000L)
Bin signal tracks into fixed-width windows
bin_bwg(data, bin_size = 50L)bin_bwg(data, bin_size = 50L)
data |
Signal table returned by retrieve_bwg. The table must contain |
bin_size |
Bin size in bases. |
A binned signal table.
rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) dt <- retrieve_bwg( rnaseq, chrom = "chr1", start = 12339001, end = 12352000, strand = "+" ) bin_bwg(dt, bin_size = 50)rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) dt <- retrieve_bwg( rnaseq, chrom = "chr1", start = 12339001, end = 12352000, strand = "+" ) bin_bwg(dt, bin_size = 50)
Creates a standardized BwgTrack object. GeneTrackR schema version 2 keeps
sample metadata, optional in-memory signal records, optional chromosome
metadata, object metadata, and validation results in stable named slots.
Public signal coordinates use 1-based closed intervals.
BwgTrack( samples, data = NULL, meta = list(), validation = make_empty_validation(), seqinfo = NULL )BwgTrack( samples, data = NULL, meta = list(), validation = make_empty_validation(), seqinfo = NULL )
samples |
Sample metadata table containing |
data |
Optional in-memory signal table. |
meta |
Metadata list. |
validation |
Validation result list. |
seqinfo |
Optional chromosome metadata containing |
A BwgTrack object with samples, data, seqinfo, meta, and
validation slots.
samples <- data.frame(sample_id = "sample1") BwgTrack(samples)samples <- data.frame(sample_id = "sample1") BwgTrack(samples)
Calculates pairwise LD for variants in a genomic region. Genotypes are parsed
from the sample columns preserved by read_vcf(..., keep_genotype = TRUE).
The current implementation uses genotype dosage, where 0 is homozygous
reference, 1 is heterozygous/non-reference carrier, and 2 is homozygous
alternate for diploid biallelic records. Multi-allelic non-reference alleles
are collapsed into total non-reference dosage.
compute_ld_block( vcf, chrom = NULL, start = NULL, end = NULL, variant_type = c("both", "snp", "ind"), method = c("r2", "Dprime"), samples = NULL, min_pair_samples = 3L, ploidy = 2L, keep_genotype_matrix = FALSE, verbose = TRUE )compute_ld_block( vcf, chrom = NULL, start = NULL, end = NULL, variant_type = c("both", "snp", "ind"), method = c("r2", "Dprime"), samples = NULL, min_pair_samples = 3L, ploidy = 2L, keep_genotype_matrix = FALSE, verbose = TRUE )
vcf |
A |
chrom |
Chromosome. If NULL, a single-chromosome in-memory VCF uses its full chromosome range. |
start |
Region start. If NULL, the minimum retained variant position is used. |
end |
Region end. If NULL, the maximum retained variant position is used. |
variant_type |
One of |
method |
LD value used as the primary |
samples |
Optional sample names to keep. |
min_pair_samples |
Minimum number of paired non-missing samples required for a pairwise estimate. |
ploidy |
Ploidy used for dosage-based allele-frequency and Dprime approximation. Default is 2. |
keep_genotype_matrix |
Logical. Whether to store the variant-by-sample dosage matrix in the returned object. |
verbose |
Logical. Whether to print progress messages. |
An LDTrack object.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) ld <- compute_ld_block( vcf, chrom = "chr1", start = 12342620, end = 12355500, variant_type = "snp", method = "r2", verbose = FALSE ) ld$datavcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) ld <- compute_ld_block( vcf, chrom = "chr1", start = 12342620, end = 12355500, variant_type = "snp", method = "r2", verbose = FALSE ) ld$data
Diagnose tabix availability for bedGraph tracks
diagnose_tabix(object)diagnose_tabix(object)
object |
A BwgTrack object created by |
A data.table reporting index presence, backend availability, and whether indexed querying is enabled.
rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "lazy", verbose = FALSE ) diagnose_tabix(rnaseq)rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "lazy", verbose = FALSE ) diagnose_tabix(rnaseq)
Feature() is the unified annotation class used by GeneTrackR. BED, GFF,
GTF, and GenePred annotations are all normalized to a Feature-compatible
object with a flat interval table in object$data. GenePred-compatible
inputs additionally store derived genes, transcripts, and exons tables,
allowing the same object to be used by gene model plotting functions.
Required coordinate convention is 1-based closed intervals.
Feature( data, meta = list(), genes = NULL, transcripts = NULL, exons = NULL, validation = make_empty_validation() )Feature( data, meta = list(), genes = NULL, transcripts = NULL, exons = NULL, validation = make_empty_validation() )
data |
A data.frame or data.table containing standardized interval columns.
Required columns are |
meta |
Metadata list such as source file, original format, and coordinate system. |
genes |
Optional gene-level table. |
transcripts |
Optional transcript-level table. |
exons |
Optional exon-level table. |
validation |
Optional validation list. |
A Feature object, also inheriting from FeatureTrack.
x <- data.frame(chrom = "chr1", start = 1L, end = 100L) Feature(x)x <- data.frame(chrom = "chr1", start = 1L, end = 100L) Feature(x)
FeatureTrack() is kept as a user-facing alias of Feature() for interval
tracks. It returns an object inheriting from both Feature and FeatureTrack.
FeatureTrack( data, meta = list(), genes = NULL, transcripts = NULL, exons = NULL, validation = make_empty_validation() )FeatureTrack( data, meta = list(), genes = NULL, transcripts = NULL, exons = NULL, validation = make_empty_validation() )
data |
A data.frame or data.table containing standardized interval columns.
Required columns are |
meta |
Metadata list such as source file, original format, and coordinate system. |
genes |
Optional gene-level table. |
transcripts |
Optional transcript-level table. |
exons |
Optional exon-level table. |
validation |
Optional validation list. |
A Feature object inheriting from FeatureTrack.
x <- data.frame(chrom = "chr1", start = 1L, end = 100L) FeatureTrack(x)x <- data.frame(chrom = "chr1", start = 1L, end = 100L) FeatureTrack(x)
Create a GenePred object
GenePred( transcripts, exons, genes = NULL, meta = list(), validation = make_empty_validation() )GenePred( transcripts, exons, genes = NULL, meta = list(), validation = make_empty_validation() )
transcripts |
Transcript-level annotation table. |
exons |
Exon-level annotation table. |
genes |
Gene-level annotation table. |
meta |
Metadata list. |
validation |
Validation result list. |
A GenePred object.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) GenePred(gp$transcripts, gp$exons, gp$genes)gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) GenePred(gp$transcripts, gp$exons, gp$genes)
This help topic summarizes frequently used advanced parameters that are shared by several GeneTrackR functions. It is intended as a quick reference for custom colors, highlighted intervals, signal transformations, sample grouping, and strand handling.
No value is returned; this is a documentation-only help topic.
Gene model functions such as plot_gene(), plot_transcript(), and
plot_region() use gene_palette and gene_colors for exon/CDS/UTR fills.
gene_palette accepts any palette from RColorBrewer::brewer.pal.info. If
the number of discrete groups exceeds the palette limit, colors are
interpolated automatically.
gene_colors can be either unnamed or named. For gene models, the most stable
named form is:
gene_colors = c( CDS = "#33a02c", UTR = "#b2df8a", exon = "#fb9a99" )
Unnamed colors are matched to the fixed gene-model levels UTR, CDS, and exon, so colors remain stable even when a plot contains only one feature type.
highlight must be a data frame with at least start and end columns:
highlight = data.frame(start = 105000, end = 106000)
In genomic plots, start and end are genomic coordinates. In transcript
coordinate plots, they are spliced transcript coordinates.
Signal plotting functions use signal_palette, signal_palette_direction, signal_colors,
sample_groups, and signal_color_by.
signal_palette = "YlGnBu" signal_palette_direction = -1 signal_colors = c(sampleA = "#2166AC", sampleB = "#B2182B")
signal_palette_direction reverses the standard discrete palette order. Discrete
sample/group/frame colors otherwise follow the RColorBrewer class order exactly,
while heatmaps use a continuous gradient. Explicit signal_colors are treated
as exact user mappings and are not reversed.
Group-level coloring is controlled by a named vector or a two-column data frame:
sample_groups = c(KO1 = "KO", KO2 = "KO", WT1 = "WT", WT2 = "WT") signal_color_by = "group"
Signal plots support transformed values and per-sample or shared y-axis ranges:
signal_transform = "sqrt" # none, log2, log10, or sqrt signal_y_scale = "fixed" # free or fixed signal_y_ticks = "range" # range or pretty signal_y_limits = c(0, 20) # limits after signal_transform
signal_y_ticks = "range" displays integer y-axis limits only.
Supplying signal_y_limits changes signal_y_scale to "fixed".
Standard track panels use plot_theme, show_panel_border, and black text.
Signal geometry can be adjusted with signal_alpha and
signal_bar_width:
plot_theme = "classic" # bw, classic, light, or minimal show_panel_border = FALSE signal_alpha = 0.80 signal_bar_width = 0.85 signal_track_height = 4 gene_track_height = 1
signal_track_height and gene_track_height control the relative panel
heights in plot_signal_transcript(), plot_signal_gene(), and
plot_signal_region(). plot_tracks() uses its named heights vector for
the same purpose.
signal_bar_width is relative to each BedGraph interval. It changes the
visual bar width around the interval center without changing genomic
positions.
Standard bigWig and wig tracks are unstranded. For such tracks,
strand_policy = "ignore_unstranded" lets strand = "+" or "-" return the
same unstranded signal. Use strand_policy = "strict" when you only want
records with explicit strand information, such as plus/minus bedGraph tracks.
plot_gene(), plot_transcript(), plot_region(),
plot_signal_gene(), plot_signal_transcript(), plot_signal_region(),
plot_tracks(), retrieve_bwg(), read_bwg()
GeneTrackR ships a small deterministic genomic dataset under
inst/extdata. The files support executable examples, tests, and
vignettes without downloading external data.
No value is returned; this is a documentation-only help topic.
The installed extdata directory contains:
gtr_demo.genePredExt, gtr_demo.gtf, and gtr_demo.gff3 for the same
deterministic gene annotation;
gtr_demo_features.bed for genomic interval features;
gtr_demo_variants.vcf for designed variant and genotype patterns;
gtr_demo_pheno.tsv for deterministic phenotypes;
gtr_demo.chrom.sizes for chromosome lengths; and
plus/minus RNA-seq and Ribo-seq gtr_demo_*bedgraph signal tracks.
The dataset is synthetic and deterministic. Canonical source tables are
stored under inst/scripts/demo_model in the source package.
inst/scripts/generate_demo_data.R generates the installed gtr_demo_*
files and inst/scripts/validate_demo_data.R validates their designed
dimensions and relationships. No external biological dataset is bundled.
Canonical source tables use 1-based closed coordinates. Format-specific output follows the conventions of GenePredExt, BED, bedGraph, GTF, GFF3, and VCF, and GeneTrackR readers convert those inputs to their documented internal coordinate representation.
system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR")system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR")
Build a tidy feature-length table from a Feature/GenePred-compatible annotation object. The function supports gene spans, transcript lengths, exon lengths, CDS lengths, total UTR lengths, 5' UTR lengths, and 3' UTR lengths. CDS and UTR lengths can be summarized per transcript or returned as individual genomic segments.
get_gene_length_distribution_table( object, feature = c("all", "gene", "transcript", "exon", "cds", "utr", "five_utr", "three_utr"), unit = c("auto", "transcript", "segment"), transcript_length = c("spliced", "genomic"), chrom = NULL, start = NULL, end = NULL, mode = c("overlap", "within", "trim"), keep_zero = FALSE ) get_genepred_length_table(...)get_gene_length_distribution_table( object, feature = c("all", "gene", "transcript", "exon", "cds", "utr", "five_utr", "three_utr"), unit = c("auto", "transcript", "segment"), transcript_length = c("spliced", "genomic"), chrom = NULL, start = NULL, end = NULL, mode = c("overlap", "within", "trim"), keep_zero = FALSE ) get_genepred_length_table(...)
object |
A Feature or GenePred-compatible annotation object. |
feature |
Feature type to extract. Use |
unit |
Output unit. |
transcript_length |
Transcript length definition. |
chrom |
Optional chromosome filter. |
start |
Optional region start in 1-based closed coordinates. |
end |
Optional region end in 1-based closed coordinates. |
mode |
Region selection mode passed to |
keep_zero |
Logical. Whether to keep zero-length transcript-level CDS/UTR
records. Default is |
... |
Deprecated compatibility arguments forwarded by
|
Use unit = "segment" to inspect each exon/CDS/UTR segment separately,
and unit = "transcript" to summarize feature lengths per transcript.
transcript_length = "spliced" uses exon lengths, whereas "genomic"
uses transcript span length including introns.
A data.table with feature-length records.
gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) get_gene_length_distribution_table(gp, feature = "cds", unit = "transcript")gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) get_gene_length_distribution_table(gp, feature = "cds", unit = "transcript")
Extracts variants for a specified gene or transcript, optionally including upstream and downstream flanking regions, and converts sample genotype profiles into haplotypes.
hap_gene_variant( vcf, annotation, gene_id = NULL, transcript_id = NULL, upstream = 0L, downstream = 0L, strand_aware = TRUE, samples = NULL, variant_type = NULL, genotype_mode = c("code", "string"), missing_genotype = NA_character_, min_variant_number = NULL )hap_gene_variant( vcf, annotation, gene_id = NULL, transcript_id = NULL, upstream = 0L, downstream = 0L, strand_aware = TRUE, samples = NULL, variant_type = NULL, genotype_mode = c("code", "string"), missing_genotype = NA_character_, min_variant_number = NULL )
vcf |
A VariantTrack object or VCF file path. |
annotation |
A gene annotation object used to locate |
gene_id |
Optional gene ID. Use exactly one of |
transcript_id |
Optional transcript ID. Use exactly one of |
upstream |
Upstream flanking length in bp. When |
downstream |
Downstream flanking length in bp. When |
strand_aware |
Logical. Whether upstream/downstream should follow strand direction. Default TRUE. |
samples |
Optional sample names to keep. |
variant_type |
Optional variant types to keep. |
genotype_mode |
Genotype representation. |
missing_genotype |
Missing genotype label. Default is |
min_variant_number |
Minimum number of non-missing variants required for a sample. If NULL, only samples with complete non-missing genotypes across all retained variants are kept. |
A HapVariant object.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_gene_variant( vcf, annotation = anno, gene_id = "GeneA", upstream = 1000, downstream = 500, min_variant_number = 1 ) hap hap$haplotypes hap_tx <- hap_gene_variant( vcf, annotation = anno, transcript_id = "TxA1", genotype_mode = "string", min_variant_number = 1 ) hap_tx$haplotypesvcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_gene_variant( vcf, annotation = anno, gene_id = "GeneA", upstream = 1000, downstream = 500, min_variant_number = 1 ) hap hap$haplotypes hap_tx <- hap_gene_variant( vcf, annotation = anno, transcript_id = "TxA1", genotype_mode = "string", min_variant_number = 1 ) hap_tx$haplotypes
Extracts variants from a user-defined genomic interval and converts sample genotype profiles into haplotypes.
hap_region_variant( vcf, chrom, start, end, samples = NULL, variant_type = NULL, genotype_mode = c("code", "string"), missing_genotype = NA_character_, min_variant_number = NULL )hap_region_variant( vcf, chrom, start, end, samples = NULL, variant_type = NULL, genotype_mode = c("code", "string"), missing_genotype = NA_character_, min_variant_number = NULL )
vcf |
A VariantTrack object or VCF file path. |
chrom |
Chromosome name. |
start |
Region start in 1-based closed coordinates. |
end |
Region end in 1-based closed coordinates. |
samples |
Optional sample names to keep. |
variant_type |
Optional variant types to keep. |
genotype_mode |
Genotype representation. |
missing_genotype |
Missing genotype label. Default is |
min_variant_number |
Minimum number of non-missing variants required for a sample. If NULL, only samples with complete non-missing genotypes across all retained variants are kept. |
A HapVariant object.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) hap <- hap_region_variant( vcf, chrom = "chr1", start = 12339700, end = 12352000, genotype_mode = "code", min_variant_number = 1 ) hap hap$haplotypesvcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) hap <- hap_region_variant( vcf, chrom = "chr1", start = 12339700, end = 12352000, genotype_mode = "code", min_variant_number = 1 ) hap hap$haplotypes
Compatibility wrapper for haplotype construction. For new code, prefer
hap_gene_variant() for gene/transcript queries and hap_region_variant()
for direct genomic interval queries.
hap_variant( vcf, annotation = NULL, gene_id = NULL, transcript_id = NULL, chrom = NULL, start = NULL, end = NULL, upstream = 0L, downstream = 0L, strand_aware = TRUE, samples = NULL, variant_type = NULL, genotype_mode = c("code", "string"), missing_genotype = NA_character_, min_variant_number = NULL )hap_variant( vcf, annotation = NULL, gene_id = NULL, transcript_id = NULL, chrom = NULL, start = NULL, end = NULL, upstream = 0L, downstream = 0L, strand_aware = TRUE, samples = NULL, variant_type = NULL, genotype_mode = c("code", "string"), missing_genotype = NA_character_, min_variant_number = NULL )
vcf |
A VariantTrack object or VCF file path. |
annotation |
Optional gene annotation object used for |
gene_id |
Optional gene ID. |
transcript_id |
Optional transcript ID. |
chrom |
Optional chromosome name. |
start |
Optional region start in 1-based closed coordinates. |
end |
Optional region end in 1-based closed coordinates. |
upstream |
Upstream flanking length in bp for gene/transcript queries. |
downstream |
Downstream flanking length in bp for gene/transcript queries. |
strand_aware |
Logical. Whether upstream/downstream should follow strand direction. Default TRUE. |
samples |
Optional sample names to keep. |
variant_type |
Optional variant types to keep. |
genotype_mode |
Genotype representation. |
missing_genotype |
Missing genotype label. Default is |
min_variant_number |
Minimum number of non-missing variants required for a sample. If NULL, only samples with complete non-missing genotypes across all retained variants are kept. |
A HapVariant object.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "code", min_variant_number = 1 ) hap hap_region <- hap_variant( vcf, chrom = "chr1", start = 12339700, end = 12352000, min_variant_number = 1 ) hap_region$haplotypesvcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "code", min_variant_number = 1 ) hap hap_region <- hap_variant( vcf, chrom = "chr1", start = 12339700, end = 12352000, min_variant_number = 1 ) hap_region$haplotypes
Show the first rows of a BwgTrack object
## S3 method for class 'BwgTrack' head(x, n = 6L, ...)## S3 method for class 'BwgTrack' head(x, n = 6L, ...)
x |
A BwgTrack object. |
n |
Number of rows to show. |
... |
Additional arguments. |
Invisibly returns the input object.
LDTrack() stores pairwise linkage disequilibrium results, retained variant
metadata, the selected genomic region, and optionally the dosage matrix and
the generated figure. It follows the same lightweight S3 list-class style used
by VariantTrack and HapVariant.
LDTrack( data = NULL, matrix = NULL, variants = NULL, region = list(), genotype = NULL, figure = NULL, meta = list(), plot = NULL )LDTrack( data = NULL, matrix = NULL, variants = NULL, region = list(), genotype = NULL, figure = NULL, meta = list(), plot = NULL )
data |
A data.frame/data.table of pairwise LD statistics. |
matrix |
A symmetric LD matrix. Diagonal values are usually 1. |
variants |
Variant metadata used in the calculation. |
region |
A list with |
genotype |
Optional numeric genotype dosage matrix. |
figure |
Optional figure object produced by |
meta |
A metadata list. |
plot |
Deprecated alias for |
An LDTrack object.
LDTrack(region = list(chrom = "chr1", start = 1L, end = 100L))LDTrack(region = list(chrom = "chr1", start = 1L, end = 100L))
Merge signal track objects
merge_bwg( ..., sample_conflict = c("error", "rename", "sum", "mean", "keep_first"), require_same_norm = TRUE )merge_bwg( ..., sample_conflict = c("error", "rename", "sum", "mean", "keep_first"), require_same_norm = TRUE )
... |
BwgTrack objects. |
sample_conflict |
Conflict strategy for duplicated sample IDs. |
require_same_norm |
Require identical normalization labels before merging. |
A merged BwgTrack object.
plus <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) minus <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_minus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_minus", strand = "-", mode = "memory", verbose = FALSE ) signal_all <- merge_bwg(plus, minus) signal_allplus <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) minus <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_minus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_minus", strand = "-", mode = "memory", verbose = FALSE ) signal_all <- merge_bwg(plus, minus) signal_all
merge_feature() combines annotations read from GenePred, GTF, GFF, or BED
files into one unified Feature object for downstream retrieval and plotting.
Inputs may represent different genes, genomic regions, annotation formats, or
independently retrieved subsets.
Duplicate identifiers are detected across input objects. For non-error
conflict strategies, a warning reports duplicated gene, transcript, and
feature IDs before the selected strategy is applied. With
conflict = "error", the function stops directly without a preliminary
warning.
With conflict = "deduplicate", input order defines precedence. The first
complete copy of a duplicated transcript is retained, duplicated feature
records are removed, and gene ranges are recalculated from all retained
non-duplicated transcripts. With conflict = "rename", only conflicting
identifiers in later inputs are renamed, and all hierarchical references are
updated together.
merge_feature( ..., source_names = NULL, conflict = c("deduplicate", "rename", "keep_all", "error", "keep_first"), rename_prefix = NULL, sort = TRUE )merge_feature( ..., source_names = NULL, conflict = c("deduplicate", "rename", "keep_all", "error", "keep_first"), rename_prefix = NULL, sort = TRUE )
... |
One or more |
source_names |
Optional unique source labels. If omitted, names from a
supplied list or named arguments are used where available; remaining labels
are generated as |
conflict |
Duplicate-ID strategy. |
rename_prefix |
Optional character vector with one prefix per input.
Used only when |
sort |
Logical. Whether to sort the merged feature and hierarchy tables. |
A merged Feature object. If transcript and exon tables are present,
the result also inherits from GenePred.
annotation <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) gene_a <- retrieve_feature(annotation, gene_id = "GeneA") gene_b <- retrieve_feature(annotation, gene_id = "GeneB") merged_genes <- merge_feature(gene_a, gene_b) merged_genesannotation <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) gene_a <- retrieve_feature(annotation, gene_id = "GeneA") gene_b <- retrieve_feature(annotation, gene_id = "GeneB") merged_genes <- merge_feature(gene_a, gene_b) merged_genes
Normalize signal tracks
norm_bwg( object, method = c("none", "RPM", "CPM", "scale", "custom"), library_size = NULL, scale_factor = NULL, custom_factor = NULL )norm_bwg( object, method = c("none", "RPM", "CPM", "scale", "custom"), library_size = NULL, scale_factor = NULL, custom_factor = NULL )
object |
A BwgTrack object. |
method |
Normalization method. Use |
library_size |
Optional named library sizes. |
scale_factor |
Optional named scale factors. |
custom_factor |
Optional named custom factors. |
A normalized BwgTrack object.
rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) norm_bwg(rnaseq, method = "scale", scale_factor = c(RNA_seq_plus = 0.5))rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) norm_bwg(rnaseq, method = "scale", scale_factor = c(RNA_seq_plus = 0.5))
Draws BED/GFF/GTF-derived interval features in a genomic region. This function
is designed to be compatible with plot_tracks().
plot_feature_track( track, chrom, start, end, mode = c("overlap", "within", "trim"), color_by = "auto", label_by = c("none", "name", "feature_id", "type"), feature_palette = "Paired", feature_colors = NULL, feature_border_color = NA, max_legend_levels = 5, text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_feature_track( track, chrom, start, end, mode = c("overlap", "within", "trim"), color_by = "auto", label_by = c("none", "name", "feature_id", "type"), feature_palette = "Paired", feature_colors = NULL, feature_border_color = NA, max_legend_levels = 5, text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
track |
A FeatureTrack object. |
chrom |
Chromosome name. |
start |
Region start. |
end |
Region end. |
mode |
|
color_by |
Column used for fill colors. Use |
label_by |
Column used for labels. Use |
feature_palette |
RColorBrewer palette name for feature fills. |
feature_colors |
Optional named or unnamed feature fill color vector. |
feature_border_color |
Rectangle border color. Use NA to hide borders. |
max_legend_levels |
Maximum number of displayed legend groups when the selected color attribute contains many categories. |
text_size |
Text size. |
plot_theme |
Base ggplot2 theme. Use |
show_panel_border |
Whether to draw the panel border. |
A ggplot object.
bed_file <- system.file( "extdata", "gtr_demo_features.bed", package = "GeneTrackR" ) features <- read_bed(bed_file, verbose = FALSE, progress = FALSE) plot_feature_track( features, chrom = "chr1", start = 12339001L, end = 12352000L )bed_file <- system.file( "extdata", "gtr_demo_features.bed", package = "GeneTrackR" ) features <- read_bed(bed_file, verbose = FALSE, progress = FALSE) plot_feature_track( features, chrom = "chr1", start = 12339001L, end = 12352000L )
Plot a gene structure
plot_gene( object, gene_id, collapse = c("none", "union_exon", "longest"), coordinate = c("genomic", "transcript"), show_cds = TRUE, cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), highlight = NULL, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_gene( object, gene_id, collapse = c("none", "union_exon", "longest"), coordinate = c("genomic", "transcript"), show_cds = TRUE, cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), highlight = NULL, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
object |
A GenePred object. |
gene_id |
Gene ID. |
collapse |
Transcript collapse mode. |
coordinate |
genomic or transcript. |
show_cds |
Whether to distinguish CDS and UTR segments. |
cds_height |
Vertical thickness of CDS rectangles. |
utr_height |
Vertical thickness of UTR/non-coding exon rectangles. |
direction_mode |
Direction-arrow style. |
highlight |
Optional data frame used to shade genomic or transcript intervals. It must contain |
gene_palette |
RColorBrewer palette name used for discrete fills. If the number of discrete groups exceeds the palette maximum, colors are automatically interpolated. |
gene_colors |
Optional custom fill colors for gene model features. Use a named vector such as |
gene_border_color |
Optional rectangle border color. Use |
label_position |
Where to draw feature labels. |
label_by |
Which identifier to use for feature labels. Use |
text_size |
Text size in points for axis text, axis titles, and legends. |
plot_theme |
Base ggplot2 theme. Use |
show_panel_border |
Whether to draw the panel border. |
Common feature names used by gene_colors are UTR, CDS, and exon.
highlight must contain start and end columns. In genomic coordinate
plots these are genomic positions; in transcript coordinate plots they are
spliced transcript positions. See also GeneTrackR-advanced-parameters.
A ggplot object.
gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_gene(gp, gene_id = "GeneA")gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_gene(gp, gene_id = "GeneA")
Plot the length distribution of genes, transcripts, exons, CDS, UTRs, 5' UTRs, and 3' UTRs from any Feature/GenePred-compatible annotation object. The function is designed for annotation quality control and comparison of coding versus non-coding feature lengths.
plot_gene_length_distribution( object, feature = c("all", "gene", "transcript", "exon", "cds", "utr", "five_utr", "three_utr"), unit = c("auto", "transcript", "segment"), transcript_length = c("spliced", "genomic"), chrom = NULL, start = NULL, end = NULL, mode = c("overlap", "within", "trim"), group_by = c("gene_type", "feature", "strand", "chrom", "none"), plot_type = c("density", "histogram", "boxplot", "violin"), scale = c("log10", "linear"), bins = 60L, facet = TRUE, keep_zero = FALSE, fill_palette = "Paired", fill_colors = NULL, border_color = NA, return_data = FALSE ) plot_genepred_length_distribution(...)plot_gene_length_distribution( object, feature = c("all", "gene", "transcript", "exon", "cds", "utr", "five_utr", "three_utr"), unit = c("auto", "transcript", "segment"), transcript_length = c("spliced", "genomic"), chrom = NULL, start = NULL, end = NULL, mode = c("overlap", "within", "trim"), group_by = c("gene_type", "feature", "strand", "chrom", "none"), plot_type = c("density", "histogram", "boxplot", "violin"), scale = c("log10", "linear"), bins = 60L, facet = TRUE, keep_zero = FALSE, fill_palette = "Paired", fill_colors = NULL, border_color = NA, return_data = FALSE ) plot_genepred_length_distribution(...)
object |
A Feature or GenePred-compatible annotation object. |
feature |
Feature type to plot. Use |
unit |
Output unit used for length extraction. See
|
transcript_length |
Transcript length definition for transcript records. |
chrom |
Optional chromosome filter. |
start |
Optional region start in 1-based closed coordinates. |
end |
Optional region end in 1-based closed coordinates. |
mode |
Region selection mode passed to |
group_by |
Grouping variable. Common choices are |
plot_type |
Plot type. One of |
scale |
Length scale. |
bins |
Number of bins for histogram. |
facet |
Logical. Whether to facet by feature when multiple features are requested. |
keep_zero |
Logical. Whether to keep zero-length CDS/UTR records. |
fill_palette |
RColorBrewer palette name used for grouped fills. Default is |
fill_colors |
Optional custom fill colors. Named vectors are matched to the
values of |
border_color |
Optional border color for histograms, boxplots, and violin plots.
Use |
return_data |
Logical. If |
... |
Deprecated compatibility arguments forwarded by
|
fill_colors follows the values of group_by. For example, if
group_by = "gene_type", names should match coding and non-coding; if
group_by = "feature", names can include gene, transcript, exon,
cds, utr, five_utr, and three_utr. Use return_data = TRUE to inspect
the exact groups before assigning named colors. See also
GeneTrackR-advanced-parameters.
A ggplot object, or a list with plot and data when
return_data = TRUE.
gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_gene_length_distribution(gp, feature = "gene", plot_type = "histogram")gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_gene_length_distribution(gp, feature = "gene", plot_type = "histogram")
Merges haplotype assignments and phenotype values, then draws phenotype distributions for each haplotype. Haplotype groups are ordered by sample number from left to right. Fill colors are mapped to the median phenotype value of each haplotype group.
plot_hap_pheno( hap, phenotype, traits = NULL, sample_col = "sample_id", min_hap_samples = 2L, plot_type = c("violin_boxplot", "violin", "boxplot"), test_method = c("t.test", "wilcox.test", "ks.test"), p_adjust = "BH", p_label = c("stars", "number", "both"), p_cutoff = 0.05, p_value_type = c("raw", "adjusted"), show_signif_only = TRUE, show_points = FALSE, show_outliers = FALSE, fill_palette = "Paired", fill_colors = NULL, fill_alpha = 0.75, violin_width = 0.9, box_width = 0.18, bracket_step = 0.08, bracket_tip_fraction = 0.12, x_text_angle = 90, facet_ncol = 3L, strip_label_width = 24, strip_text_lineheight = 0.9, strip_fill = "white", strip_border_color = NULL, text_size = 14 )plot_hap_pheno( hap, phenotype, traits = NULL, sample_col = "sample_id", min_hap_samples = 2L, plot_type = c("violin_boxplot", "violin", "boxplot"), test_method = c("t.test", "wilcox.test", "ks.test"), p_adjust = "BH", p_label = c("stars", "number", "both"), p_cutoff = 0.05, p_value_type = c("raw", "adjusted"), show_signif_only = TRUE, show_points = FALSE, show_outliers = FALSE, fill_palette = "Paired", fill_colors = NULL, fill_alpha = 0.75, violin_width = 0.9, box_width = 0.18, bracket_step = 0.08, bracket_tip_fraction = 0.12, x_text_angle = 90, facet_ncol = 3L, strip_label_width = 24, strip_text_lineheight = 0.9, strip_fill = "white", strip_border_color = NULL, text_size = 14 )
hap |
A HapVariant object from |
phenotype |
A phenotype table returned by |
traits |
Phenotype trait names. If NULL, all numeric traits are used. |
sample_col |
Sample column name in phenotype table. |
min_hap_samples |
Minimum sample number required for a haplotype group. |
plot_type |
Plot type. One of |
test_method |
Pairwise test method. One of |
p_adjust |
P-value adjustment method passed to |
p_label |
P-value label style. One of |
p_cutoff |
Significance cutoff used for displaying pairwise comparisons. |
p_value_type |
Which p-value is used for filtering and labeling. One of |
show_signif_only |
Logical. Whether to only display significant comparisons. |
show_points |
Logical. Whether to show sample points. |
show_outliers |
Logical. Whether to show boxplot outliers. |
fill_palette |
RColorBrewer palette name used for median-based haplotype fills. |
fill_colors |
Optional custom fill colors for haplotypes. |
fill_alpha |
Alpha value for violin/boxplot fill colors. |
violin_width |
Violin plot width. |
box_width |
Boxplot width. |
bracket_step |
Fraction of y-range used to separate significance brackets. |
bracket_tip_fraction |
Fraction of bracket vertical spacing used for the short downward bracket tips. |
x_text_angle |
Rotation angle for haplotype labels on the x-axis. |
facet_ncol |
Maximum number of facet columns when multiple traits are plotted. |
strip_label_width |
Maximum character width for wrapping long facet strip labels. |
strip_text_lineheight |
Line height for wrapped facet strip labels. |
strip_fill |
Facet strip background fill color. |
strip_border_color |
Facet strip border color. Use NULL to remove the border. |
text_size |
Text size. |
A list with figure and pvalue elements. Additional elements include summary, bracket, and plot_data.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "code", min_variant_number = 1 ) pheno <- read_pheno(pheno_file, verbose = FALSE) plot_hap_pheno(hap, phenotype = pheno, traits = "seed_weight", min_hap_samples = 3) plot_hap_pheno(hap, phenotype = pheno, traits = "seed_weight", min_hap_samples = 3, test_method = "wilcox.test", p_label = "number")vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "code", min_variant_number = 1 ) pheno <- read_pheno(pheno_file, verbose = FALSE) plot_hap_pheno(hap, phenotype = pheno, traits = "seed_weight", min_hap_samples = 3) plot_hap_pheno(hap, phenotype = pheno, traits = "seed_weight", min_hap_samples = 3, test_method = "wilcox.test", p_label = "number")
Legacy compatibility alias of plot_refined_hap_pheno().
plot_hap_refined(refined_hap, phenotype, ...)plot_hap_refined(refined_hap, phenotype, ...)
refined_hap |
A |
phenotype |
A phenotype table returned by |
... |
Additional parameters passed to |
A GeneTrackRPhenoPlot object returned by plot_hap_pheno().
vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) pheno_file <- system.file( "extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR" ) pheno <- read_pheno(pheno_file, verbose = FALSE) gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) hap <- hap_variant( vcf, annotation = gp, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) refined <- refine_haplotype( hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3, effect_threshold = 0.5 ) plot_hap_refined( refined, phenotype = pheno, traits = "protein_content", min_hap_samples = 3 )vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) pheno_file <- system.file( "extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR" ) pheno <- read_pheno(pheno_file, verbose = FALSE) gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) hap <- hap_variant( vcf, annotation = gp, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) refined <- refine_haplotype( hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3, effect_threshold = 0.5 ) plot_hap_refined( refined, phenotype = pheno, traits = "protein_content", min_hap_samples = 3 )
Draws a haplotype-variant figure with a compact gene model track, variant markers, connector lines, and a haplotype genotype table. Genomic gaps are compressed by mapping variant positions to evenly spaced table columns while retaining the relative order of gene model features.
plot_hap_variant( hap, annotation = NULL, show_gene_model = TRUE, min_hap_samples = 5L, show_reference_row = TRUE, variant_label = c("variant_id", "pos"), show_gene_pos_axis = TRUE, gene_pos_axis_n = 5L, gene_pos_axis_label = NULL, gene_pos_x_angle = 0, gene_track_legend_position = c("right", "top", "none"), direction_mode = c("transcript", "gene", "end", "none"), text_size = 14, table_x_angle = 90, genotype_text_size = 3.2, gene_track_height = 1.25, connector_height = 0.35, table_height = NULL, exon_height = 0.22, cds_height = 0.44, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, table_palette = "Paired", table_colors = NULL, table_alpha = 0.6, reference_fill = "white", variant_palette = "Paired", variant_colors = NULL, variant_alpha = 0.6, show_variant_marker = TRUE, variant_marker_size = 2.8 )plot_hap_variant( hap, annotation = NULL, show_gene_model = TRUE, min_hap_samples = 5L, show_reference_row = TRUE, variant_label = c("variant_id", "pos"), show_gene_pos_axis = TRUE, gene_pos_axis_n = 5L, gene_pos_axis_label = NULL, gene_pos_x_angle = 0, gene_track_legend_position = c("right", "top", "none"), direction_mode = c("transcript", "gene", "end", "none"), text_size = 14, table_x_angle = 90, genotype_text_size = 3.2, gene_track_height = 1.25, connector_height = 0.35, table_height = NULL, exon_height = 0.22, cds_height = 0.44, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, table_palette = "Paired", table_colors = NULL, table_alpha = 0.6, reference_fill = "white", variant_palette = "Paired", variant_colors = NULL, variant_alpha = 0.6, show_variant_marker = TRUE, variant_marker_size = 2.8 )
hap |
A HapVariant object from |
annotation |
Optional Feature/GenePred annotation object. When supplied, a compact gene track is drawn above the haplotype table. |
show_gene_model |
Logical. Whether to draw the gene track when
|
min_hap_samples |
Minimum sample number required for a haplotype group to be displayed. |
show_reference_row |
Logical. Whether to add two reference rows showing REF and ALT alleles for each variant. |
variant_label |
Column used for variant labels. One of |
show_gene_pos_axis |
Logical. Whether to show genomic coordinate labels above the gene track. |
gene_pos_axis_n |
Approximate number of genomic coordinate ticks above the gene track. |
gene_pos_axis_label |
Optional x-axis title for genomic coordinate labels. |
gene_pos_x_angle |
Angle of gene-position x-axis labels. Default is 0. |
gene_track_legend_position |
Legend position for variant-type markers in the gene track. One of |
direction_mode |
Gene-strand arrow style for the compact gene track. |
text_size |
Base text size for gene-track labels, axes, legends, and table axes. |
table_x_angle |
Angle of haplotype table x-axis labels. Default is 90. |
genotype_text_size |
Genotype cell text size only. Default is 3.2. |
gene_track_height |
Relative height of the gene track panel. |
connector_height |
Relative height of the connector panel. |
table_height |
Relative height of the haplotype table panel. |
exon_height |
Height of exon boxes in the compact gene track. |
cds_height |
Height of CDS boxes in the compact gene track. |
gene_palette |
RColorBrewer palette name used for gene model feature fills. |
gene_colors |
Optional custom fill colors for gene model features. |
gene_border_color |
Border color for gene model feature boxes. |
table_palette |
RColorBrewer palette name used for haplotype table fills. For allele-string haplotypes, the first five colors are always assigned in the fixed order A, T, C, G, and indel. |
table_colors |
Optional custom fill colors for haplotype table genotypes.
For allele-string haplotypes, use a vector named |
table_alpha |
Alpha value for haplotype table fill colors. |
reference_fill |
Background fill color for the REF and ALT reference rows. |
variant_palette |
RColorBrewer palette name used for solid variant-type triangle marker colors. |
variant_colors |
Optional custom colors for solid variant-type triangle markers. |
variant_alpha |
Alpha value for solid variant-type triangle marker colors. |
show_variant_marker |
Logical. Whether to draw natural-variant triangle markers. |
variant_marker_size |
Size of natural-variant triangle markers. Set to 0 to hide markers. |
A patchwork object with attributes plot_data, variant_data, and gene_data.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) plot_hap_variant(hap, annotation = anno, min_hap_samples = 1) plot_hap_variant( hap, annotation = anno, min_hap_samples = 1, table_x_angle = 90, table_palette = "Paired" )vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) plot_hap_variant(hap, annotation = anno, min_hap_samples = 1) plot_hap_variant( hap, annotation = anno, min_hap_samples = 1, table_x_angle = 90, table_palette = "Paired" )
Draws an inverted triangular LD heatmap using ggplot2. For exactly two
variants, the single pairwise LD value is drawn as one diamond-shaped heatmap
cell, matching the 45-degree geometry used by the triangular LD matrix. Interior grid lines are suppressed; only the outside frame is drawn. The function accepts
either an LDTrack object or a VariantTrack/VCF path, in which case LD is
computed first by compute_ld_block(). The default return value is an
updated LDTrack object: LD calculation results remain in the object and the
generated plot is stored in LDTrack$figure. When show_region = TRUE, the region
track follows the compact gene-model style used by plot_hap_variant() in
GeneTrackR 0.3.15 and connects genomic variant markers to LD heatmap columns
with a shared x scale, so line endpoints remain aligned after resizing.
plot_ld_block( object, chrom = NULL, start = NULL, end = NULL, variant_type = c("both", "snp", "ind"), method = c("r2", "Dprime"), color_palette = "Reds", font = 14, title = NULL, label_by = c("pos", "variant_id"), show_variant_labels = TRUE, show_region = FALSE, show_variant_marker = TRUE, variant_marker_size = 2.8, annotation = NULL, connect_region = TRUE, region_height = 1.25, connector_height = 0.35, heatmap_height = NULL, samples = NULL, min_pair_samples = 3L, ploidy = 2L, verbose = TRUE, return_object = TRUE )plot_ld_block( object, chrom = NULL, start = NULL, end = NULL, variant_type = c("both", "snp", "ind"), method = c("r2", "Dprime"), color_palette = "Reds", font = 14, title = NULL, label_by = c("pos", "variant_id"), show_variant_labels = TRUE, show_region = FALSE, show_variant_marker = TRUE, variant_marker_size = 2.8, annotation = NULL, connect_region = TRUE, region_height = 1.25, connector_height = 0.35, heatmap_height = NULL, samples = NULL, min_pair_samples = 3L, ploidy = 2L, verbose = TRUE, return_object = TRUE )
object |
An |
chrom, start, end
|
Optional region used when |
variant_type |
One of |
method |
LD method used when computing from VCF. |
color_palette |
RColorBrewer palette name used to generate the continuous LD heatmap gradient. Default |
font |
Base font size. Font color is always black. |
title |
Plot title. Default is |
label_by |
Variant label column, either |
show_variant_labels |
Logical. Whether to show labels above the heatmap. |
show_region |
Logical. Whether to add a compact region/variant track above the LD heatmap. |
show_variant_marker |
Logical. Whether to draw natural-variant triangle markers in the region track. |
variant_marker_size |
Size of natural-variant triangle markers. Set to 0 to hide markers. |
annotation |
Optional gene annotation used by the compact region track. |
connect_region |
Logical. Whether to connect region-track variant positions to heatmap columns. |
region_height |
Relative height of the compact region track. |
connector_height |
Relative height of connector lines. |
heatmap_height |
Relative height of the heatmap. If NULL, it is chosen from the number of variants. |
samples, min_pair_samples, ploidy, verbose
|
Passed to |
return_object |
Logical. Default TRUE. If TRUE, return an updated
|
By default, an updated LDTrack object with the generated figure
stored in $figure. If return_object = FALSE, the ggplot/patchwork figure
is returned directly.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) ld <- compute_ld_block( vcf, chrom = "chr1", start = 12342620, end = 12355500, variant_type = "snp", verbose = FALSE ) ld <- plot_ld_block(ld, show_region = TRUE, annotation = anno, show_variant_labels = FALSE) ld$figurevcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) ld <- compute_ld_block( vcf, chrom = "chr1", start = 12342620, end = 12355500, variant_type = "snp", verbose = FALSE ) ld <- plot_ld_block(ld, show_region = TRUE, annotation = anno, show_variant_labels = FALSE) ld$figure
Plot phenotype distributions
plot_pheno( pheno, traits = NULL, sample_col = "sample_id", bins = 30L, text_size = 14 )plot_pheno( pheno, traits = NULL, sample_col = "sample_id", bins = 30L, text_size = 14 )
pheno |
A phenotype data.frame/data.table. |
traits |
Optional trait names. If NULL, all traits are plotted. |
sample_col |
Sample column name. |
bins |
Histogram bins for numeric traits. |
text_size |
Text size. |
A ggplot object.
pheno_file <- system.file( "extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR" ) pheno <- read_pheno(pheno_file, verbose = FALSE) plot_pheno(pheno, traits = "protein_content")pheno_file <- system.file( "extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR" ) pheno <- read_pheno(pheno_file, verbose = FALSE) plot_pheno(pheno, traits = "protein_content")
Draw phenotype distributions for refined haplotype groups generated by
refine_haplotype(). This function is a refined-haplotype wrapper around
plot_hap_pheno(), but all commonly used phenotype-plot parameters are
exposed explicitly so that the help page shows the complete usage.
plot_refined_hap_pheno( refined_hap, phenotype, traits = NULL, sample_col = "sample_id", min_hap_samples = 2L, plot_type = c("violin_boxplot", "violin", "boxplot"), test_method = c("t.test", "wilcox.test", "ks.test"), p_adjust = "BH", p_label = c("stars", "number", "both"), p_cutoff = 0.05, p_value_type = c("raw", "adjusted"), show_signif_only = TRUE, show_points = FALSE, show_outliers = FALSE, fill_palette = "Paired", fill_colors = NULL, fill_alpha = 0.75, violin_width = 0.9, box_width = 0.18, bracket_step = 0.08, bracket_tip_fraction = 0.12, x_text_angle = 90, strip_label_width = 24, strip_text_lineheight = 0.9, strip_fill = "white", strip_border_color = NULL, text_size = 14 )plot_refined_hap_pheno( refined_hap, phenotype, traits = NULL, sample_col = "sample_id", min_hap_samples = 2L, plot_type = c("violin_boxplot", "violin", "boxplot"), test_method = c("t.test", "wilcox.test", "ks.test"), p_adjust = "BH", p_label = c("stars", "number", "both"), p_cutoff = 0.05, p_value_type = c("raw", "adjusted"), show_signif_only = TRUE, show_points = FALSE, show_outliers = FALSE, fill_palette = "Paired", fill_colors = NULL, fill_alpha = 0.75, violin_width = 0.9, box_width = 0.18, bracket_step = 0.08, bracket_tip_fraction = 0.12, x_text_angle = 90, strip_label_width = 24, strip_text_lineheight = 0.9, strip_fill = "white", strip_border_color = NULL, text_size = 14 )
refined_hap |
A |
phenotype |
A phenotype table returned by |
traits |
Phenotype trait names. If NULL, all numeric traits are used. |
sample_col |
Sample column name in phenotype table. |
min_hap_samples |
Minimum sample number required for a refined haplotype group. |
plot_type |
Plot type. One of |
test_method |
Pairwise test method. One of |
p_adjust |
P-value adjustment method passed to |
p_label |
P-value label style. One of |
p_cutoff |
Significance cutoff used for displaying pairwise comparisons. |
p_value_type |
Which p-value is used for filtering and labeling. One of |
show_signif_only |
Logical. Whether to only display significant comparisons. |
show_points |
Logical. Whether to show sample points. |
show_outliers |
Logical. Whether to show boxplot outliers. |
fill_palette |
RColorBrewer palette name used for median-based refined haplotype fills. |
fill_colors |
Optional custom fill colors for refined haplotypes. |
fill_alpha |
Alpha value for violin/boxplot fill colors. |
violin_width |
Violin plot width. |
box_width |
Boxplot width. |
bracket_step |
Fraction of y-range used to separate significance brackets. |
bracket_tip_fraction |
Fraction of bracket vertical spacing used for the short downward bracket tips. |
x_text_angle |
Rotation angle for refined haplotype labels on the x-axis. |
strip_label_width |
Maximum character width for wrapping long facet strip labels. |
strip_text_lineheight |
Line height for wrapped facet strip labels. |
strip_fill |
Facet strip background fill color. |
strip_border_color |
Facet strip border color. Use NULL to remove the border. |
text_size |
Text size. |
A GeneTrackRPhenoPlot object returned by plot_hap_pheno().
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) refined <- refine_haplotype( hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3, effect_threshold = 0.5 ) plot_refined_hap_pheno( refined, phenotype = pheno, traits = "protein_content", min_hap_samples = 3 )vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) refined <- refine_haplotype( hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3, effect_threshold = 0.5 ) plot_refined_hap_pheno( refined, phenotype = pheno, traits = "protein_content", min_hap_samples = 3 )
Draw a refined haplotype-variant table. By default, when the input is a
HapRefined object, the original haplotype rows are retained and arranged
into refined haplotype blocks. For example, if ten original haplotypes are
refined into three groups, the table shows the ten original haplotypes split
into three vertically separated blocks. This makes it easier to inspect which
variants are shared or variable within each refined group.
If collapse_refined = TRUE, the function falls back to a collapsed refined
table in which each refined haplotype is shown as one row, using the same
visual grammar as plot_hap_variant().
plot_refined_hap_variant( refined_hap, annotation = NULL, show_gene_model = TRUE, min_hap_samples = 5L, show_reference_row = TRUE, collapse_refined = FALSE, group_gap = 0.8, show_group_label = TRUE, group_label_prefix = "", group_label_hjust = 3.4, group_label_size = NULL, group_label_left_margin = NULL, variant_label = c("variant_id", "pos"), show_gene_pos_axis = TRUE, gene_pos_axis_n = 5L, gene_pos_axis_label = NULL, gene_pos_x_angle = 0, gene_track_legend_position = c("right", "top", "none"), text_size = 14, table_x_angle = 90, genotype_text_size = 3.2, gene_track_height = 1.25, connector_height = 0.35, table_height = NULL, exon_height = 0.22, cds_height = 0.44, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, table_palette = "Paired", table_colors = NULL, table_alpha = 0.6, reference_fill = "white", variant_palette = "Paired", variant_colors = NULL )plot_refined_hap_variant( refined_hap, annotation = NULL, show_gene_model = TRUE, min_hap_samples = 5L, show_reference_row = TRUE, collapse_refined = FALSE, group_gap = 0.8, show_group_label = TRUE, group_label_prefix = "", group_label_hjust = 3.4, group_label_size = NULL, group_label_left_margin = NULL, variant_label = c("variant_id", "pos"), show_gene_pos_axis = TRUE, gene_pos_axis_n = 5L, gene_pos_axis_label = NULL, gene_pos_x_angle = 0, gene_track_legend_position = c("right", "top", "none"), text_size = 14, table_x_angle = 90, genotype_text_size = 3.2, gene_track_height = 1.25, connector_height = 0.35, table_height = NULL, exon_height = 0.22, cds_height = 0.44, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, table_palette = "Paired", table_colors = NULL, table_alpha = 0.6, reference_fill = "white", variant_palette = "Paired", variant_colors = NULL )
refined_hap |
A |
annotation |
Optional Feature/GenePred annotation object. When supplied, a compact gene track is drawn above the refined haplotype table. |
show_gene_model |
Logical. Whether to draw the gene track when |
min_hap_samples |
Minimum sample number required for an original haplotype row. |
show_reference_row |
Logical. Whether to add two reference rows showing REF and ALT alleles for each variant. |
collapse_refined |
Logical. Whether to plot one collapsed row per refined haplotype group. |
group_gap |
Numeric vertical gap inserted between refined haplotype blocks. |
show_group_label |
Logical. Whether to show refined group labels on the left side of the table. |
group_label_prefix |
Prefix used for left-side group labels. |
group_label_hjust |
Horizontal adjustment for refined group labels. Larger values move the group labels further left and reduce overlap with original haplotype row labels. |
group_label_size |
Text size for refined group labels. If NULL, it is
derived from |
group_label_left_margin |
Left plot margin used when refined group labels are shown. Increase this value when group labels are clipped. |
variant_label |
Column used for variant labels. One of |
show_gene_pos_axis |
Logical. Whether to show genomic coordinate labels above the gene track. |
gene_pos_axis_n |
Approximate number of genomic coordinate ticks above the gene track. |
gene_pos_axis_label |
Optional x-axis title for genomic coordinate labels. |
gene_pos_x_angle |
Angle of gene-position x-axis labels. |
gene_track_legend_position |
Legend position for variant-type markers in the gene track. One of |
text_size |
Base text size for gene-track labels, axes, legends, and table axes. |
table_x_angle |
Angle of haplotype table x-axis labels. |
genotype_text_size |
Genotype cell text size only. |
gene_track_height |
Relative height of the gene track panel. |
connector_height |
Relative height of the connector panel. |
table_height |
Relative height of the haplotype table panel. If NULL, it is inferred from the number of displayed rows and group gaps. |
exon_height |
Height of exon boxes in the compact gene track. |
cds_height |
Height of CDS boxes in the compact gene track. |
gene_palette |
RColorBrewer palette name used for gene model feature fills. |
gene_colors |
Optional custom fill colors for gene model features. |
gene_border_color |
Border color for gene model feature boxes. |
table_palette |
RColorBrewer palette name used for haplotype table fills. For allele-string haplotypes, the first five colors are always assigned in the fixed order A, T, C, G, and indel. |
table_colors |
Optional custom fill colors for haplotype table genotypes.
For allele-string haplotypes, use a vector named |
table_alpha |
Alpha value for haplotype table fill colors. |
reference_fill |
Background fill color for the REF and ALT reference rows. |
variant_palette |
RColorBrewer palette name used for solid variant-type triangle marker colors. |
variant_colors |
Optional custom colors for solid variant-type triangle markers. |
A patchwork object with attributes plot_data, variant_data,
gene_data, refined_haplotype_map, and refined_haplotypes when available.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) refined <- refine_haplotype( hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3, effect_threshold = 0.5 ) plot_refined_hap_variant(refined, annotation = anno, min_hap_samples = 1)vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) refined <- refine_haplotype( hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3, effect_threshold = 0.5 ) plot_refined_hap_variant(refined, annotation = anno, min_hap_samples = 1)
Plot gene structures in a genomic region
plot_region( object, chrom, start, end, mode = c("within", "overlap", "trim"), collapse = c("none", "union_exon", "longest"), show_cds = TRUE, cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), highlight = NULL, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_region( object, chrom, start, end, mode = c("within", "overlap", "trim"), collapse = c("none", "union_exon", "longest"), show_cds = TRUE, cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), highlight = NULL, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
object |
A GenePred object. |
chrom |
Chromosome name. |
start |
Region start. |
end |
Region end. |
mode |
within, overlap, or trim. |
collapse |
Transcript collapse mode. |
show_cds |
Whether to distinguish CDS and UTR segments. |
cds_height |
Vertical thickness of CDS rectangles. |
utr_height |
Vertical thickness of UTR/non-coding exon rectangles. |
direction_mode |
Direction-arrow style. |
highlight |
Optional data frame used to shade genomic or transcript intervals. It must contain |
gene_palette |
RColorBrewer palette name used for discrete fills. If the number of discrete groups exceeds the palette maximum, colors are automatically interpolated. |
gene_colors |
Optional custom fill colors for gene model features. Use a named vector such as |
gene_border_color |
Optional rectangle border color. Use |
label_position |
Where to draw feature labels. |
label_by |
Which identifier to use for feature labels. Use |
text_size |
Text size in points for axis text, axis titles, and legends. |
plot_theme |
Base ggplot2 theme. Use |
show_panel_border |
Whether to draw the panel border. |
Common feature names used by gene_colors are UTR, CDS, and exon.
highlight must contain start and end columns. In genomic coordinate
plots these are genomic positions; in transcript coordinate plots they are
spliced transcript positions. See also GeneTrackR-advanced-parameters.
A ggplot object.
gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_region(gp, chrom = "chr1", start = 12339001, end = 12352000)gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_region(gp, chrom = "chr1", start = 12339001, end = 12352000)
Plot signal over a gene
plot_signal_gene( signal, annotation, gene_id, samples = NULL, sample_groups = NULL, signal_color_by = c("sample", "group"), signal_summary = c("none", "mean", "median", "sum"), plot_type = c("bar", "line", "heatmap"), strand = c("auto", "+", "-", "both", "ignore"), bin_size = NULL, highlight = NULL, show_gene_model = TRUE, signal_track_height = 3, gene_track_height = 1, signal_palette = "Paired", signal_palette_direction = 1, signal_colors = NULL, signal_transform = c("none", "log2", "log10", "sqrt"), signal_y_scale = c("free", "fixed"), signal_y_ticks = c("range", "pretty"), heatmap_bin_size = NULL, heatmap_max_bins = 800L, heatmap_summary = c("mean", "max", "sum", "median"), cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, signal_y_limits = NULL, signal_alpha = 0.85, signal_bar_width = 1, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_signal_gene( signal, annotation, gene_id, samples = NULL, sample_groups = NULL, signal_color_by = c("sample", "group"), signal_summary = c("none", "mean", "median", "sum"), plot_type = c("bar", "line", "heatmap"), strand = c("auto", "+", "-", "both", "ignore"), bin_size = NULL, highlight = NULL, show_gene_model = TRUE, signal_track_height = 3, gene_track_height = 1, signal_palette = "Paired", signal_palette_direction = 1, signal_colors = NULL, signal_transform = c("none", "log2", "log10", "sqrt"), signal_y_scale = c("free", "fixed"), signal_y_ticks = c("range", "pretty"), heatmap_bin_size = NULL, heatmap_max_bins = 800L, heatmap_summary = c("mean", "max", "sum", "median"), cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, signal_y_limits = NULL, signal_alpha = 0.85, signal_bar_width = 1, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
signal |
A BwgTrack object. |
annotation |
A GenePred object. |
gene_id |
Gene ID. |
samples |
Optional sample IDs to plot. If NULL, all samples are used. |
sample_groups |
Optional sample group mapping for group-level coloring or replicate summaries. Use a named character vector, a data frame with |
signal_color_by |
Color signal tracks by |
signal_summary |
Replicate summary mode. Use |
plot_type |
Signal plot type: |
strand |
Strand selector. Use |
bin_size |
Optional bin size for signal aggregation. |
highlight |
Optional data frame used to shade intervals on the signal and gene model tracks. It must contain |
show_gene_model |
Whether to append the gene model track. |
signal_track_height |
Relative height of the signal panel when the gene model is shown. Default 3. |
gene_track_height |
Relative height of the gene model panel when it is shown. Default 1. |
signal_palette |
Signal color palette. Any palette name from |
signal_palette_direction |
Direction for generated signal colors. Use |
signal_colors |
Optional named or unnamed vector of explicit colors for samples. If supplied, it overrides |
signal_transform |
Signal-axis transformation. Use |
signal_y_scale |
Signal y-axis scale mode. Use |
signal_y_ticks |
Signal y-axis tick mode. Use |
heatmap_bin_size |
Optional bin size used only for heatmap rendering.
|
heatmap_max_bins |
Maximum number of heatmap bins when
|
heatmap_summary |
Summary statistic used to aggregate signal into
heatmap bins: |
cds_height |
Vertical thickness of CDS rectangles in the gene model track. |
utr_height |
Vertical thickness of UTR/non-coding exon rectangles in the gene model track. |
direction_mode |
Direction-arrow style for the gene model track. |
label_position |
Where to draw gene model labels. |
label_by |
Which identifier to use for gene model labels. Use |
text_size |
Text size in points for signal and gene model axis text, axis titles, facet strips, and legends. |
signal_y_limits |
Optional two-element numeric vector giving the plotted y-axis limits after |
signal_alpha |
Signal geometry transparency from 0 to 1. |
signal_bar_width |
Relative width of bar intervals from greater than 0 to 1. A value below 1 creates proportional gaps without changing interval centers. |
plot_theme |
Base ggplot2 theme. Use |
show_panel_border |
Whether to draw panel borders. |
samples selects the samples to draw. sample_groups can be used for
group-level coloring and replicate summaries. When raw intervals differ among
samples, set bin_size before using signal_summary so the summary is made
on comparable bins. signal_transform changes the plotted y value only; the
queried signal table is not modified. See also GeneTrackR-advanced-parameters.
A ggplot or patchwork object.
gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) plot_signal_gene(signal = rnaseq, annotation = gp, gene_id = "GeneA")gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) plot_signal_gene(signal = rnaseq, annotation = gp, gene_id = "GeneA")
Plot signal over a genomic region
plot_signal_region( signal, chrom, start, end, samples = NULL, sample_groups = NULL, signal_color_by = c("sample", "group"), signal_summary = c("none", "mean", "median", "sum"), plot_type = c("bar", "line", "heatmap"), strand = c("ignore", "+", "-", "both"), bin_size = NULL, highlight = NULL, annotation = NULL, show_gene_model = TRUE, signal_track_height = 3, gene_track_height = 1, signal_palette = "Paired", signal_palette_direction = 1, signal_colors = NULL, signal_transform = c("none", "log2", "log10", "sqrt"), signal_y_scale = c("free", "fixed"), signal_y_ticks = c("range", "pretty"), heatmap_bin_size = NULL, heatmap_max_bins = 800L, heatmap_summary = c("mean", "max", "sum", "median"), cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, signal_y_limits = NULL, signal_alpha = 0.85, signal_bar_width = 1, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_signal_region( signal, chrom, start, end, samples = NULL, sample_groups = NULL, signal_color_by = c("sample", "group"), signal_summary = c("none", "mean", "median", "sum"), plot_type = c("bar", "line", "heatmap"), strand = c("ignore", "+", "-", "both"), bin_size = NULL, highlight = NULL, annotation = NULL, show_gene_model = TRUE, signal_track_height = 3, gene_track_height = 1, signal_palette = "Paired", signal_palette_direction = 1, signal_colors = NULL, signal_transform = c("none", "log2", "log10", "sqrt"), signal_y_scale = c("free", "fixed"), signal_y_ticks = c("range", "pretty"), heatmap_bin_size = NULL, heatmap_max_bins = 800L, heatmap_summary = c("mean", "max", "sum", "median"), cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, signal_y_limits = NULL, signal_alpha = 0.85, signal_bar_width = 1, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
signal |
A BwgTrack object. |
chrom |
Chromosome name. |
start |
Region start. |
end |
Region end. |
samples |
Optional sample IDs to plot. If NULL, all samples are used. |
sample_groups |
Optional sample group mapping for group-level coloring or replicate summaries. Use a named character vector, a data frame with |
signal_color_by |
Color signal tracks by |
signal_summary |
Replicate summary mode. Use |
plot_type |
Signal plot type: |
strand |
Strand selector. |
bin_size |
Optional bin size for signal aggregation. |
highlight |
Optional data frame used to shade intervals on the signal and gene model tracks. It must contain |
annotation |
Optional GenePred object. |
show_gene_model |
Whether to append a gene model track. Default TRUE. |
signal_track_height |
Relative height of the signal panel when the gene model is shown. Default 3. |
gene_track_height |
Relative height of the gene model panel when it is shown. Default 1. |
signal_palette |
Signal color palette. Any palette name from |
signal_palette_direction |
Direction for generated signal colors. Use |
signal_colors |
Optional named or unnamed vector of explicit colors for samples. If supplied, it overrides |
signal_transform |
Signal-axis transformation. Use |
signal_y_scale |
Signal y-axis scale mode. Use |
signal_y_ticks |
Signal y-axis tick mode. Use |
heatmap_bin_size |
Optional bin size used only for heatmap rendering.
|
heatmap_max_bins |
Maximum number of heatmap bins when
|
heatmap_summary |
Summary statistic used to aggregate signal into
heatmap bins: |
cds_height |
Vertical thickness of CDS rectangles in the gene model track. |
utr_height |
Vertical thickness of UTR/non-coding exon rectangles in the gene model track. |
direction_mode |
Direction-arrow style for the gene model track. |
label_position |
Where to draw gene model labels. |
label_by |
Which identifier to use for gene model labels. Use |
text_size |
Text size in points for signal and gene model axis text, axis titles, facet strips, and legends. |
signal_y_limits |
Optional two-element numeric vector giving the plotted y-axis limits after |
signal_alpha |
Signal geometry transparency from 0 to 1. |
signal_bar_width |
Relative width of bar intervals from greater than 0 to 1. A value below 1 creates proportional gaps without changing interval centers. |
plot_theme |
Base ggplot2 theme. Use |
show_panel_border |
Whether to draw panel borders. |
If annotation is supplied and show_gene_model = TRUE, a gene model track
is appended below the signal panel. signal_colors can be an unnamed vector
or a named vector. Named values are matched to sample IDs when
signal_color_by = "sample", and to group names when
signal_color_by = "group". See also GeneTrackR-advanced-parameters.
A ggplot or patchwork object.
gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) rnaseq <- read_bwg( system.file( "extdata", c("gtr_demo_rnaseq_plus.bedgraph", "gtr_demo_rnaseq_minus.bedgraph"), package = "GeneTrackR" ), format = "bedgraph", sample_names = c("RNA_seq_plus", "RNA_seq_minus"), strand = c("+", "-"), mode = "memory", verbose = FALSE ) plot_signal_region( signal = rnaseq, annotation = gp, chrom = "chr1", start = 12339001, end = 12352000, strand = "both", plot_type = "bar" )gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) rnaseq <- read_bwg( system.file( "extdata", c("gtr_demo_rnaseq_plus.bedgraph", "gtr_demo_rnaseq_minus.bedgraph"), package = "GeneTrackR" ), format = "bedgraph", sample_names = c("RNA_seq_plus", "RNA_seq_minus"), strand = c("+", "-"), mode = "memory", verbose = FALSE ) plot_signal_region( signal = rnaseq, annotation = gp, chrom = "chr1", start = 12339001, end = 12352000, strand = "both", plot_type = "bar" )
Plot signal over a transcript
plot_signal_transcript( signal, annotation, transcript_id, samples = NULL, sample_groups = NULL, signal_color_by = c("sample", "group"), signal_summary = c("none", "mean", "median", "sum"), coordinate = c("transcript", "genomic"), plot_type = c("bar", "line", "heatmap", "frame"), strand = c("auto", "+", "-", "both", "ignore"), bin_size = NULL, highlight = NULL, show_gene_model = TRUE, signal_track_height = 3, gene_track_height = 1, signal_palette = "Paired", signal_palette_direction = 1, signal_colors = NULL, frame_palette = "Paired", frame_colors = NULL, signal_transform = c("none", "log2", "log10", "sqrt"), signal_y_scale = c("free", "fixed"), signal_y_ticks = c("range", "pretty"), heatmap_bin_size = NULL, heatmap_max_bins = 800L, heatmap_summary = c("mean", "max", "sum", "median"), cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, signal_y_limits = NULL, signal_alpha = 0.85, signal_bar_width = 1, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_signal_transcript( signal, annotation, transcript_id, samples = NULL, sample_groups = NULL, signal_color_by = c("sample", "group"), signal_summary = c("none", "mean", "median", "sum"), coordinate = c("transcript", "genomic"), plot_type = c("bar", "line", "heatmap", "frame"), strand = c("auto", "+", "-", "both", "ignore"), bin_size = NULL, highlight = NULL, show_gene_model = TRUE, signal_track_height = 3, gene_track_height = 1, signal_palette = "Paired", signal_palette_direction = 1, signal_colors = NULL, frame_palette = "Paired", frame_colors = NULL, signal_transform = c("none", "log2", "log10", "sqrt"), signal_y_scale = c("free", "fixed"), signal_y_ticks = c("range", "pretty"), heatmap_bin_size = NULL, heatmap_max_bins = 800L, heatmap_summary = c("mean", "max", "sum", "median"), cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, signal_y_limits = NULL, signal_alpha = 0.85, signal_bar_width = 1, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
signal |
A BwgTrack object. |
annotation |
A GenePred object. |
transcript_id |
Transcript ID. |
samples |
Optional sample IDs to plot. If NULL, all samples are used. |
sample_groups |
Optional sample group mapping for group-level coloring or replicate summaries. Use a named character vector, a data frame with |
signal_color_by |
Color signal tracks by |
signal_summary |
Replicate summary mode. Use |
coordinate |
Coordinate mode. |
plot_type |
Signal plot type: |
strand |
Strand selector. Use |
bin_size |
Optional bin size for signal aggregation. |
highlight |
Optional data frame used to shade intervals on the signal and gene model tracks. It must contain |
show_gene_model |
Whether to append the transcript gene model track. Default TRUE. |
signal_track_height |
Relative height of the signal panel when the gene model is shown. Default 3. |
gene_track_height |
Relative height of the gene model panel when it is shown. Default 1. |
signal_palette |
Signal color palette. Any palette name from |
signal_palette_direction |
Direction for generated signal colors. Use |
signal_colors |
Optional named or unnamed vector of explicit colors for samples. If supplied, it overrides |
frame_palette |
RColorBrewer palette for CDS frame colors when |
frame_colors |
Optional named colors for |
signal_transform |
Signal-axis transformation. Use |
signal_y_scale |
Signal y-axis scale mode. Use |
signal_y_ticks |
Signal y-axis tick mode. Use |
heatmap_bin_size |
Optional bin size used only for heatmap rendering.
|
heatmap_max_bins |
Maximum number of heatmap bins when
|
heatmap_summary |
Summary statistic used to aggregate signal into
heatmap bins: |
cds_height |
Vertical thickness of CDS rectangles in the gene model track. |
utr_height |
Vertical thickness of UTR/non-coding exon rectangles in the gene model track. |
direction_mode |
Direction-arrow style for the gene model track. |
label_position |
Where to draw gene model labels. |
label_by |
Which identifier to use for gene model labels. |
text_size |
Text size in points for signal and gene model axis text, axis titles, facet strips, and legends. |
signal_y_limits |
Optional two-element numeric vector giving the plotted y-axis limits after |
signal_alpha |
Signal geometry transparency from 0 to 1. |
signal_bar_width |
Relative width of bar intervals from greater than 0 to 1. A value below 1 creates proportional gaps without changing interval centers. |
plot_theme |
Base ggplot2 theme. Use |
show_panel_border |
Whether to draw panel borders. |
samples selects the samples to draw. sample_groups can be a named vector
or a data frame with sample_id and group. Use signal_color_by = "group"
to color by group, and signal_summary = "mean", "median", or "sum"
to collapse replicates within groups. signal_colors overrides
signal_palette and may be named by sample ID or group name. See also
GeneTrackR-advanced-parameters.
A ggplot or patchwork object.
gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) plot_signal_transcript( signal = rnaseq, annotation = gp, transcript_id = "TxA1", coordinate = "transcript", plot_type = "bar" )gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) plot_signal_transcript( signal = rnaseq, annotation = gp, transcript_id = "TxA1", coordinate = "transcript", plot_type = "bar" )
Draw a genome-browser-like figure containing a gene model track alone or a
signal track combined with gene, feature, and variant tracks. The genomic
interval can be specified in three ways: by gene_id, by transcript_id,
or by explicit chrom, start, and end coordinates.
plot_tracks( annotation, signal = NULL, features = NULL, variants = NULL, chrom = NULL, start = NULL, end = NULL, gene_id = NULL, transcript_id = NULL, samples = NULL, sample_groups = NULL, signal_color_by = c("sample", "group"), signal_summary = c("none", "mean", "median", "sum"), signal_type = c("bar", "line", "heatmap"), signal_palette = "Paired", signal_palette_direction = 1, signal_colors = NULL, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, feature_color_by = "auto", feature_palette = "Paired", feature_colors = NULL, feature_border_color = NA, feature_max_legend_levels = 5, variant_palette = "Paired", variant_colors = NULL, ribo_signal_type = c("auto", "bar", "frame"), frame_palette = "Paired", frame_colors = NULL, signal_transform = c("none", "log2", "log10", "sqrt"), signal_y_scale = c("free", "fixed"), signal_y_ticks = c("range", "pretty"), heatmap_bin_size = NULL, heatmap_max_bins = 800L, heatmap_summary = c("mean", "max", "sum", "median"), collapse = c("none", "union_exon", "longest"), strand = c("ignore", "+", "-", "both"), bin_size = NULL, highlight = NULL, layout = c("signal_top", "gene_top"), heights = c(signal = 3, gene = 1, feature = 0.8, variant = 0.7), cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, signal_y_limits = NULL, signal_alpha = 0.85, signal_bar_width = 1, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_tracks( annotation, signal = NULL, features = NULL, variants = NULL, chrom = NULL, start = NULL, end = NULL, gene_id = NULL, transcript_id = NULL, samples = NULL, sample_groups = NULL, signal_color_by = c("sample", "group"), signal_summary = c("none", "mean", "median", "sum"), signal_type = c("bar", "line", "heatmap"), signal_palette = "Paired", signal_palette_direction = 1, signal_colors = NULL, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, feature_color_by = "auto", feature_palette = "Paired", feature_colors = NULL, feature_border_color = NA, feature_max_legend_levels = 5, variant_palette = "Paired", variant_colors = NULL, ribo_signal_type = c("auto", "bar", "frame"), frame_palette = "Paired", frame_colors = NULL, signal_transform = c("none", "log2", "log10", "sqrt"), signal_y_scale = c("free", "fixed"), signal_y_ticks = c("range", "pretty"), heatmap_bin_size = NULL, heatmap_max_bins = 800L, heatmap_summary = c("mean", "max", "sum", "median"), collapse = c("none", "union_exon", "longest"), strand = c("ignore", "+", "-", "both"), bin_size = NULL, highlight = NULL, layout = c("signal_top", "gene_top"), heights = c(signal = 3, gene = 1, feature = 0.8, variant = 0.7), cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, signal_y_limits = NULL, signal_alpha = 0.85, signal_bar_width = 1, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
annotation |
A GenePred object or a standardized Feature object with transcript/exon records. |
signal |
Optional BwgTrack object. If NULL, only annotation/feature/variant tracks are drawn. |
features |
Optional FeatureTrack object or named list of FeatureTrack objects from |
variants |
Optional VariantTrack object or named list of VariantTrack objects from |
chrom |
Chromosome name. Required when |
start |
Region start in 1-based closed coordinates. Required with |
end |
Region end in 1-based closed coordinates. Required with |
gene_id |
Optional gene ID. If supplied, the plotting interval is inferred from the gene locus. |
transcript_id |
Optional transcript ID. If supplied, the plotting interval is inferred from the transcript locus. |
samples |
Optional signal sample IDs. |
sample_groups |
Optional sample group mapping for group-level coloring or replicate summaries. Use a named character vector, a data frame with |
signal_color_by |
Color signal tracks by |
signal_summary |
Replicate summary mode. Use |
signal_type |
Signal plot type for non-Ribo-seq browser signal tracks. |
signal_palette |
Signal color palette for signal tracks. Any palette name from |
signal_palette_direction |
Direction for generated signal colors. Use |
signal_colors |
Optional named or unnamed vector of explicit colors for signal samples. Explicit colors override |
gene_palette |
RColorBrewer palette name used for gene model feature fills. |
gene_colors |
Optional custom fill colors for gene model features. Use a named vector such as |
gene_border_color |
Optional rectangle border color for gene model features. Use |
feature_color_by |
Feature-track color grouping. |
feature_palette |
RColorBrewer palette name used for feature-track fills. |
feature_colors |
Optional explicit feature-track fill colors. |
feature_border_color |
Optional rectangle border color for feature tracks. Use |
feature_max_legend_levels |
Maximum number of legend groups shown for each feature track. |
variant_palette |
RColorBrewer palette name used for variant-track colors. |
variant_colors |
Optional named or unnamed explicit colors passed to |
ribo_signal_type |
How Ribo-seq samples should be displayed in transcript-centered browser plots. |
frame_palette |
RColorBrewer palette name used for Ribo-seq frame plots. |
frame_colors |
Optional explicit colors for |
signal_transform |
Signal-axis transformation. Use |
signal_y_scale |
Signal y-axis scale mode. Use |
signal_y_ticks |
Signal y-axis tick mode. Use |
heatmap_bin_size |
Optional bin size used only for heatmap rendering.
|
heatmap_max_bins |
Maximum number of heatmap bins when
|
heatmap_summary |
Summary statistic used to aggregate signal into
heatmap bins: |
collapse |
Gene model collapse mode for region-level plotting. |
strand |
Signal strand selector. |
bin_size |
Optional signal bin size. |
highlight |
Optional data frame used to shade intervals on signal and gene model tracks. It must contain |
layout |
Track layout. Use |
heights |
Relative panel heights. Must contain at least |
cds_height |
Vertical thickness of CDS rectangles in the gene model track. |
utr_height |
Vertical thickness of UTR/non-coding exon rectangles in the gene model track. |
direction_mode |
Direction-arrow style for the gene model track. |
label_position |
Where to draw gene model labels. |
label_by |
Which identifier to use for gene model labels. Use |
text_size |
Text size in points for axis text, axis titles, legends, and facet labels. |
signal_y_limits |
Optional two-element numeric vector giving the plotted y-axis limits after |
signal_alpha |
Signal geometry transparency from 0 to 1. |
signal_bar_width |
Relative width of bar intervals from greater than 0 to 1. A value below 1 creates proportional gaps without changing interval centers. |
plot_theme |
Base ggplot2 theme used by all standard track panels. Use |
show_panel_border |
Whether to draw panel borders. |
A patchwork object or ggplot object.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_tracks(annotation = gp, gene_id = "GeneA")gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_tracks(annotation = gp, gene_id = "GeneA")
Plot a transcript structure
plot_transcript( object, transcript_id, coordinate = c("transcript", "genomic"), show_cds = TRUE, cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), highlight = NULL, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_transcript( object, transcript_id, coordinate = c("transcript", "genomic"), show_cds = TRUE, cds_height = 0.5, utr_height = 0.25, direction_mode = c("transcript", "gene", "end", "none"), highlight = NULL, gene_palette = "Paired", gene_colors = NULL, gene_border_color = NA, label_position = c("axis", "feature"), label_by = c("gene", "transcript"), text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
object |
A GenePred object. |
transcript_id |
Transcript ID. |
coordinate |
transcript removes introns, genomic keeps genomic scale. |
show_cds |
Whether to distinguish CDS and UTR segments. |
cds_height |
Vertical thickness of CDS rectangles. |
utr_height |
Vertical thickness of UTR/non-coding exon rectangles. |
direction_mode |
Direction-arrow style. |
highlight |
Optional data frame used to shade genomic or transcript intervals. It must contain |
gene_palette |
RColorBrewer palette name used for discrete fills. If the number of discrete groups exceeds the palette maximum, colors are automatically interpolated. |
gene_colors |
Optional custom fill colors for gene model features. Use a named vector such as |
gene_border_color |
Optional rectangle border color. Use |
label_position |
Where to draw feature labels. |
label_by |
Which identifier to use for feature labels. Use |
text_size |
Text size in points for axis text, axis titles, and legends. |
plot_theme |
Base ggplot2 theme. Use |
show_panel_border |
Whether to draw the panel border. |
Common feature names used by gene_colors are UTR, CDS, and exon.
highlight must contain start and end columns. In genomic coordinate
plots these are genomic positions; in transcript coordinate plots they are
spliced transcript positions. See also GeneTrackR-advanced-parameters.
A ggplot object.
gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_transcript(gp, transcript_id = "TxA1", coordinate = "transcript")gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) plot_transcript(gp, transcript_id = "TxA1", coordinate = "transcript")
Draws VCF-derived variant records in a genomic region. This function is
dedicated to variant visualization and can be used directly or through
plot_tracks().
plot_variant( variant, chrom = NULL, start = NULL, end = NULL, variant_type = NULL, color_by = c("variant_type", "filter", "none"), label_by = c("none", "variant_id", "variant_type", "ref", "alt"), variant_shape = c("lollipop", "point", "rug"), variant_palette = "Paired", variant_colors = NULL, point_size = 2, line_width = 0.35, text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_variant( variant, chrom = NULL, start = NULL, end = NULL, variant_type = NULL, color_by = c("variant_type", "filter", "none"), label_by = c("none", "variant_id", "variant_type", "ref", "alt"), variant_shape = c("lollipop", "point", "rug"), variant_palette = "Paired", variant_colors = NULL, point_size = 2, line_width = 0.35, text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
variant |
A VariantTrack object. |
chrom |
Chromosome name. If NULL, all chromosomes in |
start |
Region start in 1-based coordinates. If NULL, the minimum variant position is used. |
end |
Region end in 1-based coordinates. If NULL, the maximum variant position is used. |
variant_type |
Optional variant type filter, such as |
color_by |
Column used for variant colors. Use |
label_by |
Column used for labels. Use |
variant_shape |
Plot geometry. |
variant_palette |
RColorBrewer palette name for variant colors. |
variant_colors |
Optional named or unnamed variant color vector. |
point_size |
Point size. |
line_width |
Line width for lollipop/rug stems. |
text_size |
Text size. |
plot_theme |
Base ggplot2 theme. Use |
show_panel_border |
Whether to draw the panel border. |
A ggplot object.
vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) plot_variant( vcf, chrom = "chr1", start = 12339701L, end = 12352000L )vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) plot_variant( vcf, chrom = "chr1", start = 12339701L, end = 12352000L )
Calculate per-variant phenotype effect sizes from a HapVariant object and draw an ordered effect-size plot. For a two-genotype variant, the effect is the mean difference between the second and first genotype groups. For variants with more than two genotype groups, the effect is the maximum group mean minus the minimum group mean. Point color encodes the signed effect direction and magnitude, with blue for negative effects and red for positive effects.
plot_variant_effect( hap, phenotype, traits = NULL, sample_col = "sample_id", min_group_samples = 2L, test_method = c("t.test", "wilcox.test", "anova", "kruskal.test"), p_adjust = "BH", effect_type = c("absolute", "signed"), top_n = 10L, variant_label = c("variant_id", "pos"), x_axis = c("index", "position"), point_size = 2.2, label_size = 3.2, text_size = 14 )plot_variant_effect( hap, phenotype, traits = NULL, sample_col = "sample_id", min_group_samples = 2L, test_method = c("t.test", "wilcox.test", "anova", "kruskal.test"), p_adjust = "BH", effect_type = c("absolute", "signed"), top_n = 10L, variant_label = c("variant_id", "pos"), x_axis = c("index", "position"), point_size = 2.2, label_size = 3.2, text_size = 14 )
hap |
A HapVariant object from |
phenotype |
A phenotype table returned by |
traits |
Numeric phenotype trait names. Integer and double storage modes are accepted and normalized before reshaping. If NULL, all numeric traits are used. |
sample_col |
Sample column name in phenotype table. |
min_group_samples |
Minimum sample number required for a genotype group. |
test_method |
Significance test method. One of |
p_adjust |
P-value adjustment method passed to |
effect_type |
Which effect value is plotted. One of |
top_n |
Optional number of top variants to label by absolute effect size. |
variant_label |
Column used for variant labels. One of |
x_axis |
X-axis type. One of |
point_size |
Point size. |
label_size |
Text size for top-variant labels. |
text_size |
Base text size. |
A list with figure, effect, and plot_data elements.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "code", min_variant_number = 1 ) plot_variant_effect( hap, phenotype = pheno, traits = "protein_content", min_group_samples = 3 )vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "code", min_variant_number = 1 ) plot_variant_effect( hap, phenotype = pheno, traits = "protein_content", min_group_samples = 3 )
Draws phenotype distributions for genotype groups at one variant site. The
function is designed as the single-variant counterpart of plot_hap_pheno().
Groups are ordered by sample number from left to right, and fill colors are
mapped to the median phenotype value of each genotype group.
plot_variant_pheno( variant, phenotype, traits = NULL, sample_col = "sample_id", variant_id = NULL, chrom = NULL, pos = NULL, start = NULL, end = NULL, samples = NULL, genotype_mode = c("code", "string"), missing_genotype = NA_character_, min_group_samples = 2L, plot_type = c("violin_boxplot", "violin", "boxplot"), test_method = c("t.test", "wilcox.test", "ks.test"), p_adjust = "BH", p_label = c("stars", "number", "both"), p_cutoff = 0.05, p_value_type = c("raw", "adjusted"), show_signif_only = TRUE, show_points = FALSE, show_outliers = FALSE, fill_palette = "Paired", fill_colors = NULL, fill_alpha = 0.75, violin_width = 0.9, box_width = 0.18, bracket_step = 0.08, bracket_tip_fraction = 0.12, x_text_angle = 90, strip_label_width = 24, strip_fill = "white", strip_border_color = NULL, strip_text_lineheight = 0.9, text_size = 14 )plot_variant_pheno( variant, phenotype, traits = NULL, sample_col = "sample_id", variant_id = NULL, chrom = NULL, pos = NULL, start = NULL, end = NULL, samples = NULL, genotype_mode = c("code", "string"), missing_genotype = NA_character_, min_group_samples = 2L, plot_type = c("violin_boxplot", "violin", "boxplot"), test_method = c("t.test", "wilcox.test", "ks.test"), p_adjust = "BH", p_label = c("stars", "number", "both"), p_cutoff = 0.05, p_value_type = c("raw", "adjusted"), show_signif_only = TRUE, show_points = FALSE, show_outliers = FALSE, fill_palette = "Paired", fill_colors = NULL, fill_alpha = 0.75, violin_width = 0.9, box_width = 0.18, bracket_step = 0.08, bracket_tip_fraction = 0.12, x_text_angle = 90, strip_label_width = 24, strip_fill = "white", strip_border_color = NULL, strip_text_lineheight = 0.9, text_size = 14 )
variant |
A VariantTrack object, a VCF file path, a HapVariant object, or a VCF-like data.frame/data.table containing one or more variants with genotype sample columns. |
phenotype |
A phenotype table returned by |
traits |
Phenotype trait names. If NULL, all numeric traits are used. |
sample_col |
Sample column name in phenotype table. |
variant_id |
Optional variant ID to select. |
chrom |
Optional chromosome name used to select a variant. |
pos |
Optional 1-based variant position. This is equivalent to setting
both |
start |
Optional 1-based start position for region-based selection. |
end |
Optional 1-based end position for region-based selection. |
samples |
Optional sample names to keep. |
genotype_mode |
Genotype representation. |
missing_genotype |
Missing genotype label. Default is |
min_group_samples |
Minimum sample number required for a genotype group. |
plot_type |
Plot type. One of |
test_method |
Pairwise test method. One of |
p_adjust |
P-value adjustment method passed to |
p_label |
P-value label style. One of |
p_cutoff |
Significance cutoff used for displaying pairwise comparisons. |
p_value_type |
Which p-value is used for filtering and labeling. One of |
show_signif_only |
Logical. Whether to only display significant comparisons. |
show_points |
Logical. Whether to show sample points. |
show_outliers |
Logical. Whether to show boxplot outliers. |
fill_palette |
RColorBrewer palette name used for median-based genotype fills. |
fill_colors |
Optional custom fill colors for genotype groups. |
fill_alpha |
Alpha value for violin/boxplot fill colors. |
violin_width |
Violin plot width. |
box_width |
Boxplot width. |
bracket_step |
Fraction of y-range used to separate significance brackets. |
bracket_tip_fraction |
Fraction of bracket vertical spacing used for the short downward bracket tips. |
x_text_angle |
Rotation angle for genotype labels on the x-axis. |
strip_label_width |
Maximum character width for wrapping long facet strip labels. |
strip_fill |
Strip background fill color. Default is white. |
strip_border_color |
Strip border color. Default NULL removes the strip border. |
strip_text_lineheight |
Line height used for wrapped facet-strip labels. |
text_size |
Text size. |
A list with figure and pvalue elements. Additional elements include
summary, bracket, plot_data, and variant_data.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) plot_variant_pheno(vcf, phenotype = pheno, variant_id = "varA03", traits = "protein_content", min_group_samples = 3) plot_variant_pheno(vcf, phenotype = pheno, chrom = "chr1", pos = 12342550, traits = "protein_content", genotype_mode = "string", min_group_samples = 3, test_method = "wilcox.test")vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) plot_variant_pheno(vcf, phenotype = pheno, variant_id = "varA03", traits = "protein_content", min_group_samples = 3) plot_variant_pheno(vcf, phenotype = pheno, chrom = "chr1", pos = 12342550, traits = "protein_content", genotype_mode = "string", min_group_samples = 3, test_method = "wilcox.test")
Backward-compatible alias of plot_variant().
plot_variant_track( track, chrom, start, end, color_by = c("variant_type", "filter", "none"), label_by = c("none", "variant_id", "variant_type", "ref", "alt"), variant_palette = "Paired", variant_colors = NULL, text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )plot_variant_track( track, chrom, start, end, color_by = c("variant_type", "filter", "none"), label_by = c("none", "variant_id", "variant_type", "ref", "alt"), variant_palette = "Paired", variant_colors = NULL, text_size = 14, plot_theme = c("bw", "classic", "light", "minimal"), show_panel_border = NULL )
track |
A VariantTrack object. |
chrom |
Chromosome name. If NULL, all chromosomes in |
start |
Region start in 1-based coordinates. If NULL, the minimum variant position is used. |
end |
Region end in 1-based coordinates. If NULL, the maximum variant position is used. |
color_by |
Column used for variant colors. Use |
label_by |
Column used for labels. Use |
variant_palette |
RColorBrewer palette name for variant colors. |
variant_colors |
Optional named or unnamed variant color vector. |
text_size |
Text size. |
plot_theme |
Base ggplot2 theme. Use |
show_panel_border |
Whether to draw the panel border. |
A ggplot object.
vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) plot_variant_track( vcf, chrom = "chr1", start = 12339701L, end = 12352000L )vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) plot_variant_track( vcf, chrom = "chr1", start = 12339701L, end = 12352000L )
Print GeneTrackR phenotype plot result
## S3 method for class 'GeneTrackRPhenoPlot' print(x, ...)## S3 method for class 'GeneTrackRPhenoPlot' print(x, ...)
x |
A GeneTrackRPhenoPlot object returned by plot_hap_pheno() or plot_variant_pheno(). |
... |
Additional arguments. |
Invisibly returns x.
Reads BED3-BED12 style files and converts BED coordinates from 0-based half-open to 1-based closed intervals by default.
read_bed( file, coordinate = c("bed", "granges"), name_col = 4L, type = "BED", verbose = TRUE, progress = interactive() && isTRUE(verbose) )read_bed( file, coordinate = c("bed", "granges"), name_col = 4L, type = "BED", verbose = TRUE, progress = interactive() && isTRUE(verbose) )
file |
BED file path. Gzip-compressed files are supported by |
coordinate |
Input coordinate system. |
name_col |
BED column used as feature name. Default 4. |
type |
Feature type assigned to BED records. |
verbose |
Whether to print progress messages. |
progress |
Whether to show a stage progress bar. |
A FeatureTrack object.
bed_file <- system.file("extdata", "gtr_demo_features.bed", package = "GeneTrackR") features <- read_bed(bed_file, verbose = FALSE, progress = FALSE) features plot_feature_track(features, chrom = "chr1", start = 12338201, end = 12374500)bed_file <- system.file("extdata", "gtr_demo_features.bed", package = "GeneTrackR") features <- read_bed(bed_file, verbose = FALSE, progress = FALSE) features plot_feature_track(features, chrom = "chr1", start = 12338201, end = 12374500)
Read bedGraph, wig, or bigWig signal tracks
read_bwg( files, format = c("auto", "bedgraph", "bigwig", "wig"), sample_names = NULL, strand = NULL, mode = c("lazy", "memory"), genome = NULL, check_chrom = TRUE, use_tabix = c("auto", "yes", "no"), tabix_empty_fallback = FALSE, verbose = TRUE )read_bwg( files, format = c("auto", "bedgraph", "bigwig", "wig"), sample_names = NULL, strand = NULL, mode = c("lazy", "memory"), genome = NULL, check_chrom = TRUE, use_tabix = c("auto", "yes", "no"), tabix_empty_fallback = FALSE, verbose = TRUE )
files |
Signal file paths. |
format |
Input format. Use auto, bedgraph, bigwig, or wig. |
sample_names |
Optional sample names. If NULL, names are inferred from file basenames after removing compression suffixes and signal-track suffixes such as |
strand |
Optional strand labels for files. |
mode |
lazy stores file paths, memory reads data into R. |
genome |
Optional genome label. |
check_chrom |
Whether to check chromosome names for in-memory files. |
use_tabix |
Whether to use tabix/Rsamtools for indexed bedGraph-like files in lazy mode. Accepts |
tabix_empty_fallback |
Logical. Whether an empty tabix result should be verified by a full-file fread query. Default FALSE for performance. Set TRUE only when you suspect the tabix index coordinate convention is incompatible with the queried region. |
verbose |
Logical. Whether to print read/setup progress messages. |
format = "auto" infers the input type from file extensions after removing
compression suffixes such as .gz or .bgz. sample_names = NULL infers
names from file basenames, removing suffixes such as .bedgraph.gz, .bw,
.bigwig, and .wig.
For bigWig and wig files, strand information is not stored in the file, so
the sample is treated as unstranded. For paired plus/minus bedGraph files,
provide strand = c("+", "-") and matching sample_names if strand-specific
filtering is required.
use_tabix = "auto" uses indexed querying only when a .tbi index and an available backend are detected. GeneTrackR first checks the system tabix command and then the R package Rsamtools. Otherwise, lazy bedGraph queries fall back to full-file reading.
BigWig metadata, full-memory loading, and lazy regional queries use the built-in pure-R BigWig reader. No compiled library or external BigWig executable is required.
BwgTrack$seqinfo follows the schema-v2 sequence metadata contract. bigWig
inputs record chromosome lengths from the file header. In-memory bedGraph and
wig inputs record observed chromosome names with unknown lengths (NA).
bedGraph, WIG, and BigWig memory reads are dispatched through one internal pure-R I/O layer so all formats return the same canonical signal schema.
A BwgTrack object.
rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) rnaseqrnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) rnaseq
Read a GenePred annotation file
read_genepred( file, format = c("auto", "genePred", "genePredExt"), coordinate = c("ucsc", "granges"), remove_invalid = TRUE, report_invalid = TRUE, gene_col = c("name2", "name"), transcript_col = "name", verbose = TRUE, progress = interactive() && isTRUE(verbose) )read_genepred( file, format = c("auto", "genePred", "genePredExt"), coordinate = c("ucsc", "granges"), remove_invalid = TRUE, report_invalid = TRUE, gene_col = c("name2", "name"), transcript_col = "name", verbose = TRUE, progress = interactive() && isTRUE(verbose) )
file |
GenePred or GenePredExt file path. |
format |
Input format. Use auto, genePred, or genePredExt. |
coordinate |
Input coordinate system. ucsc means 0-based half-open. |
remove_invalid |
Remove invalid records after validation. |
report_invalid |
Store invalid records in the object validation slot. |
gene_col |
Gene identifier source. name2 is recommended for GenePredExt. |
transcript_col |
Transcript identifier source. |
verbose |
Logical. Whether to print step-level progress messages. Default TRUE. |
progress |
Logical. Whether to show a stage-level progress bar. By default, a progress bar is shown only in interactive sessions when |
Standard GenePred uses name as transcript ID. GenePredExt commonly uses
name as transcript ID and name2 as gene ID, so the default gene_col
tries name2 first and falls back to name when name2 is unavailable.
coordinate = "ucsc" converts 0-based half-open GenePred coordinates to
the package's internal 1-based closed coordinate system.
For large files, verbose = TRUE prints major processing stages, while
progress = TRUE additionally shows a stage-level text progress bar.
A GenePred object.
gp_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") gp <- read_genepred(gp_file, format = "genePredExt", verbose = FALSE) gp head(gp$genes) head(gp$transcripts)gp_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") gp <- read_genepred(gp_file, format = "genePredExt", verbose = FALSE) gp head(gp$genes) head(gp$transcripts)
Read a GFF3 file as a FeatureTrack
read_gff( file, feature_types = NULL, verbose = TRUE, progress = interactive() && isTRUE(verbose) )read_gff( file, feature_types = NULL, verbose = TRUE, progress = interactive() && isTRUE(verbose) )
file |
GFF3 file path. |
feature_types |
Optional feature types to keep, such as |
verbose |
Whether to print progress messages. |
progress |
Whether to show a stage progress bar. The parser reports major stages using the same style as |
A FeatureTrack object.
gff_file <- system.file("extdata", "gtr_demo.gff3", package = "GeneTrackR") gff <- read_gff(gff_file, verbose = FALSE, progress = FALSE) gff head(gff$genes)gff_file <- system.file("extdata", "gtr_demo.gff3", package = "GeneTrackR") gff <- read_gff(gff_file, verbose = FALSE, progress = FALSE) gff head(gff$genes)
Read a GTF file as a FeatureTrack
read_gtf( file, feature_types = NULL, verbose = TRUE, progress = interactive() && isTRUE(verbose) )read_gtf( file, feature_types = NULL, verbose = TRUE, progress = interactive() && isTRUE(verbose) )
file |
GTF file path. |
feature_types |
Optional feature types to keep, such as |
verbose |
Whether to print progress messages. |
progress |
Whether to show a stage progress bar. The parser reports major stages using the same style as |
A FeatureTrack object.
gtf_file <- system.file("extdata", "gtr_demo.gtf", package = "GeneTrackR") gtf <- read_gtf(gtf_file, verbose = FALSE, progress = FALSE) gtf head(gtf$genes)gtf_file <- system.file("extdata", "gtr_demo.gtf", package = "GeneTrackR") gtf <- read_gtf(gtf_file, verbose = FALSE, progress = FALSE) gtf head(gtf$genes)
Reads a phenotype table where the first column contains taxa/sample IDs and all remaining columns are phenotype traits.
read_pheno( file, sep = "auto", sample_col = NULL, na_strings = c("NA", "NaN", "", ".", "null", "NULL"), verbose = TRUE, progress = interactive() && isTRUE(verbose) )read_pheno( file, sep = "auto", sample_col = NULL, na_strings = c("NA", "NaN", "", ".", "null", "NULL"), verbose = TRUE, progress = interactive() && isTRUE(verbose) )
file |
Phenotype file path. |
sep |
Field separator. Use |
sample_col |
Optional sample column name. If NULL, the first column is used. |
na_strings |
Strings treated as missing values. |
verbose |
Logical. Whether to print reading messages. |
progress |
Logical. Reserved for future compact progress display. |
A data.table with the first column standardized as sample_id.
pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") pheno <- read_pheno(pheno_file, verbose = FALSE) head(pheno) summary_pheno(pheno) plot_pheno(pheno, traits = c("plant_height", "seed_weight"))pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") pheno <- read_pheno(pheno_file, verbose = FALSE) head(pheno) summary_pheno(pheno) plot_pheno(pheno, traits = c("plant_height", "seed_weight"))
Reads VCF records and stores them as genomic point variants. Standard VCF
columns are always imported. If genotype sample columns are present, they are
preserved for haplotype analysis. For bgzip-compressed VCF files with a tabix
index, chrom, start, and end can be supplied to load only a genomic
interval instead of parsing the whole VCF file.
read_vcf( file, keep_genotype = TRUE, mode = c("auto", "memory", "lazy"), chrom = NULL, start = NULL, end = NULL, verbose = TRUE, progress = interactive() && isTRUE(verbose) )read_vcf( file, keep_genotype = TRUE, mode = c("auto", "memory", "lazy"), chrom = NULL, start = NULL, end = NULL, verbose = TRUE, progress = interactive() && isTRUE(verbose) )
file |
VCF file path. Plain VCF, gzip-compressed VCF, and bgzip VCF are supported. |
keep_genotype |
Logical. Whether to keep FORMAT and sample genotype columns. |
mode |
Reading mode. |
chrom |
Optional chromosome name for indexed regional reading. |
start |
Optional 1-based region start for indexed regional reading. |
end |
Optional 1-based region end for indexed regional reading. |
verbose |
Logical. Whether to print progress messages. |
progress |
Logical. Whether to print a compact stage-level progress indicator. |
A VariantTrack object.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") variants <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) region_variants <- retrieve_vcf( variants, chrom = "chr1", start = 12339700, end = 12343200, as = "VariantTrack", verbose = FALSE ) plot_variant(region_variants, chrom = "chr1", start = 12339700, end = 12343200)vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") variants <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) region_variants <- retrieve_vcf( variants, chrom = "chr1", start = 12339700, end = 12343200, as = "VariantTrack", verbose = FALSE ) plot_variant(region_variants, chrom = "chr1", start = 12339700, end = 12343200)
Backward-compatible alias of read_vcf().
read_vcf_track( file, keep_genotype = TRUE, mode = c("auto", "memory", "lazy"), chrom = NULL, start = NULL, end = NULL, verbose = TRUE, progress = interactive() && isTRUE(verbose) )read_vcf_track( file, keep_genotype = TRUE, mode = c("auto", "memory", "lazy"), chrom = NULL, start = NULL, end = NULL, verbose = TRUE, progress = interactive() && isTRUE(verbose) )
file |
VCF file path. Plain VCF, gzip-compressed VCF, and bgzip VCF are supported. |
keep_genotype |
Logical. Whether to keep FORMAT and sample genotype columns. |
mode |
Reading mode. |
chrom |
Optional chromosome name for indexed regional reading. |
start |
Optional 1-based region start for indexed regional reading. |
end |
Optional 1-based region end for indexed regional reading. |
verbose |
Logical. Whether to print progress messages. |
progress |
Logical. Whether to print a compact stage-level progress indicator. |
A VariantTrack object.
vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) read_vcf_track( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE )vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) read_vcf_track( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE )
Collapse original haplotypes into refined haplotype groups according to
phenotype similarity. Haplotypes are merged only when their pairwise
phenotype difference is not significant and, optionally, the absolute mean
difference is smaller than effect_threshold.
refine_haplotype( hap, phenotype, traits = NULL, sample_col = "sample_id", min_hap_samples = 2L, test_method = c("t.test", "wilcox.test", "ks.test"), p_adjust = "BH", alpha = 0.05, effect_threshold = NULL, group_prefix = "RHap", mixed_label = "mixed" )refine_haplotype( hap, phenotype, traits = NULL, sample_col = "sample_id", min_hap_samples = 2L, test_method = c("t.test", "wilcox.test", "ks.test"), p_adjust = "BH", alpha = 0.05, effect_threshold = NULL, group_prefix = "RHap", mixed_label = "mixed" )
hap |
A HapVariant object from |
phenotype |
A phenotype table returned by |
traits |
Phenotype trait names. If NULL, all numeric traits are used. |
sample_col |
Sample column name in phenotype table. |
min_hap_samples |
Minimum sample number required for an original haplotype. |
test_method |
Pairwise test method. One of |
p_adjust |
P-value adjustment method passed to |
alpha |
Adjusted p-value cutoff. Pairs with adjusted p-value larger than
|
effect_threshold |
Optional maximum absolute mean difference for merging haplotypes. If NULL, only the significance criterion is used. |
group_prefix |
Prefix for refined haplotype IDs. |
mixed_label |
Label used for variant states that are heterogeneous within a refined haplotype group. |
A HapRefined object. The object contains refined_hap, which is a
HapVariant-compatible object and can be passed to plot_hap_pheno() and
plot_hap_variant().
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) refined <- refine_haplotype( hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3, effect_threshold = 0.5 ) refined$refined_haplotypes plot_hap_pheno( refined$refined_hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3 )vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") pheno_file <- system.file("extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR") anno_file <- system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) pheno <- read_pheno(pheno_file, verbose = FALSE) anno <- read_genepred(anno_file, format = "genePredExt", verbose = FALSE) hap <- hap_variant( vcf, annotation = anno, gene_id = "GeneA", genotype_mode = "string", min_variant_number = 1 ) refined <- refine_haplotype( hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3, effect_threshold = 0.5 ) refined$refined_haplotypes plot_hap_pheno( refined$refined_hap, phenotype = pheno, traits = "protein_content", min_hap_samples = 3 )
retrieve_bwg() is the unified signal retrieval API in GeneTrackR. It
retrieves signal intervals from bedGraph, wig, or bigWig tracks by genomic
region.
retrieve_bwg( object, chrom = NULL, start = NULL, end = NULL, annotation = NULL, gene_id = NULL, transcript_id = NULL, upstream = 0L, downstream = 0L, strand_aware = TRUE, samples = NULL, strand = c("ignore", "+", "-", "both", "auto"), strand_policy = c("ignore_unstranded", "strict"), as = c("data.table", "BwgTrack", "GRanges"), verbose = FALSE, progress = interactive() && isTRUE(verbose), keep_empty_samples = FALSE, tabix_empty_fallback = NULL )retrieve_bwg( object, chrom = NULL, start = NULL, end = NULL, annotation = NULL, gene_id = NULL, transcript_id = NULL, upstream = 0L, downstream = 0L, strand_aware = TRUE, samples = NULL, strand = c("ignore", "+", "-", "both", "auto"), strand_policy = c("ignore_unstranded", "strict"), as = c("data.table", "BwgTrack", "GRanges"), verbose = FALSE, progress = interactive() && isTRUE(verbose), keep_empty_samples = FALSE, tabix_empty_fallback = NULL )
object |
A BwgTrack object returned by |
chrom |
Chromosome name. Required for direct region queries. |
start |
Region start in 1-based closed coordinates. Required for direct region queries. |
end |
Region end in 1-based closed coordinates. Required for direct region queries. |
annotation |
Optional GenePred/Feature annotation object used for gene/transcript-aware retrieval. |
gene_id |
Optional gene ID. When supplied, |
transcript_id |
Optional transcript ID. When supplied, |
upstream |
Upstream flanking length in bp for gene/transcript queries. |
downstream |
Downstream flanking length in bp for gene/transcript queries. |
strand_aware |
Logical. Whether upstream/downstream should follow gene/transcript strand direction. |
samples |
Optional character vector of sample IDs to retrieve. If NULL, all samples are queried. |
strand |
Strand selector. Use |
strand_policy |
How to handle strand filtering for unstranded signal
files. |
as |
Output type. |
verbose |
Logical. Whether to print progress messages. |
progress |
Logical. Whether to show a text progress bar for multi-sample queries. |
keep_empty_samples |
Logical. If TRUE, samples without signal in the requested region are returned as zero-valued placeholder intervals. This is useful for preserving empty facets in plots. |
tabix_empty_fallback |
Optional logical. If TRUE, empty tabix results are verified by full-file fread. Keep FALSE for speed unless debugging tabix coordinate/index issues. |
A data.table, BwgTrack object, or GRanges object. BwgTrack subsets retain sequence metadata for the selected samples and chromosome when available.
rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) retrieve_bwg( rnaseq, chrom = "chr1", start = 12339001, end = 12352000, strand = "+" )rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) retrieve_bwg( rnaseq, chrom = "chr1", start = 12339001, end = 12352000, strand = "+" )
retrieve_feature() extracts a true sub-object from a Feature/GenePred-compatible
annotation object. By default it returns a Feature/GenePred-compatible object.
Use as = "data.table" only when a plain table is required.
retrieve_feature( object, pattern = NULL, level = c("feature", "gene", "transcript", "exon"), chrom = NULL, start = NULL, end = NULL, mode = c("overlap", "within", "trim"), gene_id = NULL, transcript_id = NULL, type = NULL, ignore_case = TRUE, fixed = FALSE, as = c("Feature", "data.table") )retrieve_feature( object, pattern = NULL, level = c("feature", "gene", "transcript", "exon"), chrom = NULL, start = NULL, end = NULL, mode = c("overlap", "within", "trim"), gene_id = NULL, transcript_id = NULL, type = NULL, ignore_case = TRUE, fixed = FALSE, as = c("Feature", "data.table") )
object |
A Feature-compatible annotation object. |
pattern |
Optional pattern used for ID/name matching. |
level |
Output table level when |
chrom |
Optional chromosome. |
start |
Optional start coordinate. |
end |
Optional end coordinate. |
mode |
Region matching mode. |
gene_id |
Optional gene ID filter. Exact matching is used. |
transcript_id |
Optional transcript ID filter. Exact matching is used. |
type |
Optional feature type filter for feature-table retrieval. |
ignore_case |
Logical. Whether pattern matching ignores case. |
fixed |
Logical. Whether pattern is fixed text. |
as |
Output type. Default |
A Feature/GenePred-compatible object or a data.table.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) retrieve_feature(gp, gene_id = "GeneA")gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) retrieve_feature(gp, gene_id = "GeneA")
Retrieves VCF records by optional genomic region, gene/transcript locator,
variant ID, type, or text pattern. With an in-memory VariantTrack, all
location arguments may be omitted to query the full object. For large
bgzip-compressed VCF files with a tabix index, a complete genomic region is
queried with Rsamtools::scanTabix(); non-regional filters require reading
the full file before filtering.
retrieve_vcf( object, pattern = NULL, chrom = NULL, start = NULL, end = NULL, annotation = NULL, gene_id = NULL, transcript_id = NULL, upstream = 0L, downstream = 0L, strand_aware = TRUE, variant_id = NULL, variant_type = NULL, keep_genotype = TRUE, ignore_case = TRUE, fixed = FALSE, as = c("data.table", "VariantTrack", "GRanges"), verbose = TRUE, progress = interactive() && isTRUE(verbose) )retrieve_vcf( object, pattern = NULL, chrom = NULL, start = NULL, end = NULL, annotation = NULL, gene_id = NULL, transcript_id = NULL, upstream = 0L, downstream = 0L, strand_aware = TRUE, variant_id = NULL, variant_type = NULL, keep_genotype = TRUE, ignore_case = TRUE, fixed = FALSE, as = c("data.table", "VariantTrack", "GRanges"), verbose = TRUE, progress = interactive() && isTRUE(verbose) )
object |
A VariantTrack object or a path to a VCF/VCF.GZ file. |
pattern |
Optional text pattern matched against variant ID, REF, ALT, INFO, and variant type. |
chrom |
Optional chromosome name or names. May be used alone as a chromosome filter. Required when |
start |
Optional 1-based region start. Must be supplied together with |
end |
Optional 1-based region end. Must be supplied together with |
annotation |
Optional GenePred/Feature annotation object used for gene/transcript-aware retrieval. |
gene_id |
Optional gene ID. When supplied, |
transcript_id |
Optional transcript ID. When supplied, |
upstream |
Upstream flanking length in bp for gene/transcript queries. |
downstream |
Downstream flanking length in bp for gene/transcript queries. |
strand_aware |
Logical. Whether upstream/downstream should follow gene/transcript strand direction. |
variant_id |
Optional variant ID vector. |
variant_type |
Optional variant type vector, such as |
keep_genotype |
Logical. Whether to keep FORMAT and sample genotype columns when |
ignore_case |
Logical. Whether pattern matching ignores case. |
fixed |
Logical. Whether pattern is matched as a fixed string. |
as |
Output type: |
verbose |
Logical. Whether to print progress messages. |
progress |
Logical. Whether to print a compact stage-level progress indicator. |
A data.table, VariantTrack, or GenomicRanges::GRanges object.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) retrieve_vcf(vcf, chrom = "chr1", start = 12339700, end = 12343200) retrieve_vcf(vcf, variant_type = "SNP") retrieve_vcf(vcf, pattern = "varA", fixed = TRUE) vt <- retrieve_vcf(vcf, chrom = "chr1", start = 12339700, end = 12343200, as = "VariantTrack") vt retrieve_vcf(vcf, chrom = "chr1", start = 12339700, end = 12343200, as = "GRanges")vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) retrieve_vcf(vcf, chrom = "chr1", start = 12339700, end = 12343200) retrieve_vcf(vcf, variant_type = "SNP") retrieve_vcf(vcf, pattern = "varA", fixed = TRUE) vt <- retrieve_vcf(vcf, chrom = "chr1", start = 12339700, end = 12343200, as = "VariantTrack") vt retrieve_vcf(vcf, chrom = "chr1", start = 12339700, end = 12343200, as = "GRanges")
Get chromosome information from BwgTrack objects
seqinfo_bwg(object, samples = NULL)seqinfo_bwg(object, samples = NULL)
object |
A BwgTrack object. |
samples |
Optional sample IDs. |
Schema-v2 objects return stored sequence metadata directly. Legacy objects
without a seqinfo slot query chromosome metadata from bigWig source files
through the built-in pure-R backend.
A data.table containing chromosome names and lengths for each sample.
signal_file <- system.file( "extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR" ) signal <- read_bwg( signal_file, format = "bedgraph", sample_names = "RNA_plus", strand = "+", mode = "memory", verbose = FALSE ) seqinfo_bwg(signal)signal_file <- system.file( "extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR" ) signal <- read_bwg( signal_file, format = "bedgraph", sample_names = "RNA_plus", strand = "+", mode = "memory", verbose = FALSE ) seqinfo_bwg(signal)
Slice signal tracks by genomic region
slice_bwg( object, chrom, start, end, samples = NULL, strand = "ignore", as = c("BwgTrack", "data.frame", "GRanges") )slice_bwg( object, chrom, start, end, samples = NULL, strand = "ignore", as = c("BwgTrack", "data.frame", "GRanges") )
object |
A BwgTrack object. |
chrom |
Chromosome name. |
start |
Region start. |
end |
Region end. |
samples |
Optional sample IDs. |
strand |
Strand selector. For unstranded bigWig/wig tracks, '+' and '-' do not filter records. |
as |
Return type. Use |
A BwgTrack, data.table, or GRanges object.
rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) slice_bwg( rnaseq, chrom = "chr1", start = 12339001, end = 12352000, strand = "+", as = "BwgTrack" )rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) slice_bwg( rnaseq, chrom = "chr1", start = 12339001, end = 12352000, strand = "+", as = "BwgTrack" )
Summarize signal tracks within a region
summary_bwg(object, chrom = NULL, start = NULL, end = NULL, samples = NULL)summary_bwg(object, chrom = NULL, start = NULL, end = NULL, samples = NULL)
object |
A BwgTrack object. |
chrom |
Optional chromosome name. |
start |
Optional region start. |
end |
Optional region end. |
samples |
Optional sample IDs. |
A data.table summary.
signal_file <- system.file( "extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR" ) signal <- read_bwg( signal_file, format = "bedgraph", sample_names = "RNA_plus", strand = "+", mode = "memory", verbose = FALSE ) summary_bwg(signal)signal_file <- system.file( "extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR" ) signal <- read_bwg( signal_file, format = "bedgraph", sample_names = "RNA_plus", strand = "+", mode = "memory", verbose = FALSE ) summary_bwg(signal)
summary_feature() is the unified summary API for GenePred, GTF, GFF, and
BED-derived annotation objects.
summary_feature( object, chrom = NULL, start = NULL, end = NULL, level = c("feature", "gene", "transcript", "exon"), by = c("chrom", "type") )summary_feature( object, chrom = NULL, start = NULL, end = NULL, level = c("feature", "gene", "transcript", "exon"), by = c("chrom", "type") )
object |
A Feature-compatible annotation object. |
chrom |
Optional chromosome filter. |
start |
Optional region start. |
end |
Optional region end. |
level |
Summary level. Use |
by |
Grouping columns used when |
A data.table summary.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) summary_feature(gp, level = "gene")gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) summary_feature(gp, level = "gene")
Summarize phenotype traits
summary_pheno(pheno, sample_col = "sample_id")summary_pheno(pheno, sample_col = "sample_id")
pheno |
A phenotype data.frame/data.table returned by |
sample_col |
Sample column name. |
A data.table summarizing trait type, missing values, and basic statistics.
pheno_file <- system.file( "extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR" ) pheno <- read_pheno(pheno_file, verbose = FALSE) summary_pheno(pheno)pheno_file <- system.file( "extdata", "gtr_demo_pheno.tsv", package = "GeneTrackR" ) pheno <- read_pheno(pheno_file, verbose = FALSE) summary_pheno(pheno)
summary_vcf() is the unified summary API for VCF-derived VariantTrack
objects. When no genomic range is supplied, the full in-memory object is
summarized. For lazy tracks, an omitted range causes the source VCF to be
read before summarization.
summary_vcf( object, chrom = NULL, start = NULL, end = NULL, by = c("chrom", "variant_type") )summary_vcf( object, chrom = NULL, start = NULL, end = NULL, by = c("chrom", "variant_type") )
object |
A VariantTrack object. |
chrom |
Optional chromosome filter. May be used without |
start |
Optional 1-based start coordinate. Must be paired with |
end |
Optional 1-based end coordinate. Must be paired with |
by |
Grouping columns. Default |
A data.table summary.
vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) summary_vcf(vcf) summary_vcf(vcf, chrom = "chr1")vcf_file <- system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR") vcf <- read_vcf(vcf_file, mode = "memory", verbose = FALSE) summary_vcf(vcf) summary_vcf(vcf, chrom = "chr1")
Validate a BwgTrack object
validate_bwg(object)validate_bwg(object)
object |
A BwgTrack object. |
A validation list.
signal_file <- system.file( "extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR" ) signal <- read_bwg( signal_file, format = "bedgraph", sample_names = "RNA_plus", strand = "+", mode = "memory", verbose = FALSE ) validate_bwg(signal)signal_file <- system.file( "extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR" ) signal <- read_bwg( signal_file, format = "bedgraph", sample_names = "RNA_plus", strand = "+", mode = "memory", verbose = FALSE ) validate_bwg(signal)
validate_feature() is the unified validation entry for annotation data. It
validates BED/GFF/GTF/GenePred-derived Feature objects. If gene-model tables
are present, transcript/exon consistency is checked in addition to the flat
standardized feature table.
validate_feature(object, check_gene_model = TRUE)validate_feature(object, check_gene_model = TRUE)
object |
A Feature-compatible annotation object. |
check_gene_model |
Logical. Whether to check derived gene-model tables when transcripts and exons are available. |
A validation list with invalid_records, invalid_summary, and
warnings.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) validate_feature(gp)gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) validate_feature(gp)
validate_vcf() validates genome-level variant records stored in a
VariantTrack object. It checks chromosome and position fields, allele
fields, duplicated variant IDs, and consistency between pos, start, and
end when those columns are available.
validate_vcf(object)validate_vcf(object)
object |
A VariantTrack object. |
A validation list with invalid_records, invalid_summary, and
warnings.
vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) validate_vcf(vcf)vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) validate_vcf(vcf)
VariantTrack() stores VCF-like variant records as genomic point features.
Coordinates are stored internally as 1-based positions with start == end.
VariantTrack(data = NULL, meta = list())VariantTrack(data = NULL, meta = list())
data |
A data.frame or data.table containing at least |
meta |
A list of metadata. |
A VariantTrack object.
VariantTrack(data.frame(chrom = "chr1", pos = 10L, ref = "A", alt = "G"))VariantTrack(data.frame(chrom = "chr1", pos = 10L, ref = "A", alt = "G"))
Writes a BwgTrack object to bedGraph, wig, or bigWig files. All three
formats are written directly in pure R. bigWig output uses GeneTrackR's
built-in binary writer and requires chromosome sizes; no external conversion
program or compiled library is required. All in-memory formats are dispatched
through the same internal pure-R I/O layer.
For in-memory BwgTrack objects, signal records are written from object$data.
For lazy objects, direct conversion is not possible because signal records are
not loaded; if the requested format matches the original file format, the
original files are copied to the output directory.
write_bwg( object, outdir, format = c("bedgraph", "wig", "bigwig"), samples = NULL, chrom_sizes = NULL, overwrite = FALSE, compress = FALSE )write_bwg( object, outdir, format = c("bedgraph", "wig", "bigwig"), samples = NULL, chrom_sizes = NULL, overwrite = FALSE, compress = FALSE )
object |
A |
outdir |
Output directory. |
format |
Output format. One of |
samples |
Optional sample IDs to write. Default writes all samples. |
chrom_sizes |
Chromosome sizes for bigWig output. Can be a file path or a data.frame/data.table with two columns: chromosome and size. |
overwrite |
Whether to overwrite existing files. |
compress |
Whether to gzip-compress bedGraph or wig output. |
Invisibly returns a data.table containing sample IDs and output files.
rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) outdir <- tempfile("gtr_signal_") write_bwg(rnaseq, outdir = outdir, format = "bedgraph", overwrite = TRUE)rnaseq <- read_bwg( system.file("extdata", "gtr_demo_rnaseq_plus.bedgraph", package = "GeneTrackR"), format = "bedgraph", sample_names = "RNA_seq_plus", strand = "+", mode = "memory", verbose = FALSE ) outdir <- tempfile("gtr_signal_") write_bwg(rnaseq, outdir = outdir, format = "bedgraph", overwrite = TRUE)
Writes a unified Feature annotation object to GenePred, GenePredExt, GFF3,
GTF, or BED format. This is the main output function for annotation tracks
produced by read_genepred(), read_gff(), read_gtf(), or read_bed().
write_feature( object, file, format = c("auto", "genepred", "genepredext", "gff", "gtf", "bed6", "bed12"), coordinate = c("ucsc", "granges"), overwrite = FALSE, keep_attributes = TRUE, sort_output = TRUE, chrom_order = NULL )write_feature( object, file, format = c("auto", "genepred", "genepredext", "gff", "gtf", "bed6", "bed12"), coordinate = c("ucsc", "granges"), overwrite = FALSE, keep_attributes = TRUE, sort_output = TRUE, chrom_order = NULL )
object |
A |
file |
Output file path. |
format |
Output format. Use |
coordinate |
Output coordinate system for GenePred/BED-like formats.
|
overwrite |
Whether to overwrite an existing file. |
keep_attributes |
Whether to reuse existing |
sort_output |
Whether to sort records before writing. Default TRUE. GenePred output is sorted by chromosome and transcript start. GFF/GTF output is sorted by chromosome, start, and feature hierarchy. |
chrom_order |
Optional chromosome order used for sorting. It can be NULL, a character vector of chromosome names, a data frame whose first column contains chromosome names, or a FASTA index |
Invisibly returns the output file path.
gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) outfile <- tempfile(fileext = ".bed") write_feature(gp, outfile, format = "bed12", overwrite = TRUE)gp <- read_genepred( system.file("extdata", "gtr_demo.genePredExt", package = "GeneTrackR"), format = "genePredExt", verbose = FALSE, progress = FALSE ) outfile <- tempfile(fileext = ".bed") write_feature(gp, outfile, format = "bed12", overwrite = TRUE)
Backward-compatible wrapper around write_feature().
write_feature_track( object, file, format = c("bed12", "bed6", "gff", "gtf", "genepred", "genepredext"), sort_output = TRUE, chrom_order = NULL )write_feature_track( object, file, format = c("bed12", "bed6", "gff", "gtf", "genepred", "genepredext"), sort_output = TRUE, chrom_order = NULL )
object |
A |
file |
Output file path. |
format |
Output format. Use |
sort_output |
Whether to sort records before writing. Default TRUE. GenePred output is sorted by chromosome and transcript start. GFF/GTF output is sorted by chromosome, start, and feature hierarchy. |
chrom_order |
Optional chromosome order used for sorting. It can be NULL, a character vector of chromosome names, a data frame whose first column contains chromosome names, or a FASTA index |
Invisibly returns the output file path.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) features <- as_feature(gp) outfile <- tempfile(fileext = ".bed") write_feature_track(features, outfile)gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) features <- as_feature(gp) outfile <- tempfile(fileext = ".bed") write_feature_track(features, outfile)
Backward-compatible wrapper around write_feature().
write_genepred( object, file, format = c("genePred", "genePredExt"), coordinate = c("ucsc", "granges"), sort_output = TRUE, chrom_order = NULL )write_genepred( object, file, format = c("genePred", "genePredExt"), coordinate = c("ucsc", "granges"), sort_output = TRUE, chrom_order = NULL )
object |
A |
file |
Output file path. |
format |
Output format. Use |
coordinate |
Output coordinate system for GenePred/BED-like formats.
|
sort_output |
Whether to sort records before writing. Default TRUE. GenePred output is sorted by chromosome and transcript start. GFF/GTF output is sorted by chromosome, start, and feature hierarchy. |
chrom_order |
Optional chromosome order used for sorting. It can be NULL, a character vector of chromosome names, a data frame whose first column contains chromosome names, or a FASTA index |
Invisibly returns the output file path.
gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) outfile <- tempfile(fileext = ".genePred") write_genepred(gp, outfile)gp_file <- system.file( "extdata", "gtr_demo.genePredExt", package = "GeneTrackR" ) gp <- read_genepred( gp_file, format = "genePredExt", verbose = FALSE, progress = FALSE ) outfile <- tempfile(fileext = ".genePred") write_genepred(gp, outfile)
Backward-compatible wrapper around write_vcf().
write_variant_track(object, file, overwrite = FALSE, include_header = TRUE)write_variant_track(object, file, overwrite = FALSE, include_header = TRUE)
object |
A |
file |
Output VCF file path. |
overwrite |
Whether to overwrite an existing file. |
include_header |
Whether to include minimal VCF header lines. |
Invisibly returns the output file path.
vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) outfile <- tempfile(fileext = ".vcf") write_variant_track(vcf, outfile, overwrite = TRUE)vcf_file <- system.file( "extdata", "gtr_demo_variants.vcf", package = "GeneTrackR" ) vcf <- read_vcf( vcf_file, mode = "memory", verbose = FALSE, progress = FALSE ) outfile <- tempfile(fileext = ".vcf") write_variant_track(vcf, outfile, overwrite = TRUE)
Write a VariantTrack object to VCF
write_vcf(object, file, overwrite = FALSE, include_header = TRUE)write_vcf(object, file, overwrite = FALSE, include_header = TRUE)
object |
A |
file |
Output VCF file path. |
overwrite |
Whether to overwrite an existing file. |
include_header |
Whether to include minimal VCF header lines. |
Invisibly returns the output file path.
vcf <- read_vcf( system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR"), mode = "memory", verbose = FALSE, progress = FALSE ) outfile <- tempfile(fileext = ".vcf") write_vcf(vcf, outfile, overwrite = TRUE)vcf <- read_vcf( system.file("extdata", "gtr_demo_variants.vcf", package = "GeneTrackR"), mode = "memory", verbose = FALSE, progress = FALSE ) outfile <- tempfile(fileext = ".vcf") write_vcf(vcf, outfile, overwrite = TRUE)