-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLocate_Position.py
More file actions
33 lines (25 loc) · 1.4 KB
/
Locate_Position.py
File metadata and controls
33 lines (25 loc) · 1.4 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
scRNA_seq_metadata = [
["cell_id", "sample_id", "cell_type", "condition", "treatment", "sequencing_batch", "nUMI", "nGene", "percent_mt"],
["cell_001", "sample_A", "T-cell", "healthy", "none", "batch_1", 1200, 800, 2.5],
["cell_002", "sample_A", "B-cell", "disease", "drug_X", "batch_1", 1500, 1000, 3.1],
["cell_003", "sample_B", "Monocyte", "disease", "drug_Y", "batch_2", 1800, 1100, 4.0],
["cell_004", "sample_B", "NK-cell", "healthy", "none", "batch_2", 1400, 950, 2.8],
]
for row in scRNA_seq_metadata:
print(row)
# Locate the first element
scRNA_seq_metadata[0]
# Locate the last element
scRNA_seq_metadata[-1]
# Locate the penultimate 倒数第二的 element
scRNA_seq_metadata[-2]
# Locate the row position of a particular data entry
position = scRNA_seq_metadata.index(["cell_004", "sample_B", "NK-cell", "healthy", "none", "batch_2", 1400, 950, 2.8])
# Remove an element in a specific position and save the removed element
removed_element = scRNA_seq_metadata.pop(position)
for row in scRNA_seq_metadata:
print(row)
# ['cell_id', 'sample_id', 'cell_type', 'condition', 'treatment', 'sequencing_batch', 'nUMI', 'nGene', 'percent_mt']
# ['cell_001', 'sample_A', 'T-cell', 'healthy', 'none', 'batch_1', 1200, 800, 2.5]
# ['cell_002', 'sample_A', 'B-cell', 'disease', 'drug_X', 'batch_1', 1500, 1000, 3.1]
# ['cell_003', 'sample_B', 'Monocyte', 'disease', 'drug_Y', 'batch_2', 1800, 1100, 4.0]