sccross.utils

Miscellaneous utilities

Functions

all_counts

Check whether an array contains all counts

col_pcc

Column-wise Pearson’s correlation coefficient (sparse friendly)

col_spr

Column-wise Spearman’s rank correlation

col_var

Column-wise variance (sparse friendly)

cov_mat

Covariance matrix (sparse friendly)

densify

Convert a matrix to dense regardless of original type.

get_chained_attr

Get attribute from an object, with support for chained attribute names.

get_rs

Get random state object

in_ipynb

Determine whether running in an ipynb environment.

logged

Add logger as an attribute

pcc_mat

Pearson’s correlation coefficient (sparse friendly)

prob_or

Combined multiple probabilities in a logical OR manner.

prod

Product of elements

run_command

Run an external command and get realtime output

sigmoid

The sigmoid function in numpy

smart_tqdm

Use tqdm.tqdm or tqdm.tqdm_notebook adaptively based on return value of in_ipynb().

spr_mat

Spearman’s rank correlation

tfidf

TF-IDF normalization (following the Seurat v3 approach)

Classes

ConfigManager

Global configurations

ConstrainedDataFrame

Data frame with certain format constraints

DelayedKeyboardInterrupt

Shield a code block from keyboard interruptions, delaying handling till the block is finished (adapted from https://stackoverflow.com/a/21919644).

LogManager

Manage loggers used in the package

SingletonMeta

Ensure singletons via a meta class