-
Notifications
You must be signed in to change notification settings - Fork 0
/
extend_hela_tables.py
59 lines (48 loc) · 2.46 KB
/
extend_hela_tables.py
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
# adding the information about organelles per tomogram to the hela tables
# https://docs.google.com/spreadsheets/d/12a4-xcPqJzGReId5vqkCx6NSn1VojsvY_vf0qOZHnhk/edit#gid=0
import pandas as pd
TOMOGRAMS = {
"tomo_37": ["ribosomes", "golgi", "microtubule", "endo/lysosome"],
"tomo_38": ["ribosomes", "golgi", "filaments bundle", "endo/lysosome", "autophagosome", "endoplasmic reticulum"],
"tomo_40": ["ribosomes", "endo/lysosome", "golgi"],
"tomo_41": ["ribosomes", "endo/lysosome", "golgi", "filaments bundle"],
"tomo_53": ["golgi", "endo/lysosome", "autophagosome", "filaments bundle", "microtubule"],
"tomo_54": ["mitochondrion", "endoplasmic reticulum", "microtubule", "filaments bundle"],
}
def extend_hela_table(table):
all_organelles = list(set(
[organelle for organelles in TOMOGRAMS.values() for organelle in organelles]
))
all_organelles.sort()
print(all_organelles)
tab = pd.read_csv(table, sep="\t")
tomo_names = ["_".join(name.split("_")[:2]) for name in tab["source"]]
print(tomo_names)
for organelle in all_organelles:
new_col = [int(organelle in TOMOGRAMS[name]) for name in tomo_names]
tab[organelle] = new_col
tab.to_csv(table, index=False, sep="\t")
def update_hela_table(table):
all_organelles = list(set(
[organelle for organelles in TOMOGRAMS.values() for organelle in organelles]
))
all_organelles.sort()
print(all_organelles)
tab = pd.read_csv(table, sep="\t")[["region_id", "source"]]
tomo_names = ["_".join(name.split("_")[:2]) for name in tab["source"]]
print(tomo_names)
for organelle in all_organelles:
new_col = ["yes" if organelle in TOMOGRAMS[name] else "no" for name in tomo_names]
tab[organelle] = new_col
tab.to_csv(table, index=False, sep="\t")
def restore_annotation_color(table, is_lowmag):
tab = pd.read_csv(table, sep="\t")
color = "255-0-146-255" if is_lowmag else "0-255-146-0"
tab["annotationColor"] = [color] * len(tab)
tab.to_csv(table, index=False, sep="\t")
# extend_hela_table("./data/hela/tables/highmag_tomos/default.tsv")
# extend_hela_table("./data/hela/tables/lm-tomogram-table/default.tsv")
# update_hela_table("./data/hela/tables/highmag_tomos/default.tsv")
# update_hela_table("./data/hela/tables/lm-tomogram-table/default.tsv")
restore_annotation_color("./data/hela/tables/lm-tomogram-table/default.tsv", True)
restore_annotation_color("./data/hela/tables/highmag_tomos/default.tsv", False)