addPredictions
Short Description
The addPredictions function serves as a link between cspot and scimap package.
It's useful for evaluating model performance. The function transforms results
stored in anndata.uns to anndata.obs so they can be visualized using
the scimap package's sm.pl.image viewer function. This displays positive
and negative cells overlaid on the raw image.
The addPredictions function can take in two methods.
cspotOutput displays the result of running the cspot function,
while csScore shows the raw output produced by the csScore
function, which returns a probability score. The midpoint parameter,
with a default value of 0.5, can be adjusted to define what is
considered a positive result, when method is set to csScore.
Function¶
addPredictions(csObject, method='cspotOutput', cspotOutput='cspotOutput', csScore='csScore', midpoint=0.5, outputDir=None)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csObject
|
anndata
|
Single or combined CSPOT object. |
required |
method
|
str
|
There are two options: |
'cspotOutput'
|
cspotOutput
|
str
|
The name under which the |
'cspotOutput'
|
csScore
|
str
|
The name under which the |
'csScore'
|
midpoint
|
float
|
The threshold for determining positive cells, in conjunction with 'csScore'. |
0.5
|
outputDir
|
string
|
Provide the path to the output directory. Kindly take note that this particular
output will not be automatically saved in a predetermined directory,
unlike the other outputs. The file will be saved in the directory
specified by the |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
csObject |
anndata
|
If output directory is provided the |
Example
# Path to projectDir
projectDir = '/Users/aj/Documents/cspotExampleData'
# Path to csObject
csObject = projectDir + '/CSPOT/cspotOutput/exampleImage_cspotPredict.ome.h5ad'
adata = cs.addPredictions (csObject,
method='cspotOutput',
cspotOutput='cspotOutput',
csScore='csScore',
midpoint=0.5)
# Same function if the user wants to run it via Command Line Interface
python addPredictions.py --csObject Users/aj/Documents/cspotExampleData/CSPOT/cspotOutput/exampleImage_cspotPredict.ome.h5ad
Source code in cspot/addPredictions.py
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |