concat_layers.py 737 Bytes
Newer Older
Nicole Bussola's avatar
Nicole Bussola committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#%%
import pandas as  pd
#%%
target = 'ER'
layer1 = 'gene'
layer2 = 'cnv'
layer3 = 'prot'
#%%
for split_id in range(10):

    PATH = f'data/tcga_breast/{target}/{split_id}'
    l1_l2_tr = pd.read_csv(f'{PATH}/{layer1}_{layer2}_tr.txt', sep='\t')
    l1_l2_ts = pd.read_csv(f'{PATH}/{layer1}_{layer2}_ts.txt', sep='\t')
    l3_tr = pd.read_csv(f'{PATH}/{layer3}_tr.txt', sep='\t')
    l3_ts = pd.read_csv(f'{PATH}/{layer3}_ts.txt', sep='\t')

    merged_tr = pd.merge(l1_l2_tr, l3_tr, on='Sample')
    merged_ts = pd.merge(l1_l2_ts, l3_ts, on='Sample')

    merged_tr.to_csv(f'{PATH}/{layer1}_{layer2}_{layer3}_tr.txt', sep='\t', index=False)
    merged_ts.to_csv(f'{PATH}/{layer1}_{layer2}_{layer3}_ts.txt', sep='\t', index=False)

# %%