<jupyter_start><jupyter_text>Saving the gene names in a Pandas series for mapping between indices and names<jupyter_code>gene_labels_df = pd.DataFrame(data=gene_labels.tolist(), columns=["gene_symbol"])
gene_labels_df.to_csv(os.path.join(output_path, "gene_symbols.tsv"), sep="\t", index=True, header=True)
for tumor_type in tcga.tumor_type.unique():
    if tumor_type not in ['GBMLGG', 'COADREAD', 'BRCA']:
        print(tumor_type)
        
        X_tt = tcga.loc[tcga.tumor_type == tumor_type, gene_labels].as_matrix()
        y_tt = tcga.loc[tcga.tumor_type == tumor_type, "sample_type"].as_matrix()
        # We consider TUMOR everything which is not "Solid Tissue Normal"
        y_tt_num = np.ones(y_tt.shape[0])
        y_tt_num[y_tt != 'Solid Tissue Normal'] = TUMOR
        
        t_out_folder = os.path.join(output_path, tumor_type)
        os.makedirs(t_out_folder, exist_ok=True)
        np.save(os.path.join(t_out_folder, "X.npy"), X_tt)
        np.save(os.path.join(t_out_folder, "y.npy"), y_tt_num)<jupyter_output>ESCA
SARC
OV
ACC
CESC
PAAD
DLBC
LGG
TGCT
HNSC
PCPG
KIRP
KICH
LUAD
BLCA
THYM
PRAD
CHOL
STAD
MESO
SKCM
UCEC
LUSC
UVM
KIRC
LIHC
LAML
READ
UCS
COAD
GBM
THCA<jupyter_text>Aggregates<jupyter_code>aggregates = {
    'LUNG': ['LUAD', 'LUSC'],
    'KIDNEY': ['KIRP', 'KICH', 'KIRC'],
    'COADREAD': ['COAD', 'READ'],
    'GBMLGG': ['LGG', 'GBM']
}
aggregate_folder = os.path.join(output_path, 'aggregates')
for agg_name, agg in aggregates.items():
    print("{:<10}-->{:<30}".format(agg_name, ", ".join(agg)))
    X_tt = tcga.loc[tcga.tumor_type.isin(agg), gene_labels].as_matrix()
    y_tt = tcga.loc[tcga.tumor_type.isin(agg), "sample_type"].as_matrix()
    # We consider TUMOR everything which is not "Solid Tissue Normal"
    y_tt_num = np.ones(y_tt.shape[0])
    y_tt_num[y_tt != 'Solid Tissue Normal'] = TUMOR

    t_out_folder = os.path.join(aggregate_folder, agg_name)
    os.makedirs(t_out_folder, exist_ok=True)
    np.save(os.path.join(t_out_folder, "X.npy"), X_tt)
    np.save(os.path.join(t_out_folder, "y.npy"), y_tt_num)<jupyter_output>LUNG      -->LUAD, LUSC                    
KIDNEY    -->KIRP, KICH, KIRC              
COADREAD  -->COAD, READ                    
GBMLGG    -->LGG, GBM
{'fraction_non_alphanumeric': 0.14535666218034993, 'fraction_numerical': 0.0026917900403768506, 'mean_word_length': 3.6458333333333335, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '532534', 'license': 'MIT', 'n_tokens_mistral': 973, 'n_tokens_neox': 914, 'n_words': 169, 'path': 'notebooks/utils/TCGA_to_MATRICES.ipynb', 'repo_name': 'DEIB-GECO/CIBB2018', 'size': '2229'}