MaayanLab / sigcom-lincs

Signature Commons LINCS Repo
3 stars 3 forks source link

API - LINCS chemical perturbagen signatures #70

Closed SanthoshKumarKarthikeyan08 closed 1 year ago

SanthoshKumarKarthikeyan08 commented 1 year ago

Hi,

I am trying to access the LINCS chemical perturbagen signatures through API. I have a list of up and downregulated genes, for which I am interested in obtaining the mimickers and reversers from the LINCS chemical perturbagen signatures database. I tried the tutorial, and the code i modified are as follows:

Python code:

import requests import json

METADATA_API = "https://maayanlab.cloud/sigcom-lincs/metadata-api/" DATA_API = "https://maayanlab.cloud/sigcom-lincs/data-api/api/v1/"

input_gene_set = { "up_genes": ["TARBP1", "APP", "RAP1GAP", "UFM1", "DNAJA3", "PCBD1", "CSRP1"], "down_genes": ["CEBPA", "STAT5B", "DSE", "EIF4EBP1", "CARD8", "HLA-DMA", "SERPINE1"] }

all_genes = input_gene_set["up_genes"] + input_gene_set["down_genes"]

payload = { "filter": { "where": { "meta.symbol": { "inq": all_genes } }, "fields": ["id", "meta.symbol"] } } res = requests.post(METADATA_API + "entities/find", json=payload) entities = res.json()

for_enrichment = { "up_entities": [], "down_entities": [] }

for e in entities: symbol = e["meta"]["symbol"] if symbol in input_gene_set["up_genes"]: for_enrichment["up_entities"].append(e["id"]) elif symbol in input_gene_set["down_genes"]: for_enrichment["down_entities"].append(e["id"])

print(json.dumps(for_enrichment, indent=2))

payload = { "meta": { "$validator": "/dcic/signature-commons-schema/v6/meta/user_input/user_input.json", **for_enrichment }, "type": "signature" } res = requests.post(METADATA_API + "user_input", json=payload) persistent_id = res.json()["id"] print("Access your analysis here: https://maayanlab.cloud/sigcom-lincs#/SignatureSearch/Rank/%s"%persistent_id)

Changed the database selection

query = { **for_enrichment, "limit": 10, "database": "LINCS chemical perturbagen signatures" }

res = requests.post(DATA_API + "enrich/ranktwosided", json=query) results = res.json()

sigids = {i["uuid"]: i for i in results["results"]}

payload = { "filter": { "where": { "id": { "inq": list(sigids.keys()) } } }

res = requests.post(METADATA_API + "signatures/find", json=payload) signatures = res.json()

for sig in signatures: uid = sig["id"] scores = sigids[uid] scores.pop("uuid") sig["scores"] = scores

print(json.dumps(signatures[0:2], indent=2))

Error: Gives an empty signatures array.

The output I expect is: The names of mimickers and reversers form the UUID obtained.

Please help. Thanks in advance!

~Santhosh

jeevangelista commented 1 year ago

Hi @SanthoshKumarKarthikeyan08, you should use l1000_cp instead of "LINCS chemical perturbagen signatures" as the database

SanthoshKumarKarthikeyan08 commented 1 year ago

Great. It works! Thanks, Santhosh