Example #1
0
def gwas_variation_to_genes(meth, workspaceID=None, gwasObjectID=None, num2snps=None, pmin=None, distance=None, gl_out=None, fs_out=None):
    """This method takes the top SNPs obtained after GWAS analysis as input
    (TopVariations) object, -log (pvalue) cutoff and a distance parameter as input.
    For each significant SNP that passes the p-value cutoff, genes are searched in the
    window specified by the distance parameter.

    :param workspaceID: Workspace (use current if empty)
    :type workspaceID: kbtypes.Unicode
    :param gwasObjectID: GWAS analysis MLM result object
    :type gwasObjectID: kbtypes.KBaseGwasData.GwasTopVariations
    :param num2snps: Number to snps
    :type num2snps: kbtypes.Numeric
    :default num2snps: 100
    :param pmin: Minimum pvalue (-log10)
    :type pmin: kbtypes.Numeric
    :default pmin: 4
    :param distance: Distance in bp around SNP to look for genes
    :type distance: kbtypes.Numeric
    :default distance: 10000
    :param gl_out: Output GwasGeneLint workspace object name
    :type gl_out: kbtypes.KBaseGwasData.GwasGeneList
    :param fs_out: Output FeatureSet workspace object name
    :type fs_out: kbtypes.KBaseSearch.FeatureSet
    :return: Workspace objectID of gwas results
    :rtype: kbtypes.Unicode
    :output_widget: ValueListWidget
    """
    meth.stages = 3

    if not workspaceID:
        workspaceID = meth.workspace_id

    meth.advance("init GWAS service")
    gc = GWAS(URLS.gwas, token=meth.token)
    meth.advance("Running Variations to Genes")
    argsx = {"ws_id" : meth.workspace_id, "variation_id" : gwasObjectID,  "out_id": gl_out, "num2snps" : num2snps, "pmin": pmin, "distance" : distance, "comment" : "comment"}
    try:
        gl_oid = gc.variations_to_genes(argsx)
    except Exception as err:
        raise GWASException("submit job failed: {}".format(err))

    ws = Workspace2(token=meth.token, wsid=meth.workspace_id)
    raw_data = ws.get(gl_out)

    gl = [ gr[2] for gr in raw_data['genes']]
    fs = genelist2fs(gl)
    ws.save_objects({'workspace' : meth.workspace_id, 'objects' :[{'type' : 'KBaseSearch.FeatureSet', 'data' : fs, 'name' : fs_out, 'meta' : {'original' : gl_out}}]})

    meth.advance("Returning object")
    return json.dumps({'values': [
                                   ["Workspace GwasGeneList object", gl_out],
                                   ["Workspace FeatureSet object", fs_out]
                                 ]})
Example #2
0
def gwas_variation_to_genes(meth,
                            workspaceID=None,
                            gwasObjectID=None,
                            num2snps=None,
                            pmin=None,
                            distance=None,
                            gl_out=None,
                            fs_out=None):
    """This method takes the top SNPs obtained after GWAS analysis as input
    (TopVariations) object, -log (pvalue) cutoff and a distance parameter as input.
    For each significant SNP that passes the p-value cutoff, genes are searched in the
    window specified by the distance parameter.

    :param workspaceID: Workspace (use current if empty)
    :type workspaceID: kbtypes.Unicode
    :param gwasObjectID: GWAS analysis MLM result object
    :type gwasObjectID: kbtypes.KBaseGwasData.GwasTopVariations
    :param num2snps: Number to snps
    :type num2snps: kbtypes.Numeric
    :default num2snps: 100
    :param pmin: Minimum pvalue (-log10)
    :type pmin: kbtypes.Numeric
    :default pmin: 4
    :param distance: Distance in bp around SNP to look for genes
    :type distance: kbtypes.Numeric
    :default distance: 10000
    :param gl_out: Output GwasGeneLint workspace object name
    :type gl_out: kbtypes.KBaseGwasData.GwasGeneList
    :param fs_out: Output FeatureSet workspace object name
    :type fs_out: kbtypes.KBaseSearch.FeatureSet
    :return: Workspace objectID of gwas results
    :rtype: kbtypes.Unicode
    :output_widget: ValueListWidget
    """
    meth.stages = 3

    if not workspaceID:
        workspaceID = meth.workspace_id

    meth.advance("init GWAS service")
    gc = GWAS(URLS.gwas, token=meth.token)
    meth.advance("Running Variations to Genes")
    argsx = {
        "ws_id": meth.workspace_id,
        "variation_id": gwasObjectID,
        "out_id": gl_out,
        "num2snps": num2snps,
        "pmin": pmin,
        "distance": distance,
        "comment": "comment"
    }
    try:
        gl_oid = gc.variations_to_genes(argsx)
    except Exception as err:
        raise GWASException("submit job failed: {}".format(err))

    ws = Workspace2(token=meth.token, wsid=meth.workspace_id)
    raw_data = ws.get(gl_out)

    gl = [gr[2] for gr in raw_data['genes']]
    fs = genelist2fs(gl)
    ws.save_objects({
        'workspace':
        meth.workspace_id,
        'objects': [{
            'type': 'KBaseSearch.FeatureSet',
            'data': fs,
            'name': fs_out,
            'meta': {
                'original': gl_out
            }
        }]
    })

    meth.advance("Returning object")
    return json.dumps({
        'values': [["Workspace GwasGeneList object", gl_out],
                   ["Workspace FeatureSet object", fs_out]]
    })