spared.layer_operations.add_noisy_layer
- spared.layer_operations.add_noisy_layer(adata: AnnData, prediction_layer: str) AnnData[source]
Add an artificial noisy layer.
This function should only be used for experimentation/ablation purposes. The noisy layer is created by returning the missing values to an already denoised layer of the
adata. In the case the'prediction_layer'is on \(\log_2(TPM+1)\) logarithmic scale, the noisy layer is created by assigning zero values to the missing values (adds'noisy'layer to the adata). In the case the'prediction_layer'is on delta scale, the noisy layer is created by assigning the negative mean of the gene to the missing values (adds'noisy_d'layer to the adata). Missing values are specified by the binaryadata.layers['mask']layer that must be already present and hasTruevalues for all real data andFalsevalues for imputed data.- Parameters:
adata (ad.AnnData) – The AnnData object to update. Must have the
adata.layers[prediction_layer], the gene means if its a delta layer, andadata.layers['mask'].prediction_layer (str) – The layer that will be corrupted to create the noisy layer.
- Returns:
The updated AnnData object with the
adata.layers['noisy']oradata.layers['noisy_d']layer added depending onprediction_layer.- Return type:
ad.AnnData