L2G Feature Matrix
gentropy.dataset.l2g_feature_matrix.L2GFeatureMatrix
¶
Dataset with features for Locus to Gene prediction.
Source code in src/gentropy/dataset/l2g_feature_matrix.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 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
__init__(_df: DataFrame, features_list: list[str] | None = None, with_gold_standard: bool = False) -> None
¶
Post-initialisation to set the features list. If not provided, all columns except the fixed ones are used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
_df
|
DataFrame
|
Feature matrix dataset |
required |
features_list
|
list[str] | None
|
List of features to use. If None, all possible features are used. |
None
|
with_gold_standard
|
bool
|
Whether to include the gold standard set in the feature matrix. |
False
|
Source code in src/gentropy/dataset/l2g_feature_matrix.py
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 |
|
calculate_feature_missingness_rate() -> dict[str, float]
¶
Calculate the proportion of missing values in each feature.
Returns:
Type | Description |
---|---|
dict[str, float]
|
dict[str, float]: Dictionary of feature names and their missingness rate. |
Raises:
Type | Description |
---|---|
ValueError
|
If no features are found. |
Source code in src/gentropy/dataset/l2g_feature_matrix.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
fill_na(na_value: float = 0.0, subset: list[str] | None = None) -> L2GFeatureMatrix
¶
Fill missing values in a column with a given value.
For features that correspond to gene attributes, missing values are imputed using the mean of the column.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
na_value
|
float
|
Value to replace missing values with. Defaults to 0.0. |
0.0
|
subset
|
list[str] | None
|
Subset of columns to consider. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
L2GFeatureMatrix |
L2GFeatureMatrix
|
L2G feature matrix dataset |
Source code in src/gentropy/dataset/l2g_feature_matrix.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
from_features_list(study_loci_to_annotate: StudyLocus | L2GGoldStandard, features_list: list[str], features_input_loader: L2GFeatureInputLoader) -> L2GFeatureMatrix
classmethod
¶
Generate features from the gentropy datasets by calling the feature factory that will instantiate the corresponding features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
study_loci_to_annotate
|
StudyLocus | L2GGoldStandard
|
Study locus pairs to annotate |
required |
features_list
|
list[str]
|
List of feature names to be computed. |
required |
features_input_loader
|
L2GFeatureInputLoader
|
Object that contais features input. |
required |
Returns:
Name | Type | Description |
---|---|---|
L2GFeatureMatrix |
L2GFeatureMatrix
|
L2G feature matrix dataset |
Source code in src/gentropy/dataset/l2g_feature_matrix.py
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 |
|
persist() -> Self
¶
Persist the feature matrix in memory.
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
Persisted Dataset |
Source code in src/gentropy/dataset/l2g_feature_matrix.py
196 197 198 199 200 201 202 203 |
|
select_features(features_list: list[str] | None) -> L2GFeatureMatrix
¶
Returns a new object with a subset of features from the original feature matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
features_list
|
list[str] | None
|
List of features to select |
required |
Returns:
Name | Type | Description |
---|---|---|
L2GFeatureMatrix |
L2GFeatureMatrix
|
L2G feature matrix dataset |
Raises:
Type | Description |
---|---|
ValueError
|
If no features have been selected. |
Source code in src/gentropy/dataset/l2g_feature_matrix.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|