def test_get_ccle_mrna(): mrna = cbio_client.get_ccle_mrna(['XYZ', 'MAP2K1'], ['A375_SKIN']) assert('A375_SKIN' in mrna) assert(mrna['A375_SKIN'] is not None) assert(mrna['A375_SKIN']['MAP2K1'] > 10) assert(mrna['A375_SKIN']['XYZ'] is None) mrna = cbio_client.get_ccle_mrna(['EGFR', 'BRAF'], ['XXX']) assert('XXX' in mrna) assert(mrna['XXX'] is None)
def test_get_ccle_mrna(): mrna = cbio_client.get_ccle_mrna(['XYZ', 'MAP2K1'], ['A375_SKIN']) assert 'A375_SKIN' in mrna assert mrna['A375_SKIN'] is not None assert mrna['A375_SKIN']['MAP2K1'] > 10 assert mrna['A375_SKIN']['XYZ'] is None mrna = cbio_client.get_ccle_mrna(['EGFR', 'BRAF'], ['XXX']) assert 'XXX' in mrna assert mrna['XXX'] is None
def get_protein_expression(gene_names, cell_types): """Return the protein expression levels of genes in cell types. Parameters ---------- gene_names : list HGNC gene symbols for which expression levels are queried. cell_types : list List of cell type names in which expression levels are queried. The cell type names follow the CCLE database conventions. Example: LOXIMVI_SKIN, BT20_BREAST Returns ------- res : dict[dict[float]] A dictionary keyed by cell line, which contains another dictionary that is keyed by gene name, with estimated protein amounts as values. """ A = 0.2438361 B = 3.0957627 mrna_amounts = cbio_client.get_ccle_mrna(gene_names, cell_types) protein_amounts = copy(mrna_amounts) for cell_type in cell_types: amounts = mrna_amounts.get(cell_type) if amounts is None: continue for gene_name, amount in amounts.items(): if amount is not None: protein_amount = 10**(A * amount + B) protein_amounts[cell_type][gene_name] = protein_amount return protein_amounts
def get_ccle_mrna_levels(): """Get CCLE mRNA amounts using cBioClient""" if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) gene_list = body.get('gene_list') cell_lines = body.get('cell_lines') mrna_amounts = cbio_client.get_ccle_mrna(gene_list, cell_lines) res = {'mrna_amounts': mrna_amounts} return res
def contextualize_stmts(stmts, cell_line, genes): """Contextualize model at the level of INDRA Statements.""" to_remove = [] cell_line_ccle = cell_line + '_SKIN' # Remove genes with CNA = -2 print('Contextualize by CNA') cna = cbio_client.get_ccle_cna(genes, [cell_line_ccle])[cell_line_ccle] for gene in genes: if cna.get(gene) == -2: to_remove.append(gene) print('To remove CNA: %s' % gene) # Remove genes with transcripts in bottom 5% print('Contextualize by mRNA') mrna = cbio_client.get_ccle_mrna(genes, [cell_line_ccle])[cell_line_ccle] mrna_vals = [v for v in mrna.values() if v] if mrna_vals: thresh = numpy.percentile(mrna_vals, 5.0) for gene, val in mrna.items(): if val and val < thresh: to_remove.append(gene) print('To remove mRNA: %s' % gene) # Remove genes with nonsense mutations print('Contextualize by nonsense mutations') variants = read_ccle_variants(genes) to_remove_nonsense = list(variants['nonsense'][cell_line_ccle].keys()) if to_remove_nonsense: print('To remove nonsense: %s' % ', '.join(to_remove_nonsense)) to_remove += to_remove_nonsense # Remove Statements for these genes new_stmts = [] for stmt in stmts: any_to_remove = False for agent in stmt.agent_list(): if agent is not None and agent.name in to_remove: any_to_remove = True break if not any_to_remove: new_stmts.append(stmt) # Remove Statements with irrelevant mutations print('Contextualize by missense mutations') mutations = variants['missense'][cell_line_ccle] muts_to_use = {} for gene, mut_list in mutations.items(): muts_to_use[gene] = [] for mut in mut_list: muts_to_use[gene].append(mut) stmts = ac.filter_mutation_status(new_stmts, mutations, []) return stmts
def analyze_cna_mrna(genes, cell_line): """Plot CNA vs mRNA reported by CCLE for given genes in a cell line.""" import matplotlib.pyplot as plt cna = cbio_client.get_ccle_cna(genes, [cell_line])[cell_line] mrna = cbio_client.get_ccle_mrna(genes, [cell_line])[cell_line] plt.ion() plt.figure() for gene, cna_val in cna.items(): if cna_val is None or gene not in mrna: continue mrna_val = mrna[gene] if mrna_val is None: continue plt.plot(cna_val, mrna_val, 'ro', alpha=0.5) plt.xlim([-2.1, 2.1]) cna_vals = list(range(-2, 3)) plt.title('%s cell line' % cell_line) plt.xticks(cna_vals, [str(c) for c in cna_vals]) plt.ylabel('mRNA amounts reported by CCLE') plt.xlabel('DNA copy number alteration reported by CCLE') plt.show()
def post(self): """Get CCLE mRNA amounts using cBioClient Parameters ---------- gene_list : list[str] A list of HGNC gene symbols to get mRNA amounts for. cell_lines : list[str] A list of CCLE cell line names to get mRNA amounts for. Returns ------- mrna_amounts : dict[dict[float]] A dict keyed to cell lines containing a dict keyed to genes containing float """ args = request.json gene_list = args.get('gene_list') cell_lines = args.get('cell_lines') mrna_amounts = cbio_client.get_ccle_mrna(gene_list, cell_lines) res = {'mrna_amounts': mrna_amounts} return res