Add Calling Cards metrics to the given DataFrame.
The kwargs parameter is used to pass additional arguments into underlying
functions. Currently, the following are configured:
- pseudocount: pseudocount to use when calculating both the enrichment and
poisson pvalue. See either function for more documentation. Passed through
kwargs so that if none is passed to add_metrics, the default in
enrichment_vectorized() and poisson_pval_vectorized() is used.
:param dataframe: a pandas DataFrame of promoter regions.
:type dataframe: DataFrame
:return: a pandas DataFrame of promoter regions with Calling Cards
metrics.
:rtype: DataFrame
Source code in callingcardstools/PeakCalling/yeast/call_peaks.py
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376 | def add_metrics(dataframe: pd.DataFrame, **kwargs) -> pd.DataFrame:
"""
Add Calling Cards metrics to the given DataFrame.
The kwargs parameter is used to pass additional arguments into underlying
functions. Currently, the following are configured:
- pseudocount: pseudocount to use when calculating both the enrichment and
poisson pvalue. See either function for more documentation. Passed through
kwargs so that if none is passed to add_metrics, the default in
enrichment_vectorized() and poisson_pval_vectorized() is used.
:param dataframe: a pandas DataFrame of promoter regions.
:type dataframe: DataFrame
:return: a pandas DataFrame of promoter regions with Calling Cards
metrics.
:rtype: DataFrame
"""
dataframe["callingcards_enrichment"] = enrichment_vectorized(
dataframe["background_total_hops"],
dataframe["experiment_total_hops"],
dataframe["background_hops"],
dataframe["experiment_hops"],
**kwargs,
)
dataframe["poisson_pval"] = poisson_pval_vectorized(
dataframe["background_total_hops"],
dataframe["experiment_total_hops"],
dataframe["background_hops"],
dataframe["experiment_hops"],
**kwargs,
)
dataframe["hypergeometric_pval"] = hypergeom_pval_vectorized(
dataframe["background_total_hops"],
dataframe["experiment_total_hops"],
dataframe["background_hops"],
dataframe["experiment_hops"],
)
return dataframe
|