Skip to content

Add Allele Frequency Calculation Example #1

@adamstruck

Description

@adamstruck

Example code for frequency of TP53 mutations in a single cohort:

import gripql

conn = gripql.Connection("http://grip.compbio.ohsu.edu")
graph = conn.graph("bmeg_rc1_2")

# find gene id
gene = "TP53"
for i in graph.query().V().hasLabel("Gene").has(gripql.eq("symbol", gene)):
    gene_id = i.gid


# Find all the aliquots in a cohort with mutation calls
disease = "OV"
proj_id = "Project:TCGA-" + disease
q = graph.query().V(proj_id).in_("InProject").in_("SampleFor").in_("AliquotFor").has(gripql.eq("gdc_attributes.sample_type", "Primary Tumor")).as_("sample").in_("CallsetFor").select("sample")
all_aliquots = []
for row in q:
    all_aliquots.append(row.gid)
print(len(all_aliquots))

# Find all the aliquots in a cohort with mutations in the gene of interest
mut_samples = []
q = graph.query().V(all_aliquots).as_("sample").in_("CallsetFor").outE("AlleleCall")
q = q.has(gripql.eq("ensembl_gene", gene_id)).as_("variant")
q = q.distinct("_from")
for i in q:
    mut_samples.append(i.gid)
freq = (float(len(mut_samples)) / float(len(all_aliquots))) * 100
print(freq)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions