pilotpy 2.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pilotpy/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ __version__ = "2.0.2"
2
+ __author__ = 'Mehdi Joodaki'
3
+ __credits__ = 'Institute for Computational Genomics'
4
+
5
+ from . import tl
6
+ from . import pl
pilotpy/pl.py ADDED
@@ -0,0 +1 @@
1
+ from .plot import *
@@ -0,0 +1,5 @@
1
+ from .ploting import *
2
+ from .curve_activity import *
3
+ from .gene_selection_analysis import *
4
+ from .pseudobulk_DE_analysis import *
5
+
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ # This code had been adapted from https://github.com/pinellolab/dictys
4
+ # Wang, L., Trasanidis, N., Wu, T. et al. Dictys: dynamic gene regulatory
5
+ ## network dissects developmental continuum with single-cell multiomics.
6
+ ### Nat Methods 20, 1368–1378 (2023).
7
+
8
+ import numpy as np
9
+
10
+ def auc(curves, times):
11
+ """
12
+ Computes area under the curves.
13
+ Parameters
14
+ ----------
15
+ times: numpy.ndarray(shape=(n,))
16
+ X coordinates
17
+ curves: numpy.ndarray(shape=(ny,n))
18
+ Y coordinates, one for each y curve
19
+ Returns
20
+ -------
21
+ numpy.ndarray(shape=(ny,))
22
+ Area under the curves
23
+ """
24
+
25
+ if len(times) < 2 or not (times[1:] > times[:-1]).all():
26
+ raise ValueError('times must be increasing and have at least 2 values.')
27
+ timesdiff = times[1:] - times[:-1]
28
+ curvesmean = (curves[:,1:] + curves[:, :-1]) / 2
29
+ ans = curvesmean@timesdiff
30
+ return ans
31
+
32
+ def _curvesnamic_network_char_terminal_logfc_(curves, times):
33
+ """
34
+ Computes terminal logFC for curves.
35
+ Parameters
36
+ ----------
37
+ times: numpy.ndarray(shape=(n,))
38
+ X coordinates
39
+ curves: numpy.ndarray(shape=(ny,n))
40
+ Y coordinates, one for each y curve
41
+ Returns
42
+ -------
43
+ numpy.ndarray(shape=(ny,))
44
+ Terminal logFCs
45
+ """
46
+ if len(times) < 2 or not (times[1:] > times[:-1]).all():
47
+ raise ValueError('times must be increasing and have at least 2 values.')
48
+ return (curves[:,-1] - curves[:,0]) / (times[-1] - times[0])
49
+
50
+ def _curvesnamic_network_char_transient_logfc_(curves, times):
51
+ """
52
+ Computes transient logFC for curves.
53
+ Parameters
54
+ ----------
55
+ times: numpy.ndarray(shape=(n,))
56
+ X coordinates
57
+ curves: numpy.ndarray(shape=(ny,n))
58
+ Y coordinates, one for each y curve
59
+ Returns
60
+ -------
61
+ numpy.ndarray(shape=(ny,))
62
+ Transient logFCs
63
+ """
64
+ n = curves.shape[1]
65
+ times = (times - times[0]) / (times[-1] - times[0])
66
+ curves = curves - np.median([curves, np.repeat(curves[:, [0]], n, axis = 1), np.repeat(curves[:, [-1]], n, axis = 1)], axis = 0)
67
+ return auc(curves, times)
68
+
69
+ def _curvesnamic_network_char_switching_time_(curves, times):
70
+ """
71
+ Computes switching time for curves.
72
+ Parameters
73
+ ----------
74
+ times: numpy.ndarray(shape=(n,))
75
+ X coordinates
76
+ curves: numpy.ndarray(shape=(ny,n))
77
+ Y coordinates, one for each y curve
78
+ Returns
79
+ -------
80
+ numpy.ndarray(shape=(ny,))
81
+ Switching time
82
+ """
83
+ n = curves.shape[1]
84
+ times = (times - times[0]) / (times[-1] - times[0])
85
+ curves = np.median([curves, np.repeat(curves[:, [0]], n, axis = 1), np.repeat(curves[:, [-1]], n, axis = 1)], axis = 0)
86
+ return (auc((curves.T - curves[:, -1]).T, times)) / (curves[:, 0] - curves[:, -1] + 1E-300)
87
+
88
+
89
+ def _curvesnamic_network_char_area_(curves, times):
90
+ return abs(curves[:, 0] + curves[:, -1]) * abs(times[-1] - times[0])
91
+
92
+