semvec/pypi-packages huggingface dataset:
ciara-python 1.0.4
"Cluster Independent Algorithm for the identification of RAre cell types."
License: MIT
Requires Python: >=3.8

# CIARA <br /> (Cluster Independent Algorithm for the identification of markers of RAre cell types)

Python implementation of the CIARA algorithm that integrates into scanpy's analysis with the AnnData format.

The package can be installed via pip:

`python -m pip install ciara_python`

*Note: The package only works on UNIX / MacOS operating systems, not on Windows systems, due to the copy-on-write multiprocessing setup used.*

## Tutorial

The functions are designed to work with scanpy's AnnData objects. For an interactive tutorial check out the Human Gastrula IPython Notebook which is also part of this repository.

First you load your dataset as a scanpy object and after normal preprocessing calculate the knn-network:

```python
import scanpy as sc

pbmc = sc.datasets.pbmc3k()
sc.pp.filter_cells(pbmc, min_genes=50)
sc.pp.filter_genes(pbmc, min_cells=10)
sc.pp.log1p(pbmc)

sc.pp.pca(pbmc)
sc.pp.neighbors(pbmc)
```

The CIARA package contains the two main functions `get_background_full()` and `ciara()` which should be imported via:

```python
from ciara_python import get_background_full, ciara
```

Afterwards, the background genes get marked by running the `get_background_full()` function on your scanpy dataset. This adds the boolean column 'CIARA_background' to your `pbmc.var` AnnData slot, where relevant background genes are marked.

```python
get_background_full(pbmc, threshold=1, n_cells_low=2, n_cells_high=5)
```

Finally, the `ciara()` function is run on the dataset. This adds the column 'CIARA_p_value' to your `pbmc.var` object, where the calculated p_values for each of the previously marked background genes are stored.

```python
ciara(pbmc, n_cores=4, p_value=0.001, approximation=True, local_region=1)
```

We can then extract the top markers or rare cells (lowest CIARA_p_value) and plot them onto the UMAP:

```python
from matplotlib.pyplot import rc_context

sc.tl.umap(pbmc)

top_markers = pbmc.var.nsmallest(4, ["CIARA_p_value"],)

with rc_context({'figure.figsize': (3, 3)}):
    sc.pl.umap(pbmc, color=top_markers.index.tolist())
```

![UMAP of top 4 rare cell type markers for PBMCs](/figures/umap_CIARA_PBMCs.svg)

## R package

Link to R package:

https://github.com/ScialdoneLab/CIARA/
pysweet-func 1.1.9
Composable Python via syntactic sugar
License: MIT
Requires Python: >=3.8,<4.0
Keywords: utility,functional

pysweet-func
============

|test| |codecov| |Documentation Status| |PyPI version|

Why ``pysweet``?
----------------

Consider the following variants
of the same logic:

.. code:: python

   acc = []

   for x in range(10):
       y = x + 1

       if y % 2 == 0:
           acc.extend([y, y * 2])

.. code:: python

   acc = [
       z for y in (x + 1 for x in range(10))
       for z in [y, y * 2] if y % 2 == 0
   ]

.. code:: python

   from itertools import chain

   acc = list(chain.from_iterable(map(
       lambda x: [x, x * 2],
       filter(
           lambda x: x % 2 == 0,
           map(lambda x: x + 1, range(10)),
       ),
   )))

* The imperative style
  can grow complex as requirements evolve;

* The comprehension style
  can get complicated when nested;

* The functional style
  is not very readable in Python.

In JavaScript, the same logic can be written:

.. code:: js

   acc = [...Array(10).keys()]
       .map(x => x + 1)
       .filter(x => x % 2 === 0)
       .flatMap(x => [x, x * 2])

Can we write analogous code in Python?

Now you can with ``pysweet``!

.. code:: python

   from pysweet import Iterable_

   acc = (
       Iterable_(range(10))
       .map(lambda x: x + 1)
       .filter(lambda x: x % 2 == 0)
       .flat_map(lambda x: [x, x * 2])
       .to_list()
   )

``pysweet`` also offers many other similar features.

``pysweet`` is:

* lightweight, with around 100 lines of code;

* mostly syntactic sugar, so it is
  performant, easy to debug, and easy to learn;

* successfully used in production.

Sweeten Python with ``pysweet``!

Sample features
---------------

* Iterable with method chaining,
  in the spirit of JavaScript and Scala:

.. code:: python

   from pysweet import Iterable_

   (
       Iterable_([1, 2])
       .map(lambda x: x + 1)
       .to_list()
   )
   # [2, 3]

* Multi-expression lambda,
  common in modern languages:

.. code:: python

   from pysweet import block_

   val = lambda: block_(
       x := 1,
       x + 1,
   )
   # val() == 2

* Statement as expression,
  in the spirit of Scala and Haskell
  (``if_`` is also the ternary operator):

.. code:: python

   from pysweet import if_, try_, raise_

   if_(
       True,
       lambda: 1,
       lambda: 2,
   )
   # 1

   try_(
       lambda: raise_(Exception('test')),
       catch=lambda e: str(e),
   )
   # 'test'

Next steps
----------

-  `Installation <https://pypi.org/project/pysweet-func>`__
-  `Documentation <https://pysweet-func.readthedocs.io>`__

.. |test| image:: https://github.com/natso26/pysweet-func/actions/workflows/test.yml/badge.svg?branch=main&event=push
.. |codecov| image:: https://codecov.io/gh/natso26/pysweet-func/branch/main/graph/badge.svg
   :target: https://codecov.io/gh/natso26/pysweet-func
.. |Documentation Status| image:: https://readthedocs.org/projects/pysweet-func/badge/?version=latest
   :target: https://pysweet-func.readthedocs.io/en/latest/?badge=latest
.. |PyPI version| image:: https://badge.fury.io/py/pysweet-func.svg
   :target: https://badge.fury.io/py/pysweet-func