Utilities for BiocPy
Motivation
This repository contains a variety of simple utilities for the BiocPy project,
mostly convenient aspects of R that aren't provided by base Python.
The aim is to simplify development of higher-level packages like scranpy and singler
that would otherwise have to implement these methods individually.
Available utilities
match
import biocutils
biocutils.match(["A", "C", "E"], ["A", "B", "C", "D", "E"])
factor
import biocutils
biocutils.factor(["A", "B", "B", "A", "C", "D", "C", "D"])
intersect
import biocutils
biocutils.intersect(["A", "B", "C", "D"], ["D", "A", "E"])
union
import biocutils
biocutils.union(["A", "B", "C", "D"], ["D", "A", "E"])
subset
import biocutils
biocutils.subset(["A", "B", "C", "D", "E"], [0, 2, 4])
import numpy as np
y = np.array([10, 20, 30, 40, 50])
biocutils.subset(y, [0, 2, 4])
is_list_of_type
Checks if all elements of a list or tuple are of the same type.
import biocutils
import numpy as np
x = [np.random.rand(3), np.random.rand(3, 2)]
biocutils.is_list_of_type(x, np.ndarray)