除了使用gdc-client对TCGA中数据进行下载外,还可以利用一下python脚本,对TCGA数据进行下载,但是需要你提供带有fileid的manifest文件
- python 脚本: python_tcga.py
- manifest 文件:manifest.txt
脚本的使用
python python_tcga.py manifest.txt
大概20分钟左右,就可以下载2000个左右的RNAseq表达数据。
这个是python_tcga.py脚本内容
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 10:17:06 2020
@author: dongl
"""
import requests
import json
import re
import sys
import pandas as pd
data_endpt = "https://api.gdc.cancer.gov/data"
mainfest=pd.read_table(sys.argv[1],sep="\t")
ids=list(mainfest['id'].values)
params = {"ids": ids}
response = requests.post(data_endpt,
data = json.dumps(params),
headers={
"Content-Type": "application/json"
})
response_head_cd = response.headers["Content-Disposition"]
file_name = re.findall("filename=(.+)", response_head_cd)[0]
with open(file_name, "wb") as output_file:
output_file.write(response.content)
网友评论