# Appending data to adata object in R

**URL:** <https://discourse.scverse.org/t/appending-data-to-adata-object-in-r/187>\
**Category:** scvi-tools\
**Created:** [September 27, 2021, 7:34am UTC](https://discourse.scverse.org/t/appending-data-to-adata-object-in-r/187 "2021-09-27T07:34:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dn-ra](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@dn-ra](https://discourse.scverse.org/u/dn-ra)\
**Post date:** [September 27, 2021, 7:34am UTC](https://discourse.scverse.org/t/appending-data-to-adata-object-in-r/187/1 "2021-09-27T07:34:11Z")

</div>

Hi,

Thanks for all your work on SCVI.  
I have done some analysis on my data in Seurat already, so am trying to perfrom some SCVI analysis in R. But I am having trouble doing the equivalent of `adata.layers["counts"] = adata.X.copy()` in R.

When I write `adataRNA$layers[['counts']] <- adataRNA$X$copy()` , the command completes without error, but then I try to access the count layer and I get a Key Error as if nothing has been written there.  
`> adataRNA$layers[['counts']] Error in py_get_item_impl(x, key, FALSE) : KeyError: 'counts' `

Since I am working with CITE-seq data, I am having the same trouble trying to write protein count data into the `adata.obsm['protein_expression']` object:

`  
adataRNA$obsm[[“protein\_expression”]] ← adataHTO$to\_df()

> adataRNA$obsm[[‘protein\_expression’]]  
> Error in py\_get\_item\_impl(x, key, FALSE) : KeyError: ‘protein\_expression’  
> `

Any ideas as to why this is happening?  
Thanks

---

<div class="post-metadata">

**Author:** ![adamgayoso](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/adamgayoso/32/100_2.png) [@adamgayoso](https://discourse.scverse.org/u/adamgayoso)\
**Post date:** [September 27, 2021, 3:38pm UTC](https://discourse.scverse.org/t/appending-data-to-adata-object-in-r/187/2 "2021-09-27T15:38:37Z")

</div>

We are working on new tutorials for R.

You might find this one on our development version of the docs helpful:

[https://docs.scvi-tools.org/en/latest/tutorials/notebooks/totalvi\_in\_R.html#Data-conversion-(SCE--\>-AnnData)](https://docs.scvi-tools.org/en/latest/tutorials/notebooks/totalvi_in_R.html#Data-conversion-(SCE--%3E-AnnData))

We found the sceasy package to be useful for conversion of seurat to anndata (or singlecellexperiment to anndata)
