Closed labixiaoxin1234 closed 2 years ago
I think the issue here is with the line pig.gene.list <- unique(genes.list[, 2])
. This command is asking for the second column in the output of of getLDS()
.
However you're asking for the following 5 attributes: "hgnc_symbol","chromosome_name","start_position"
from the human dataset and "chromosome_name","start_position"
from the pig dataset.
By selecting the second column, you're only returning the human chromosomes.
Perhaps something like the following would work for your purposes:
library(biomaRt)
library(Seurat)
data(cc.genes)
## this can be really slow, lets do it once outside the function
human = biomaRt::useEnsembl("ensembl", dataset = "hsapiens_gene_ensembl")
pig = biomaRt::useEnsembl("ensembl", dataset = "sscrofa_gene_ensembl")
ConvertHumanGeneListToPig <- function(x, humanMart, pigMart){
genes.list = biomaRt::getLDS(attributes = c("hgnc_symbol","ensembl_gene_id", "chromosome_name","start_position"),
filters = "hgnc_symbol",
values = x ,
mart = humanMart,
attributesL = c("ensembl_gene_id", "chromosome_name","start_position"),
martL = pigMart,
uniqueRows = T)
return(genes.list)
}
conversionTable <- lapply(cc.genes, FUN = ConvertHumanGeneListToPig, humanMart = human, pigMart = pig)
## lets look at the first 5 results
head(conversionTable$s.genes)
#> HGNC.symbol Gene.stable.ID Chromosome.scaffold.name Gene.start..bp.
#> 1 CASP8AP2 ENSG00000118412 6 89829894
#> 2 CDCA7 ENSG00000144354 2 173354820
#> 3 RPA2 ENSG00000117748 1 27891524
#> 4 CLSPN ENSG00000092853 1 35720218
#> 5 POLA1 ENSG00000101868 X 24693873
#> 6 NASP ENSG00000132780 1 45583846
#> Gene.stable.ID.1 Chromosome.scaffold.name.1 Gene.start..bp..1
#> 1 ENSSSCG00000004331 1 57834116
#> 2 ENSSSCG00000015961 15 79432257
#> 3 ENSSSCG00000003583 6 85031578
#> 4 ENSSSCG00000003628 6 91906318
#> 5 ENSSSCG00000022240 X 20756201
#> 6 ENSSSCG00000029573 6 165770055
hi, biomaRt team,
I am doing a project about finding the cell cycle gene of the pig genome, and using the biomaRt package to converting human gene list to pig. Howerver, there is an error that I do not know how to do.
my code is as folloing:
the result is that:
$g2m.genes [1] 12 5 4 7 15 1 13 18 22 10 9 20 6 17 11 2 8 3 14 16
these result is not gene name, so how to adjust my code to convert human gene list to pig.
thank you! Looking forward to your reply.