Question: Plotting a single transcript with ggbio
1
gravatar for longoka
2.5 years ago by
longoka30
Cambridge/MA
longoka30 wrote:

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
genomicfeatures ggbio • 1.8k views
ADD COMMENTlink modified 2.5 years ago • written 2.5 years ago by longoka30

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 REPLYlink written 2.5 years ago by longoka30
1
gravatar for h.mon
2.5 years ago by
h.mon29k
Brazil
h.mon29k wrote:

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 COMMENTlink modified 2.5 years ago • written 2.5 years ago by h.mon29k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1591 users visited in the last hour