-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__add__.py
More file actions
59 lines (47 loc) · 2.08 KB
/
__add__.py
File metadata and controls
59 lines (47 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Notice that the following function is a pseudo example to estimate the RNA velocity from 2 cells
class RNASequencingData:
def __init__(self, gene_expression, spliced_expression, unspliced_expression):
self.gene_expression = gene_expression
self.spliced_expression = spliced_expression
self.unspliced_expression = unspliced_expression
def compute_velocity(self):
velocity = self.spliced_expression - self.unspliced_expression
return velocity
class Cell:
def __init__(self, cell_id, rna_data):
self.cell_id = cell_id
self.rna_data = rna_data
def __add__(self, other):
# Combine RNA sequencing data for two cells
combined_gene_expression = self.rna_data.gene_expression + other.rna_data.gene_expression
combined_spliced_expression = self.rna_data.spliced_expression + other.rna_data.spliced_expression
combined_unspliced_expression = self.rna_data.unspliced_expression + other.rna_data.unspliced_expression
# Create a new RNASequencingData object for the combined data
combined_rna_data = RNASequencingData(
combined_gene_expression,
combined_spliced_expression,
combined_unspliced_expression
)
# Create a new Cell object with the combined data
combined_cell = Cell(cell_id="Combined", rna_data=combined_rna_data)
return combined_cell
# Create RNA sequencing data for two cells
cell1_rna_data = RNASequencingData(
gene_expression=10,
spliced_expression=5,
unspliced_expression=2
)
cell2_rna_data = RNASequencingData(
gene_expression=15,
spliced_expression=9,
unspliced_expression=3
)
# Create Cell objects for the two cells
cell1 = Cell(cell_id="Cell1", rna_data=cell1_rna_data)
cell2 = Cell(cell_id="Cell2", rna_data=cell2_rna_data)
# Combine the RNA sequencing data for cell1 and cell2
combined_cell = cell1 + cell2
# Compute the velocity for the combined data
velocity = combined_cell.rna_data.compute_velocity()
# Print the result
print(f"Combined Cell RNA Velocity: {velocity}")