log1p
Short Description
sm.pp.log1p
applies a log1p transformation to the raw data of an AnnData object and saves the transformed data in a specified layer.
If a string path to an AnnData file is provided, the file is loaded, transformed, and overwritten with the
transformed data. The function ensures the raw data exists before applying the transformation and allows for verbose output.
Function
log1p(adata, layer='log', verbose=True)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
adata |
str or AnnData
|
The AnnData object or a string path to an AnnData file. If a path is provided, the function will load the AnnData object from the file. The transformation is applied to the raw data of this object. |
required |
layer |
str
|
Name of the new layer where the log-transformed data will be stored. Default is 'log'. If the layer already exists, it will be overwritten with the new log-transformed data. |
'log'
|
verbose |
bool
|
If True, the function will print messages about its progress and actions, including warnings if the specified layer already exists and confirmation when the AnnData object is saved to a file. Default is True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
adata |
anndata
|
The modified AnnData object, only if the input is an AnnData object and not a file path. If a file path is provided and successfully processed, the function returns None. |
Example
1 2 3 4 5 6 7 8 9 10 |
|
Source code in scimap/preprocessing/log1p.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|