## transcripts(), exons(), genes():
txdb <- loadDb(system.file("extdata", "hg19_knownGene_sample.sqlite",
package="GenomicFeatures"))
vals <- list(tx_chrom = c("chr3", "chr5"), tx_strand = "+")
transcripts(txdb, vals)
exons(txdb, vals=list(exon_id=1), columns=c("EXONID", "TXNAME"))
exons(txdb, vals=list(tx_name="uc009vip.1"), columns=c("EXONID",
"TXNAME"))
genes(txdb) # a GRanges object
cols <- c("tx_id", "tx_chrom", "tx_strand",
"exon_id", "exon_chrom", "exon_strand")
single_strand_genes <- genes(txdb, columns=cols)
## Because we've returned single strand genes only, the "tx_chrom"
## and "exon_chrom" metadata columns are guaranteed to match
## 'seqnames(single_strand_genes)':
stopifnot(identical(as.character(seqnames(single_strand_genes)),
as.character(mcols(single_strand_genes)$tx_chrom)))
stopifnot(identical(as.character(seqnames(single_strand_genes)),
as.character(mcols(single_strand_genes)$exon_chrom)))
## and also the "tx_strand" and "exon_strand" metadata columns are
## guaranteed to match 'strand(single_strand_genes)':
stopifnot(identical(as.character(strand(single_strand_genes)),
as.character(mcols(single_strand_genes)$tx_strand)))
stopifnot(identical(as.character(strand(single_strand_genes)),
as.character(mcols(single_strand_genes)$exon_strand)))
all_genes <- genes(txdb, columns=cols, single.strand.genes.only=FALSE)
all_genes # a GRangesList object
multiple_strand_genes <- all_genes[elementLengths(all_genes) >= 2]
multiple_strand_genes
mcols(multiple_strand_genes)
## microRNAs() :
## Not run: library(TxDb.Hsapiens.UCSC.hg19.knownGene)
# library(mirbase.db)
# microRNAs(TxDb.Hsapiens.UCSC.hg19.knownGene)
# ## End(Not run)
## promoters() :
head(promoters(txdb, 100, 50))
Run the code above in your browser using DataCamp Workspace