Plotting a single transcript with ggbio
1
2
Entering edit mode
7.3 years ago
longoka ▴ 40

I'm trying to create the plot below, but with only a single transcript (uc062uto.1) displayed, not all of the variants (see below).

enter image description here

What am I missing?

The code I'm using to make this image:

# simple genomic/transcript map

rm(list = ls()) # clear workspace

Gene <- "HTT"

require(biomaRt)
require(ggbio)
require(Biostrings)
require(ShortRead)
require(BSgenome)
require(GenomicFeatures)

## get gene ranges, strand, based on gene name (biomaRt functions)
mart <- useMart("ENSEMBL_MART_ENSEMBL", host = "useast.ensembl.org")
datasets <- listDatasets(mart)
mart <- useDataset("hsapiens_gene_ensembl",mart)

r1 <- getBM(filters="external_gene_name",
            values = Gene,
            attributes=c("external_gene_name",
                         "chromosome_name",
                         "start_position",
                         "end_position",
                         "strand",
                         "refseq_mrna",
                         "entrezgene",
                         "ucsc",
                         "ensembl_gene_id",
                         "hamap"),
            mart = mart)
r1 <- r1[r1$refseq_mrna != "",]

CHR <- paste("chr",r1$chromosome_name[1], sep = "")
START <- r1$start_position[1]
END <- r1$end_position[1]
if (r1$strand[1] == 1) {
  STRAND = "+"
  } else {
    STRAND = "-"
  }

library(TxDb.Hsapiens.UCSC.hg38.knownGene) # knowngene db for hg38
txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene
gr <- GRanges(CHR, IRanges(START, END), strand = STRAND)
p <- autoplot(txdb,
              which = gr,
              ylab = paste(Gene," [",CHR,":",START,"-",END,"]", sep = ""),
              geom = "full",
              coord = "genome",
              layout = "linear",
              strand = STRAND)
p
ggbio GenomicFeatures • 4.1k views
ADD COMMENT
0
Entering edit mode

Works like a charm; I think I need to verse myself a bit better on all the functions in the GenomicFeatures package. Thank you!

ADD REPLY
1
Entering edit mode
7.3 years ago
h.mon 35k

There may be better ways, but one way would be creating your own TxDB object:

library(ggbio)
library(GenomicFeatures)
library(TxDb.Hsapiens.UCSC.hg38.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene

gr <- subset(transcripts(txdb), tx_name == "uc062uto.1")

tx <- makeTxDbFromUCSC(
  genome="hg38",
  tablename="knownGene",
  transcript_ids="uc062uto.1",
  url="http://genome.ucsc.edu/cgi-bin/",
  goldenPath_url="http://hgdownload.cse.ucsc.edu/goldenPath" )

p <- autoplot(tx,
              which = gr,
              geom = "full",
              coord = "genome",
              layout = "linear" )
p
ADD COMMENT

Login before adding your answer.

Traffic: 1160 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6