@Nicolas Please do you know explain me why you use this command:
exonNumber=n()
Thank you
• 0 views
•
link
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?
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

Log in to answer this question.
Did you do first do:
I assume you are interested in human data?
Yes of course:
It looks great. I don't know tidyverse package, please could I do it something similarly also with dplyr?
tidyverse is a collection of package that includes dplyr ;) https://www.tidyverse.org/packages/
marija : Please use
ADD COMMENT/ADD REPLYwhen responding to existing posts to keep threads logically organized.@genomax : better put this comment under my post as it's related to dplyr
@Nicolas: Mods can only move comments (that are not real answers) to the top post. We can't select a specific location to move them to in the thread. It is not ideal but the only option currently possible. If marija reposts under your answer then we can delete this set here.
Sorry. And @Nicolas thank you very much.
Accept @Nicolas' answer (green check mark) if you are happy with it.
Sorry didn't know that.