<jupyter_start><jupyter_text>Available collections:<jupyter_code>msigdb.gene_sets<jupyter_output><empty_output><jupyter_text>Genes in TCGA and LINCS connectivity map:<jupyter_code>tcga_genes = set(tcga.expression.genes('BRCA'))
dcm_genes = set(dcm.entrez_gene_ids.astype(str))
chosen_collections = {
    'KEGG': 'c2.cp.kegg',
    'Reactome': 'c2.cp.reactome',
    'Hallmarks': 'h.all'
}

data = []

min_genes = 15
max_genes = 500

def trimmed_len(collection):
    return len(collection.trim(min_genes, max_genes).gene_sets)


for name, identifier in chosen_collections.items():
    collection = msigdb.load(identifier, 'entrez')
    subset = collection.subset

    tcga_subset = subset(tcga_genes)
    lincs_subset = subset(dcm_genes)
    shared_subset = subset(tcga_genes & dcm_genes)

    data.append({
        'Name': name,
        'ID': identifier,
        'Total': trimmed_len(collection),
        'TCGA': trimmed_len(tcga_subset),
        'LINCS': trimmed_len(lincs_subset),
        'TCGA $\\cap$ LINCS': trimmed_len(shared_subset)
    })
order = [
    'Name', 'ID', 'Total',
    'TCGA', 'LINCS', 'TCGA $\\cap$ LINCS'
]
df = DataFrame(data)[order]
df.style.hide_index()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14439834024896264, 'fraction_numerical': 0.005809128630705394, 'mean_word_length': 4.457013574660634, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '460025', 'license': 'MIT', 'n_tokens_mistral': 481, 'n_tokens_neox': 448, 'n_words': 72, 'path': 'notebooks/Gene_set_collections_summary.ipynb', 'repo_name': 'krassowski/drug-disease-profile-matching-evaluation', 'size': '1205'}