Answers.Body: <p>It turned out that I needed to reinstall OSX to upgrade my R version and biomaRt install.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-05T14:02:53.893Z
Answers.LastActivityDate: 2019-01-05T14:02:53.893Z
Answers.UserDisplayName: Will Gibson
Answers.Body: <p>You could also save your "biomart_query_result" object after the first time it is generated. Then you can re-use it without having to depend on the biomaRt API functionality.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-07T15:12:10.413Z
Answers.LastActivityDate: 2019-01-07T15:12:10.413Z
Answers.UserDisplayName: story
Answers.Body: <p>Would this be useful to you?</p>
  
  <pre><code>
     library(EnsDb.Hsapiens.v86)  
     library(ensembldb)
     mygene &lt;- genes(EnsDb.Hsapiens.v86, filter= GenenameFilter("KRAS"))
  </code></pre>
  
  <h1>to get the protein info and protein sequence for each transcript</h1>
  
  <p>proteins(EnsDb.Hsapiens.v86, filter= GenenameFilter("KRAS"))</p>
  
  <p>Also have a look at functions
      proteinToTranscript
      proteinToGenome</p>
  
  <pre><code>&gt; x&lt;- proteins(EnsDb.Hsapiens.v86, filter= GenenameFilter("KRAS"), return.type = "AAStringSet")
  &gt; x
    A AAStringSet instance of length 4
      width seq                                    names               
  [1]   188 MTEYKLVVVGAGGVGKSA...KDGKKKKKKSKTKCVIM ENSP00000308495
  [2]    75 MTEYKLVVVGAGGVGKSA...KDGKKKKKKSKTKCVIM ENSP00000452512
  [3]   189 MTEYKLVVVGAGGVGKSA...KEEKTPGCVKIKKCIIM ENSP00000256078
  [4]    43 MTEYKLVVVGAGGVGKSA...HFVDEYDPTIEVLLSSM ENSP00000451856
  
  </code></pre>
  
  <p>There are also functions  exons, exonsBy, transcriptsBy, cdsBy, fiveUTRsByTranscript and threeUTRsByTranscript.  These functions return a GenomicRanges object and inherit all of the methods in that package too. </p>
  
  <pre><code>x&lt;-  genes(EnsDb.Hsapiens.v86, filter= GenenameFilter("KRAS"))
  start(x)
  end(x)
  strand(x)
  length(x)
  flank(x)
  </code></pre>
  
  <p>You can manipulate the sequence selected as an IRanges object</p>
  
  <pre><code>ranges(x)   # gives an IRanges object
  narrow(ranges(x), start=10, end=20)  # select the 10th position 
  </code></pre>
  
  <pre><code>&gt; ranges(x)
  IRanges object with 1 range and 0 metadata columns:
                        start       end     width
                    &lt;integer&gt; &lt;integer&gt; &lt;integer&gt;
    ENSG00000133703  25204789  25250936     46148
  &gt; narrow(ranges(x), start=10, end=19)
  IRanges object with 1 range and 0 metadata columns:
                        start       end     width
                    &lt;integer&gt; &lt;integer&gt; &lt;integer&gt;
    ENSG00000133703  25204798  25204807        10
  </code></pre>
  
  <p>It is worth having a look at these vignettes. Let me know if you've questions or post to the Bioconductor support forum ;-)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-08T23:12:26.160Z
Answers.LastActivityDate: 2019-01-08T23:12:26.160Z
Answers.UserDisplayName: Aedin
Body: <p>I'm trying to find the amino acid context around a particular position in a protein (5 aa amino acid window on each side).</p>
  
  <p>I used to have some code that works and then biomaRt stopped working. I think some of these issues would be fixed in later versions of biomaRt, but I would have to install a new version of R, which would require me to install a new version of my OS.</p>
  
  <pre><code>require('biomaRt')
  require('Biostrings')
  hs_ensembl_mart = 
  useMart(biomart="ENSEMBL_MART_ENSEMBL",dataset="hsapiens_gene_ensembl")
  
  gene_names=c('KRAS')
  aa_affected_loc=12
  
  biomart_query_results=getBM(attributes=c('hgnc_symbol', 'entrezgene','coding'), 
    filters = 'hgnc_symbol', 
    values = gene_names, 
    mart = hs_ensembl_mart)
  
  preceding_peptide= substr(as.character(translate(DNAString(biomart_query_results[1,'coding']))),aa_affected_loc-5,aa_affected_loc-1)
  
  trailing_peptide= substr(as.character(translate(DNAString(biomart_query_results[1,'coding']))),aa_affected_loc+1,aa_affected_loc+5)
  </code></pre>
  
  <p>Does anyone have a workaround for this?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-25T16:19:06.597Z
Comments.Text: You can install a new version of R without a new OS.  Which problem are you having? When I try your code the problem is that `j` is not defined, if I define it with a number I get `unable to find an inherited method for function ‘XString’ for signature ‘"integer"’` (and I'm using the latest versions of Bioconductor and R)
Comments.UserDisplayName: llrs
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-25T18:52:05.520Z
Comments.Text: Sorry, I had extracted that line from a loop and forgot to change the j. Should work now. I have a 5 year old computer and the OSX version I was using wouldn't allow upgrading R. I ended up upgrading my OSX version and reinstalling R. I'll see if it works now.
Comments.UserDisplayName: Will Gibson
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-25T19:35:13.270Z
Comments.Text: It doesn't work, I said so in my previous comment, see the error, and could you explain what are you doing in this long line?
Comments.UserDisplayName: llrs
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-26T13:25:29.410Z
Comments.Text: You are simply using a substr command, which is present in Perl and there is a very cool way for doing this in python. It is honestly easier to code this directly.
Comments.UserDisplayName: M__
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-03T23:24:37.370Z
Comments.Text: From what I heard even learning R is kinda waste of time, much less using it for simple scripts.
Comments.UserDisplayName: Mithoron
Tags: <r><biomart>
Title: How to obtain amino acid context at a given position
ThreadText: # How to obtain amino acid context at a given position
  
  (Asked by: username_0 on 2018-12-25)
  
  I'm trying to find the amino acid context around a particular position in a protein (5 aa amino acid window on each side).
  
  I used to have some code that works and then biomaRt stopped working. I think some of these issues would be fixed in later versions of biomaRt, but I would have to install a new version of R, which would require me to install a new version of my OS.
  
  ```
  require('biomaRt')
  require('Biostrings')
  hs_ensembl_mart = 
  useMart(biomart="ENSEMBL_MART_ENSEMBL",dataset="hsapiens_gene_ensembl")
  
  gene_names=c('KRAS')
  aa_affected_loc=12
  
  biomart_query_results=getBM(attributes=c('hgnc_symbol', 'entrezgene','coding'), 
    filters = 'hgnc_symbol', 
    values = gene_names, 
    mart = hs_ensembl_mart)
  
  preceding_peptide= substr(as.character(translate(DNAString(biomart_query_results[1,'coding']))),aa_affected_loc-5,aa_affected_loc-1)
  
  trailing_peptide= substr(as.character(translate(DNAString(biomart_query_results[1,'coding']))),aa_affected_loc+1,aa_affected_loc+5)
  
  ```
  
  Does anyone have a workaround for this?
  
  **Tags:** r, biomart
  
  > **Comments:**
  > **username_1**: You can install a new version of R without a new OS.  Which problem are you having? When I try your code the problem is that `j` is not defined, if I define it with a number I get `unable to find an inherited method for function ‘XString’ for signature ‘"integer"’` (and I'm using the latest versions of Bioconductor and R)  
  > **username_0**: Sorry, I had extracted that line from a loop and forgot to change the j. Should work now. I have a 5 year old computer and the OSX version I was using wouldn't allow upgrading R. I ended up upgrading my OSX version and reinstalling R. I'll see if it works now.  
  > **username_1**: It doesn't work, I said so in my previous comment, see the error, and could you explain what are you doing in this long line?  
  > **username_2**: You are simply using a substr command, which is present in Perl and there is a very cool way for doing this in python. It is honestly easier to code this directly.  
  > **username_3**: From what I heard even learning R is kinda waste of time, much less using it for simple scripts.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2019-01-05. Score: 2
  
  It turned out that I needed to reinstall OSX to upgrade my R version and biomaRt install.
  
  
  ---
  
  ### Answer by username_4 on 2019-01-07. Score: 2
  
  You could also save your "biomart\_query\_result" object after the first time it is generated. Then you can re-use it without having to depend on the biomaRt API functionality.
  
  
  ---
  
  ### Answer by username_5 on 2019-01-08. Score: 1
  
  Would this be useful to you?
  
  ```
  
     library(EnsDb.Hsapiens.v86)  
     library(ensembldb)
     mygene <- genes(EnsDb.Hsapiens.v86, filter= GenenameFilter("KRAS"))
  
  ```
  
  # to get the protein info and protein sequence for each transcript
  
  proteins(EnsDb.Hsapiens.v86, filter= GenenameFilter("KRAS"))
  
  Also have a look at functions
  proteinToTranscript
  proteinToGenome
  
  ```
  > x<- proteins(EnsDb.Hsapiens.v86, filter= GenenameFilter("KRAS"), return.type = "AAStringSet")
  > x
    A AAStringSet instance of length 4
      width seq                                    names               
  [1]   188 MTEYKLVVVGAGGVGKSA...KDGKKKKKKSKTKCVIM ENSP00000308495
  [2]    75 MTEYKLVVVGAGGVGKSA...KDGKKKKKKSKTKCVIM ENSP00000452512
  [3]   189 MTEYKLVVVGAGGVGKSA...KEEKTPGCVKIKKCIIM ENSP00000256078
  [4]    43 MTEYKLVVVGAGGVGKSA...HFVDEYDPTIEVLLSSM ENSP00000451856
  
  ```
  
  There are also functions exons, exonsBy, transcriptsBy, cdsBy, fiveUTRsByTranscript and threeUTRsByTranscript. These functions return a GenomicRanges object and inherit all of the methods in that package too.
  
  ```
  x<-  genes(EnsDb.Hsapiens.v86, filter= GenenameFilter("KRAS"))
  start(x)
  end(x)
  strand(x)
  length(x)
  flank(x)
  
  ```
  
  You can manipulate the sequence selected as an IRanges object
  
  ```
  ranges(x)   # gives an IRanges object
  narrow(ranges(x), start=10, end=20)  # select the 10th position 
  
  ```
  
  ```
  > ranges(x)
  IRanges object with 1 range and 0 metadata columns:
                        start       end     width
                    <integer> <integer> <integer>
    ENSG00000133703  25204789  25250936     46148
  > narrow(ranges(x), start=10, end=19)
  IRanges object with 1 range and 0 metadata columns:
                        start       end     width
                    <integer> <integer> <integer>
    ENSG00000133703  25204798  25204807        10
  
  ```
  
  It is worth having a look at these vignettes. Let me know if you've questions or post to the Bioconductor support forum ;-)
  
  
  ---
  
  