How to get the number of exons and visualize them?
1
2
Entering edit mode
7.0 years ago
marija ▴ 80

Hello everyone, I would like to ask you how can I get the number of exon? I want visualize gene length vs. number of exons in gene.

For example:

I have the length of the gene:

exons <- getBM(attributes = c("external_gene_name","start_position","end_position","ensembl_exon_id"),
          filters = "chromosome_name",
          values = "21",
          mart = genes)
exons[5] <- exons$end_position - exons$start_position
names(exons)[5] <- "gene_length"

I tried to find out the number of exons:

as.data.frame(table(exons$ensembl_exon_id))

But now, I don't know what else. Please, somebody would help me?

R • 2.1k views
ADD COMMENT
6
Entering edit mode
7.0 years ago

Something like :

require(tidyverse)
genes <- useDataset("hsapiens_gene_ensembl",mart=ensembl)
exons <- getBM(attributes =
      c("external_gene_name","start_position","end_position","ensembl_exon_id"),
      filters = "chromosome_name",
      values = "21",
      mart = genes)
exons <- as.tibble(exons)
exons.plot <- exons %>% 
    mutate(len=end_position-start_position) %>% 
    group_by(external_gene_name) %>% 
    summarize(geneLen=sum(len),exonNumber=n())
# plot
ggplot(exons.plot,aes(x=geneLen,y=exonNumber))+
  geom_point(alpha=0.5)+
  scale_y_log10()+
  scale_x_log10()+
  theme_bw()

FYI you should use ensembl_gene_id instead of gene name

enter image description here

ADD COMMENT
0
Entering edit mode

@Nicolas Please do you know explain me why you use this command:

exonNumber=n()

Thank you

ADD REPLY
0
Entering edit mode

n() reports the number of elements in each group thus the number of exons

ADD REPLY

Login before adding your answer.

Traffic: 2973 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