Build design matrix
Module to regroup the steps to build the design matrix for DESeq2.
build_design_matrix
BuildDesignMatrix
Bases: AggMergeDesignColumnsBuildContrast
, AggMergeDesignLevels
, LocGetLocalFactors
, LocSetLocalDesign
, LocOderDesignComputeLogMean
Mixin class to implement the computation of the design matrix.
Methods:
Name | Description |
---|---|
build_design_matrix |
The method to build the design matrix, that must be used in the main pipeline. |
check_design_matrix |
The method to check the design matrix, that must be used in the main pipeline while we are testing. |
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/build_design_matrix.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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
build_design_matrix(train_data_nodes, aggregation_node, local_states, round_idx, clean_models)
Build the design matrix.
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
|
The current round |
required | |
clean_models
|
Whether to clean the models after the computation. |
required |
Returns:
Name | Type | Description |
---|---|---|
local_states |
dict
|
Local states. Required to propagate intermediate results. |
shared_states |
dict
|
Shared states containing the necessary local information to start the next step of the pipeline, which is computing the size factors. They contain a "log_means" key and a "n_samples" key. |
round_idx |
int
|
The updated round |
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/build_design_matrix.py
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 143 144 |
|
substeps
Module containing the substeps for the computation of design matrices.
This module contains all these substeps as mixin classes.
AggMergeDesignColumnsBuildContrast
Mixin to merge the columns of the design matrices and build contrast.
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/substeps.py
merge_design_columns_and_build_contrast(shared_states)
Merge the columns of the design matrices and build constrasts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shared_states
|
list
|
List of results (dictionaries of design columns) from training nodes. |
required |
Returns:
Type | Description |
---|---|
dict
|
Shared state containing: - merged_columns: the names of the columns that the local design matrices should have. - contrast: the contrast (in a list of strings form) to be used for the DESeq2 model. |
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/substeps.py
AggMergeDesignLevels
Mixin to merge the levels of the design factors.
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/substeps.py
merge_design_levels(shared_states)
Merge the levels of the design factors.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shared_states
|
list
|
List of results (dictionaries of local_levels) from training nodes. |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary of unique levels for each factor. |
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/substeps.py
LocGetLocalFactors
Mixin to get the list of unique levels for each categorical design factor.
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/substeps.py
get_local_factors(data_from_opener, shared_state=None)
Get the list of unique levels for each categorical design factor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_from_opener
|
AnnData
|
AnnData returned by the opener. Copied in local anndata objects. |
required |
shared_state
|
None
|
Not used. |
None
|
Returns:
Type | Description |
---|---|
dict
|
A dictionary of unique local levels for each factor. |
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/substeps.py
LocOderDesignComputeLogMean
Mixin to order design cols and compute the local log mean.
Attributes:
Name | Type | Description |
---|---|---|
local_adata |
AnnData
|
The local AnnData. |
Methods:
Name | Description |
---|---|
order_design_cols_compute_local_log_mean |
Order design columns and compute the local log mean. |
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/substeps.py
order_design_cols_compute_local_log_mean(data_from_opener, shared_state=None)
Order design columns and compute the local log mean.
This function also sets the contrast in the local AnnData, and saves the number of parameters in the uns field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_from_opener
|
AnnData
|
AnnData returned by the opener. Not used. |
required |
shared_state
|
dict
|
Shared state with: - "merged_columns" a set containing the names of columns that the design matrix should have. - "contrast" the contrast to be used for the DESeq2 model. |
None
|
Returns:
Type | Description |
---|---|
dict
|
Local mean of logs and number of samples. |
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/substeps.py
LocSetLocalDesign
Mixin to set the design matrices in centers.
Source code in fedpydeseq2/core/deseq2_core/build_design_matrix/substeps.py
set_local_design(data_from_opener, shared_state)
Set the design matrices in centers.
Returns their columns in order to harmonize them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_from_opener
|
AnnData
|
AnnData returned by the opener. Not used. |
required |
shared_state
|
dict
|
Shared state with a "design_columns" key containing a dictionary with, for each design factor, the names of its unique levels. |
required |
Returns:
Type | Description |
---|---|
dict
|
Local design columns. |