rcavalcante / annotatr

Package Homepage: http://bioconductor.org/packages/devel/bioc/html/annotatr.html Bug Reports: https://support.bioconductor.org/p/new/post/?tag_val=annotatr.
26 stars 8 forks source link

how can I change the annotation files in the annotatr_cache #39

Closed Lucyyang1991 closed 4 years ago

Lucyyang1991 commented 4 years ago

Thanks for developing the package which is very useful. First, I just wondering how can I change the the annotation files in the annotatr_cache. After I import the custom annotations:

print(annotatr_cache$get('mm10_custom_FuncElems'))
GRanges object with 1968 ranges and 5 metadata columns:
         seqnames            ranges strand |             id     tx_id   gene_id    symbol                  type
            <Rle>         <IRanges>  <Rle> |    <character> <logical> <logical> <logical>           <character>
     [1]     chr1   9648222-9650965      + |    FuncElems:1      <NA>      <NA>      <NA> mm10_custom_FuncElems
     [2]     chr1 12509175-12511893      + |    FuncElems:2      <NA>      <NA>      <NA> mm10_custom_FuncElems
     [3]     chr1 39945609-39950472      + |    FuncElems:3      <NA>      <NA>      <NA> mm10_custom_FuncElems
     [4]     chr1 56286329-56287543      + |    FuncElems:4      <NA>      <NA>      <NA> mm10_custom_FuncElems
     [5]     chr1 57329917-57330730      + |    FuncElems:5      <NA>      <NA>      <NA> mm10_custom_FuncElems
     ...      ...               ...    ... .            ...       ...       ...       ...                   ...
  [1964]    chr19 58371921-58373062      + | FuncElems:1964      <NA>      <NA>      <NA> mm10_custom_FuncElems
  [1965]    chr19 58419230-58420471      + | FuncElems:1965      <NA>      <NA>      <NA> mm10_custom_FuncElems
  [1966]    chr19 59267127-59268278      + | FuncElems:1966      <NA>      <NA>      <NA> mm10_custom_FuncElems
  [1967]    chr19 59423213-59425570      + | FuncElems:1967      <NA>      <NA>      <NA> mm10_custom_FuncElems
  [1968]    chr19 60015441-60016837      + | FuncElems:1968      <NA>      <NA>      <NA> mm10_custom_FuncElems
  -------
  seqinfo: 66 sequences from mm10 genome

> annotatr_cache$get('mm10_custom_FuncElems')$gene_id = funcElem.obj$geneIds
Error in annotatr_cache$get("mm10_custom_FuncElems")$gene_id = funcElem.obj$geneIds 

Besides that issue above, sometimes I wanna delete the files in the annotatr_cache.

print(annotatr_cache$list_env())
[1] "mm10_custom_FuncElems" "mm10_custom_test" 

So how can I fulfill things like that.

Thanks so much.

rcavalcante commented 4 years ago

Sorry for the delay in response, and thanks for your feedback and use of annotatr.

From the example in the documentation for annotatr_cache (?annotatr_cache), you can manually set things in the cache like:

annotatr_cache$set("foo", 1:10)

So to alter something already in the cache you'd do something like get, edit, and set as in:

temp_annots = annotatr_cache$get('mm10_custom_FuncElems')
# Make any changes you want to temp_annots
annotatr_cache$set('mm10_custom_FuncElems', temp_annots)

As for deleting things in the annotatr_cache, there is no rm() for annotatr_cache at the moment. It's not necessary to reference all the items in annotatr_cache when calling build_annotations() so if you're not too worried about the space the item takes up, you can just leave it around. If you are worried, you can set them to NULL with annotatr_cache$set('foo', NULL). The annotatr_cache() is valid per session and resets with new sessions, so that's another way to wipe it.

Hope that helps, thanks for using annotatr.

Lucyyang1991 commented 4 years ago

Thanks so much! That helps a lot.