- 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()
- 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)
-
Why is
inplace=False
incompatible withcopy=True
in the above command (per the documentation)? To me, it seems thatcopy=True
is another way of sayinginplace=False
“, ie don’t updateadata.X,
but instead just return the output. -
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
andadata.layers
or updatesadata
with normalized version of the originaladata.X
andadata.layers
, depending oninplace
.
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!