Computing the Cooks distance
Pipe step computing the cooks distance.
compute_cook_distance
ComputeCookDistances
Bases: ComputeTrimmedMean
, LocComputeSqerror
, LocGetNormedCounts
, AggComputeDispersionForCook
Mixin class to compute Cook's distances.
Methods:
Name | Description |
---|---|
compute_cook_distance |
The method to compute Cook's distances. |
Source code in fedpydeseq2/core/deseq2_core/compute_cook_distance/compute_cook_distance.py
16 17 18 19 20 21 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 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 |
|
compute_cook_distance(train_data_nodes, aggregation_node, local_states, round_idx, clean_models)
Compute Cook's distances.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
train_data_nodes
|
list of TrainDataNode. |
required | |
aggregation_node
|
The aggregation node. |
required | |
local_states
|
Local states. Required to propagate intermediate results. |
required | |
round_idx
|
Index of the current round. |
required | |
clean_models
|
Whether to clean the models after the computation. |
required |
Returns:
Name | Type | Description |
---|---|---|
local_states |
dict
|
Local states. The new local state contains Cook's distances. |
dispersion_for_cook_shared_state |
dict
|
Shared state with the dispersion values for Cook's distances, in a "cooks_dispersions" key. |
round_idx |
int
|
The updated round index. |
Source code in fedpydeseq2/core/deseq2_core/compute_cook_distance/compute_cook_distance.py
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 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 |
|
substeps
AggComputeDispersionForCook
Compute the dispersion for Cook's distance calculation.
Source code in fedpydeseq2/core/deseq2_core/compute_cook_distance/substeps.py
agg_compute_dispersion_for_cook(shared_states)
Compute the dispersion for Cook's distance calculation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shared_states
|
list[dict]
|
list of shared states with the following keys: - mean_normed_counts: mean of the normalized counts - n_samples: number of samples - varEst: variance estimate |
required |
Returns:
Type | Description |
---|---|
dict
|
Because it is decorated, the dictionary will have the following key: - cooks_dispersions: dispersion values |
Source code in fedpydeseq2/core/deseq2_core/compute_cook_distance/substeps.py
LocComputeSqerror
Compute the squared error between the normalized counts and the trimmed mean.
Source code in fedpydeseq2/core/deseq2_core/compute_cook_distance/substeps.py
local_compute_sqerror(data_from_opener, shared_state=dict)
Compute the squared error between the normalized counts and the trimmed mean.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_from_opener
|
AnnData
|
AnnData returned by the opener. Not used. |
required |
shared_state
|
dict
|
Results to save in the local states. |
dict
|
Source code in fedpydeseq2/core/deseq2_core/compute_cook_distance/substeps.py
LocGetNormedCounts
Get the mean of the normalized counts.
Source code in fedpydeseq2/core/deseq2_core/compute_cook_distance/substeps.py
local_get_normed_count_means(data_from_opener, shared_state=dict)
Send local normed counts means.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_from_opener
|
AnnData
|
AnnData returned by the opener. Not used. |
required |
shared_state
|
dict
|
Dictionary with the following keys: - varEst: variance estimate for Cook's distance calculation |
dict
|
Returns:
Type | Description |
---|---|
dict
|
Because of the decorator, dictionary with the following keys: - mean_normed_counts: mean of the normalized counts - n_samples: number of samples - varEst: variance estimate |