3. scVMAP API

scVMAP provides backend API interface information, and researchers in need can obtain data directly through API interfaces. The interface specifications follow RESTful API standards, and all returned data is in JSON format.

Note

This API method is actually suitable for situations where you need to retrieve data related to a specific sample. For obtaining all the data, it is strongly not recommended to use API operations; instead, it is advised to download the data from the Download page.

Tip

Other websites or applications that embed scVMAP API development are most suitable.

_images/api.png

We provide Python code to retrieve data from API interfaces.

 1# -*- coding: UTF-8 -*-
 2
 3import time
 4
 5import pandas as pd
 6import requests
 7from requests import Response
 8
 9
10def get_result_data(resp: Response):
11    json_data = resp.json()
12
13    if json_data["status"]:
14        return json_data["data"]
15
16    raise ValueError(json_data["message"])
17
18
19if __name__ == '__main__':
20
21    base_url: str = "https://bio.liclab.net/scvmap_service/"
22    sample_id: str = "sample_id_1"
23    trait_id: str = "trait_id_894"
24    genome: str = "hg19"
25    fine_mapping_method: str = "finemap"
26
27    # Test
28    response = requests.get(f"{base_url}/test")
29    print(get_result_data(response))
30
31    time.sleep(3)
32    print("----------------------------------------------------------------------------------")
33
34    # Variant information https://bio.liclab.net/scvmap_service/scvmap.html#/Detail-API/listTraitInfoData
35    response = requests.post(
36        f"{base_url}/detail/trait_info/{trait_id}/{genome}/{fine_mapping_method}",
37        json={
38            "page": 1,
39            "size": 10,
40            "field": "",
41            "order": 0,
42            "searchField": "",
43            "content": "",
44            "type": 1,
45            "symbol": 1
46        }
47    )
48    total_size = get_result_data(response)["total"]
49    response = requests.post(
50        f"{base_url}/detail/trait_info/{trait_id}/{genome}/{fine_mapping_method}",
51        json={
52            "page": 1,
53            "size": total_size,
54            "field": "",
55            "order": 0,
56            "searchField": "",
57            "content": "",
58            "type": 1,
59            "symbol": 1
60        }
61    )
62    variant_data = get_result_data(response)
63    variant_df = pd.DataFrame(variant_data["data"])
64    print(variant_df)
65
66    time.sleep(3)
67    print("----------------------------------------------------------------------------------")
68
69    # MAGMA https://bio.liclab.net/scvmap_service/scvmap.html#/Detail-API/listMagmaGeneByTraitId
70    response = requests.get(f"{base_url}/detail/magma_gene/{trait_id}/{genome}")
71    magma_data = get_result_data(response)
72    magma_df = pd.DataFrame(magma_data)
73    print(magma_df)
 1Connection test successful!
 2----------------------------------------------------------------------------------
 3           traitId     sourceId   chr  ... findex       pvalue              zscore
 40     trait_id_894  source_id_1  chr1  ...   1553  3.71279e-40  13.264584871821922
 51     trait_id_894  source_id_1  chr1  ...   1569  1.27087e-41  13.515227089114475
 62     trait_id_894  source_id_1  chr1  ...   1566  1.59038e-41  13.498714449933749
 73     trait_id_894  source_id_1  chr1  ...   1567   7.1796e-42  13.557193629064104
 84     trait_id_894  source_id_1  chr1  ...   1559  6.38263e-42  13.565799634934008
 9...            ...          ...   ...  ...    ...          ...                 ...
102195  trait_id_894  source_id_1  chr9  ...    876  6.75943e-10   6.171597123541317
112196  trait_id_894  source_id_1  chr9  ...    904  6.74388e-10   6.171967446066399
122197  trait_id_894  source_id_1  chr9  ...    836  3.41044e-10   6.278847312864843
132198  trait_id_894  source_id_1  chr9  ...    869  2.58988e-09   5.955671300308524
142199  trait_id_894  source_id_1  chr9  ...    916  2.99909e-09   5.931628007804032
15
16[2200 rows x 19 columns]
17----------------------------------------------------------------------------------
18          traitId        gene chr  ...      pvalue  nsnps  zvalue
190    trait_id_894       AAMDC  11  ...  3.2869e-07     32  4.9736
201    trait_id_894     AFG3L1P  16  ...       5e-10      2  6.1094
212    trait_id_894      ALOX12  17  ...  7.7875e-09      1  5.6551
223    trait_id_894  ALOX12-AS1  17  ...  7.8535e-09      2  5.6537
234    trait_id_894    ALOX12P2  17  ...  2.8279e-09      1  5.8266
24..            ...         ...  ..  ...         ...    ...     ...
25180  trait_id_894   ZFHX4-AS1   8  ...  3.5305e-14     28  7.4867
26181  trait_id_894       ZFPM1  16  ...  1.0679e-12      9  7.0253
27182  trait_id_894      ZNF276  16  ...  8.5389e-17      1  8.2410
28183  trait_id_894      ZNF469  16  ...  4.9616e-07      1  4.8932
29184  trait_id_894      ZSWIM4  19  ...  1.9492e-08      2  5.4954
30
31[185 rows x 8 columns]

Note

Do not access the API with long-term multi-threaded requests. If it affects the server’s access speed or even impacts server operation, we will disable the IP address from which the access originates.