How can I retrieve a protein's coding sequence using getSequence
1
0
Entering edit mode
heiko_kin ▴ 60
@heiko_kin-23266
Last seen 3.2 years ago

Dear all,

I am looking for a way to retrieve a protein's coding sequence, and only the one that translates into a biologically functioning protein directly using BioMart and the getsequence function. For example, when using:

cds_seq = getSequence(id = "NM_004974", 
                      type = "refseq_mrna", 
                      seqType = "coding", 
                      mart = mart)

I get a data frame with 8 different sequences. However, I only want the one that translates into the proper protein. Is there a way to do this?

biomaRt • 2.6k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 7 hours ago
United States

I don't see that.

> mart <- useEnsembl("ensembl","hsapiens_gene_ensembl")
> cds_seq = getSequence(id = "NM_004974",
                      type = "refseq_mrna",
                      seqType = "coding",
                      mart = mart)

> cds_seq
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        coding
1 ATGACAGTGGCCACCGGAGACCCAGCAGACGAGGCTGCTGCCCTCCCTGGGCACCCACAGGACACCTATGACCCAGAGGCAGACCACGAGTGCTGTGAGAGGGTGGTGATCAACATCTCAGGGCTGCGGTTTGAGACCCAGCTAAAGACCTTAGCCCAGTTTCCAGAGACCCTCTTAGGGGACCCAAAGAAACGAATGAGGTACTTTGACCCCCTCCGAAATGAGTACTTTTTCGATCGGAACCGCCCTAGCTTTGATGCCATTTTGTACTACTACCAGTCAGGGGGCCGATTGAGGCGACCTGTGAATGTGCCCTTAGATATATTCTCTGAAGAAATTCGGTTTTATGAGCTGGGAGAAGAAGCGATGGAGATGTTTCGGGAAGATGAAGGCTACATCAAGGAGGAAGAGCGTCCTCTGCCTGAAAATGAGTTTCAGAGACAAGTGTGGCTTCTCTTTGAATACCCAGAGAGCTCAGGGCCTGCCAGGATTATAGCTATTGTGTCTGTCATGGTGATTCTGATCTCAATTGTCAGCTTCTGTCTGGAAACATTGCCCATCTTCCGGGATGAGAATGAAGACATGCATGGTAGTGGGGTGACCTTCCACACCTATTCCAACAGCACCATCGGGTACCAGCAGTCCACTTCCTTCACAGACCCTTTCTTCATTGTAGAGACACTCTGCATCATCTGGTTCTCCTTTGAATTCTTGGTGAGGTTCTTTGCCTGTCCCAGCAAAGCCGGCTTCTTCACCAACATCATGAACATCATTGACATTGTGGCCATCATCCCCTACTTCATCACCCTGGGGACAGAGTTGGCTGAGAAGCCAGAGGACGCTCAGCAAGGCCAGCAGGCCATGTCACTGGCCATCCTCCGTGTCATCCGGTTGGTAAGAGTCTTTAGGATTTTCAAGTTGTCCAGACACTCCAAAGGTCTCCAGATTCTAGGTCAGACCCTCAAAGCCAGCATGAGAGAATTGGGCCTCCTGATATTCTTTCTCTTCATAGGGGTCATCCTTTTCTCTAGTGCTGTGTATTTTGCAGAGGCCGATGAGCGAGAGTCCCAGTTCCCCAGCATCCCAGATGCCTTCTGGTGGGCAGTCGTCTCCATGACAACTGTAGGCTATGGAGACATGGTTCCGACTACCATTGGGGGAAAGATAGTGGGTTCCCTATGTGCGATTGCAGGTGTGTTAACTATTGCCTTACCGGTCCCTGTCATTGTGTCCAATTTCAACTACTTCTACCACCGGGAGACAGAGGGAGAGGAACAGGCCCAATACTTGCAAGTGACAAGCTGTCCAAAGATCCCATCCTCCCCTGACCTAAAGAAAAGTAGAAGTGCCTCTACCATTAGTAAGTCTGATTACATGGAGATCCAGGAGGGTGTAAATAACAGTAATGAGGACTTTAGAGAGGAAAACTTGAAAACAGCCAACTGTACCTTGGCTAACACAAACTATGTGAATATTACCAAAATGTTAACTGATGTCTGA
  refseq_mrna
1   NM_004974
> dim(cds_seq)
[1] 1 2

In general you should probably get information about NCBI IDs from NCBI rather than EBI/EMBL. They both have their own 'rich set of transcripts' and it's a non-trivial exercise to map between them. For example, they have been trying to do so since 2018 and are still at it.

ADD COMMENT
0
Entering edit mode

Dear James,

thanks for your feedback! If I use the proposed R code I get the following result:

Result of retrieving the sequence for NM_004974

How can I determine which one is the one that properly translates into a protein?

ADD REPLY
0
Entering edit mode

Dear James,

thanks for your feedback! If I use the proposed R code I get the following result:

Result of retrieving the sequence for NM_004974

How can I determine which one is the one that properly translates into a protein?

ADD REPLY
0
Entering edit mode

You don't need to post the same thing twice. You should also provide more context. How did you generate your mart object? What is the result of running sessionInfo() after getting your results?

Anyway, you show 7 sequences, all of which have a start codon. Why do you think that only one is 'properly translated'?

As I have already shown, I only get one sequence, so I have no idea why you would get seven. BUT I also pointed out that there are issues when trying to map transcripts from NCBI to EBI/EMBL. But there does seem to be a 1:1 correspondence, and if I do

> cds_seq = getSequence(id = "ENST00000316361", 
                      type = "ensembl_transcript_id", 
                      seqType = "coding", 
                      mart = mart)

> cds_seq.orig = getSequence(id = "NM_004974", 
                      type = "refseq_mrna", 
                      seqType = "coding", 
                      mart = mart)
> all.equal(cds_seq$coding, cds_seq.orig$coding)
[1] TRUE

I still have no idea why you get multiple transcripts. I just get one, regardless. So it would be useful to first figure out why you get seven and I get one.

ADD REPLY
0
Entering edit mode

I think this is because I've introduce a bug in the developmental version of biomaRt trying to respond to https://github.com/grimbough/biomaRt/issues/33

The Ensembl BioMart will let you query with a filter of refseq_mrna but it won't let you retrieve that ID type in as an attribute. I think this was causing the unstable and broken results in the Github issue. I tried to work around this by mapping on to Ensembl Gene IDs internally, but I see now that is obviously not working as I expected when the original identifier is mRNA based. I'll take another look the code and try to come up with something more robust.

ADD REPLY
0
Entering edit mode

Thanks, Mike! That is interesting - a colleague has a non-developer version of BioMart installed and he does not get the error. So I guess we're on the right way to solve the problem! Here is the information that was missing in my initial post - sorry about that! I generate my mart object as follows

mart <- useMart('ensembl',
                dataset = 'hsapiens_gene_ensembl',
                host = 'useast.ensembl.org')

sessionInfo( )
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ggrepel_0.8.2       ggsci_2.9           ggpubr_0.4.0        cowplot_1.1.0      
 [5] reshape_0.8.8       forcats_0.5.0       stringr_1.4.0       dplyr_1.0.2        
 [9] purrr_0.3.4         readr_1.4.0         tidyr_1.1.2         tibble_3.0.4       
[13] ggplot2_3.3.2       tidyverse_1.3.0     Biostrings_2.54.0   XVector_0.26.0     
[17] IRanges_2.20.2      S4Vectors_0.24.4    BiocGenerics_0.32.0 biomaRt_2.42.1     

loaded via a namespace (and not attached):
 [1] fs_1.5.0             usethis_1.6.3        lubridate_1.7.9.2    devtools_2.3.2      
 [5] bit64_4.0.5          progress_1.2.2       httr_1.4.2           rprojroot_2.0.2     
 [9] tools_3.6.3          backports_1.2.0      R6_2.5.0             DBI_1.1.0           
[13] colorspace_2.0-0     withr_2.3.0          tidyselect_1.1.0     prettyunits_1.1.1   
[17] processx_3.4.4       bit_4.0.4            curl_4.3             compiler_3.6.3      
[21] cli_2.2.0            rvest_0.3.6          Biobase_2.46.0       xml2_1.3.2          
[25] desc_1.2.0           scales_1.1.1         callr_3.5.1          askpass_1.1         
[29] rappdirs_0.3.1       digest_0.6.27        foreign_0.8-75       rio_0.5.16          
[33] pkgconfig_2.0.3      sessioninfo_1.1.1    dbplyr_2.0.0         rlang_0.4.8         
[37] readxl_1.3.1         rstudioapi_0.13      RSQLite_2.2.1        generics_0.1.0      
[41] jsonlite_1.7.1       zip_2.1.1            car_3.0-10           magrittr_2.0.1      
[45] Rcpp_1.0.5           munsell_0.5.0        fansi_0.4.1          abind_1.4-5         
[49] lifecycle_0.2.0      stringi_1.5.3        carData_3.0-4        zlibbioc_1.32.0     
[53] pkgbuild_1.1.0       plyr_1.8.6           BiocFileCache_1.10.2 grid_3.6.3          
[57] blob_1.2.1           crayon_1.3.4         haven_2.3.1          hms_0.5.3           
[61] ps_1.4.0             pillar_1.4.7         ggsignif_0.6.0       pkgload_1.1.0       
[65] reprex_0.3.0         XML_3.99-0.3         glue_1.4.2           packrat_0.5.0       
[69] BiocManager_1.30.10  data.table_1.13.2    remotes_2.2.0        modelr_0.1.8        
[73] vctrs_0.3.5          testthat_3.0.0       cellranger_1.1.0     gtable_0.3.0        
[77] openssl_1.4.3        assertthat_0.2.1     openxlsx_4.2.3       broom_0.7.2         
[81] rstatix_0.6.0        rsconnect_0.8.16     AnnotationDbi_1.48.0 memoise_1.1.0       
[85] ellipsis_0.3.1
ADD REPLY
0
Entering edit mode

You aren't using the devel version of biomaRt. Instead you are using an old version that you should update. The current release version of Bioconductor runs on R-4.0.2, and your biomaRt version should be 2.46.0.

ADD REPLY
0
Entering edit mode

Which makes this all the more confusing, as we have three versions of biomaRt in play, that all query the same database, and produce quite different results. I also get 8 sequences with the devel version, but only 1 if I run the query in the Ensembl web interface.

I'll take a longer look at this tomorrow.

ADD REPLY
1
Entering edit mode

I updated both my R version and the biomaRt version as James suggested - and now it seems to give a single results for my query which looks fine! Still I am unsure what caused the problem...

R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] ggrepel_0.8.2   ggsci_2.9       ggpubr_0.4.0    cowplot_1.1.0   reshape_0.8.8   forcats_0.5.0   stringr_1.4.0  
 [8] dplyr_1.0.2     purrr_0.3.4     readr_1.4.0     tidyr_1.1.2     tibble_3.0.4    ggplot2_3.3.2   tidyverse_1.3.0
[15] biomaRt_2.46.0 

loaded via a namespace (and not attached):
 [1] fs_1.5.0             usethis_1.6.3        lubridate_1.7.9.2    devtools_2.3.2       bit64_4.0.5         
 [6] progress_1.2.2       httr_1.4.2           rprojroot_2.0.2      tools_4.0.3          backports_1.2.0     
[11] R6_2.5.0             DBI_1.1.0            BiocGenerics_0.36.0  colorspace_2.0-0     withr_2.3.0         
[16] tidyselect_1.1.0     prettyunits_1.1.1    processx_3.4.4       bit_4.0.4            curl_4.3            
[21] compiler_4.0.3       cli_2.2.0            rvest_0.3.6          Biobase_2.50.0       xml2_1.3.2          
[26] desc_1.2.0           scales_1.1.1         callr_3.5.1          askpass_1.1          rappdirs_0.3.1      
[31] digest_0.6.27        foreign_0.8-80       rio_0.5.16           pkgconfig_2.0.3      sessioninfo_1.1.1   
[36] dbplyr_2.0.0         rlang_0.4.9          readxl_1.3.1         rstudioapi_0.13      RSQLite_2.2.1       
[41] generics_0.1.0       jsonlite_1.7.1       zip_2.1.1            car_3.0-10           magrittr_2.0.1      
[46] Rcpp_1.0.5           munsell_0.5.0        S4Vectors_0.28.0     fansi_0.4.1          abind_1.4-5         
[51] lifecycle_0.2.0      stringi_1.5.3        carData_3.0-4        pkgbuild_1.1.0       plyr_1.8.6          
[56] BiocFileCache_1.14.0 grid_4.0.3           blob_1.2.1           parallel_4.0.3       crayon_1.3.4        
[61] haven_2.3.1          hms_0.5.3            ps_1.4.0             pillar_1.4.7         ggsignif_0.6.0      
[66] stats4_4.0.3         pkgload_1.1.0        reprex_0.3.0         XML_3.99-0.5         glue_1.4.2          
[71] data.table_1.13.2    remotes_2.2.0        modelr_0.1.8         vctrs_0.3.5          testthat_3.0.0      
[76] cellranger_1.1.0     gtable_0.3.0         openssl_1.4.3        assertthat_0.2.1     openxlsx_4.2.3      
[81] broom_0.7.2          rstatix_0.6.0        AnnotationDbi_1.52.0 memoise_1.1.0        IRanges_2.24.0      
[86] ellipsis_0.3.1
ADD REPLY

Login before adding your answer.

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