https://github.com/biocpy/biocutils
Miscellaneous utilities for BiocPy, mostly to mimic base functionality in R.
https://github.com/biocpy/biocutils
Last synced: about 2 months ago
JSON representation
Miscellaneous utilities for BiocPy, mostly to mimic base functionality in R.
- Host: GitHub
- URL: https://github.com/biocpy/biocutils
- Owner: BiocPy
- License: mit
- Created: 2023-09-13T23:42:25.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-01-19T06:37:57.000Z (over 1 year ago)
- Last Synced: 2024-08-09T08:58:11.865Z (9 months ago)
- Language: Python
- Homepage: https://biocpy.github.io/BiocUtils/
- Size: 525 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
- Authors: AUTHORS.md
Awesome Lists containing this project
README
# Utilities for BiocPy
[](https://pyscaffold.org/)
[](https://pypi.org/project/biocutils/)
[](https://pepy.tech/project/biocutils)
## Motivation
This repository contains a variety of simple utilities for the [BiocPy](https://github.com/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**](https://github.com/BiocPy/scranpy) and [**singler**](https://github.com/BiocPy/singler)
that would otherwise have to implement these methods individually.## Available utilities
### `match`
```python
import biocutils
biocutils.match(["A", "C", "E"], ["A", "B", "C", "D", "E"])
## [0, 2, 4]
```### `factor`
```python
import biocutils
biocutils.factor(["A", "B", "B", "A", "C", "D", "C", "D"])
## (['A', 'B', 'C', 'D'], [0, 1, 1, 0, 2, 3, 2, 3])
```### `intersect`
```python
import biocutils
biocutils.intersect(["A", "B", "C", "D"], ["D", "A", "E"])
## ['A', 'D']
```### `union`
```python
import biocutils
biocutils.union(["A", "B", "C", "D"], ["D", "A", "E"])
## ['A', 'B', 'C', 'D', 'E']
```### `subset`
```python
import biocutils
biocutils.subset(["A", "B", "C", "D", "E"], [0, 2, 4])
## ['A', 'C', 'E']import numpy as np
y = np.array([10, 20, 30, 40, 50])
biocutils.subset(y, [0, 2, 4])
## array([10, 30, 50])
```### `is_list_of_type`
Checks if all elements of a list or tuple are of the same type.
```python
import biocutils
import numpy as npx = [np.random.rand(3), np.random.rand(3, 2)]
biocutils.is_list_of_type(x, np.ndarray)
## True
```