# Correct use of .copy() when working with layers

**URL:** <https://discourse.scverse.org/t/correct-use-of-copy-when-working-with-layers/1095>\
**Category:** scanpy\
**Created:** [February 2, 2023, 8:07am UTC](https://discourse.scverse.org/t/correct-use-of-copy-when-working-with-layers/1095 "2023-02-02T08:07:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![natalia.nutella](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@natalia.nutella](https://discourse.scverse.org/u/natalia.nutella)\
**Post date:** [February 2, 2023, 8:07am UTC](https://discourse.scverse.org/t/correct-use-of-copy-when-working-with-layers/1095/1 "2023-02-02T08:07:43Z")

</div>

1. Is it always necessary to use .`copy()` when creating a new layer with the value of a different layer? I see some examples with and some without `.copy()` and can’t find any clear documentation specifying the correct use of this.

Example

`adata[‘layer1’]=adata.X`

vs

`adata[‘layer1’]=adata.X.copy()`

1. When assigning the result of a transformation to a layer, as opposed to updating `adata.X`, is this the correct syntax?

`adata[‘norm’] = sc.pp.normalize_total(adata, copy=True)`

1. Why is `inplace=False` incompatible with `copy=True` in the above command (per the documentation)? To me, it seems that `copy=True` is another way of saying `inplace=False` “, ie don’t update `adata.X,` but instead just return the output.

2. I cannot seem to wrap my head around this sentence in the documentation for `sc.pp.normalize_total` :

> Returns dictionary with normalized copies of `adata.X` and `adata.layers` or updates `adata`with normalized version of the original `adata.X` and `adata.layers`, depending on `inplace`.

a) Can somebody elaborate on what it means to “return a dictionary of the normalized copies of `X` _AND_ layers”? Why would you get a dictionary of transformed `X` _AND_ layers if you don’t specify any layers as input? Wouldn’t you just get the transformed result of `.X`? Or is it normalizing all the layers in anndata? I thought the default was to only normalize .X unless any other layers are specified?

b) “Depending on `inplace`” — wouldn’t this depend on whether `copy=True` or `False`?

Thank you!
