This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Biomart, Sort Genes After Their Location On The Genome

Hi,

I am trying to retrive for a list of genes with their location on the chromosomes:

gene_locations<-getBM(attributes = c("ensembl_gene_id","chromosome_name", "start_position", "end_position"), filters='ensembl_gene_id', values = combined_cells_genes, mart = ens)

Now I would like to sort this list after their location on the genome (sort after chromosome + start position). Is there any straightforward way to do that within biomart, without having me to sort them with my own R code?

Thanks in advance, T

biomart

1 answer

Okay this was not a very smart questions.

Basically I have used gene_locations [order(gene_locations[, 2], gene_locations[, 3]),] to order them, the only thing is they are order lexically rather than numerically, so will have to circumvent this somehow.

Remember that R is 1-indexed, so you are probably ordering them by chromosome_name and start_position.

To fix the lexical rather than numeric chromosome sorting, you would have to convert the chromosome_name column to a factor with the levels in the desired order:

Log in to answer this question.