label_responsive_genes
Labels genes in a DataFrame as responsive or not based on thresholds for expression effect and p-value. Note that the comparisons on the thresholds are strictly greater than for the abs_expression_effect_threshold and strictly less than for the expression_pvalue_threshold.
The function adds a new boolean column ‘responsive’ to the DataFrame, where each gene is labeled as responsive if its absolute effect expression is strictly greater than a threshold and its p-value is strictly less than a specified threshold. If normalization is enabled, only the top genes meeting the criteria up to the minimum number found in the normalized subset are labeled as responsive.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
DataFrame containing gene data. Must include ‘expression_effect’ and ‘expression_pvalue’ columns. |
required |
abs_expression_effect_threshold |
float
|
Absolute value threshold for the absolute value of the expression effect. Values strictly greater than this threshold are considered responsive if the pvalue threshold passes. |
required |
expression_pvalue_threshold |
float
|
Threshold for the expression p-value. Values strictly less than this threshold are considered responsive if the effect threshold passes. |
required |
normalization_cutoff |
int
|
The maximum number of responsive genes to consider prior to labelling. This serves to normalize rank response across expression data sets. Defaults to -1, which disables normalization. |
-1
|
Returns:
Type | Description |
---|---|
pd.DataFrame: The input DataFrame with an added ‘responsive’ column. |
Raises:
Type | Description |
---|---|
KeyError
|
If ‘expression_effect’ or ‘expression_pvalue’ are not in |
Examples:
>>> df = pd.DataFrame({'effect_expression': [0.5, 0.7, 1.2],
'p_expression': [0.01, 0.05, 0.2]})
>>> label_responsive_genes(df, 0.6, 0.05).responsive
[False, True, False]
Source code in callingcardstools/Analysis/yeast/rank_response.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|