上一篇我们的基因体时代-AI, Data和生物资讯 Day24- 使用tidyverse观念来分析基因资料:plyranges分享加入了tidyverse观念的资料处理方法,算是这五年R里面主流的一个语法,而创建IRange/GRange架构的开发者Michael Lawrence也利用tidyverse的原则来建立plyranges包,我们持续整合前面方法搭配plyranges来进行基因注释资料的分享。
之前有介绍过使用AnnotationDbi的介面来对资料封包做存取,分别可以使用columns, keytypes等函数来了解这个资料包有什麽内容,以及可以用什麽资讯来检索,这边介绍获取更大资料的方式,可以利用AnnotationHub,就其目前的资料,至少包含有57231笔资料集可以使用,里面有来自52个组织或是项目的资料包含如UCSC, Ensembl, NIH, EMBL-EBI, NCBI, ENCODE Project, Broad Institute, Stanford等等,来自2643种物种的资讯,里面有人类、细菌、霉菌、寄生虫等等,资料格式有28种,从单纯的列表(list)、资料格(data.frame)到我们前几天分享的GRanges, TxDb甚至序列资料(TwoBit)等,非常丰富。
## load library
library(AnnotationHub)
## construct annotationHub
ah <- AnnotationHub()
## see the elements and resources in the annotationHub
length(ah)
snapshotDate(ah)
mcols(ah)
我们可以使用mcols来看这些resource的一些细节,比如title, dataprovider, species, taxonomyi, genome, description, maintainer, rdatadateadded, preparerclass等等。
> ah %>% mcols() %>% colnames
[1] "title" "dataprovider" "species" "taxonomyid" "genome"
[6] "description" "coordinate_1_based" "maintainer" "rdatadateadded" "preparerclass"
[11] "tags" "rdataclass" "rdatapath" "sourceurl" "sourcetype"
这边我们可以进一步利用query来搜寻资源里面包含有特定字串描述的资源,并且来阅览一下他们的内容
ahs.gtf.resources <- query(ah, c("Homo sapiens", "GRCh38", "gtf"))
ahs.2bit.resources <- query(ah, c("Homo sapiens", "GRCh38", "2bit"))
ahs.gtf.resources.df <- data.frame(ah_id = ahs.gtf.resources$ah_id,
title = ahs.gtf.resources$title,
provider = ahs.gtf.resources$dataprovider,
genome = ahs.gtf.resources$genome,
date = ahs.gtf.resources$rdatadateadded,
dataType = ahs.gtf.resources$rdataclass)
ahs.2bit.resources.df <- data.frame(ah_id = ahs.2bit.resources$ah_id,
title = ahs.2bit.resources$title,
provider = ahs.2bit.resources$dataprovider,
genome = ahs.2bit.resources$genome,
date = ahs.2bit.resources$rdatadateadded,
dataType = ahs.2bit.resources$rdataclass)
> ahs.2bit.resources.df %>% head
ah_id title provider genome date dataType
1 AH49722 Homo_sapiens.GRCh38.cdna.all.2bit Ensembl GRCh38 2015-12-28 TwoBitFile
2 AH49723 Homo_sapiens.GRCh38.dna.primary_assembly.2bit Ensembl GRCh38 2015-12-28 TwoBitFile
3 AH49724 Homo_sapiens.GRCh38.dna_rm.primary_assembly.2bit Ensembl GRCh38 2015-12-28 TwoBitFile
4 AH49725 Homo_sapiens.GRCh38.dna_sm.primary_assembly.2bit Ensembl GRCh38 2015-12-28 TwoBitFile
5 AH49726 Homo_sapiens.GRCh38.ncrna.2bit Ensembl GRCh38 2015-12-28 TwoBitFile
6 AH50067 Homo_sapiens.GRCh38.cdna.all.2bit Ensembl GRCh38 2015-12-29 TwoBitFile
最後,我们可以利用他们的ah_id来进行下载,语法相当单纯,比如我们想要下载一笔名为Homo_sapiens.GRCh38.cdna.all.2bit的资料,我们直接用他的ah_id即为AH49722,用下面的语法即可
Homo.sapiens.GRCh38.cdna.2bit <- ahs.2bit.resources[["AH49722"]]
阅读参考:
Pagès H, Carlson M, Falcon S, Li N (2021). AnnotationDbi: Manipulation of SQLite-based annotations in Bioconductor. R package version 1.54.1, https://bioconductor.org/packages/AnnotationDbi.
Morgan M, Pagès H, Obenchain V, Hayden N (2021). Rsamtools: Binary alignment (BAM), FASTA, variant call (BCF), and tabix file import. R package version 2.8.0, https://bioconductor.org/packages/Rsamtools.
Pagès H (2021). BSgenome: Software infrastructure for efficient representation of full genomes and their SNPs. R package version 1.60.0, https://bioconductor.org/packages/BSgenome.
Morgan M (2019). AnnotationHub: Client to access AnnotationHub resources. R package version 2.18.0.
2017.[Adavanced GenomicRanges, RtrackLayer and Rsamtools]
(https://combine-australia.github.io/2017-05-19-bioconductor-melbourne/AdvGRanges_Rtracklayer_Rsamtools.html)
这个月的规划贴在这篇文章中我们的基因体时代-AI, Data和生物资讯 Overview,也会持续调整!我们的基因体时代是我经营的部落格,如有对於生物资讯、检验医学、资料视觉化、R语言有兴趣的话,可以来交流交流!
<<: 成员 13 人:狼来了! 狼来了! 狼...... 好乖
>>: 成为工具人应有的工具包-10 IECookiesView 02
前言 今日的程序码 => GITHUB 讲解官方范例的权限、扫描、广播的部分。官方范例是使用 ...
今天我们谈到 declarative 声明式和 imperative 命令式, 他的概念比较像是以下...
Boxenn 的 error handling Boxenn 的实作可以在这边复习。 Use Cas...
Pivot 枢纽可以说是分析资料非常重要的一个工具,特别是在於多维度的资料。所以接下来我们会有一连...
函式的说明文件 可以在函式下方使用「'''」撰写函式的说明文件,说明文件可以跨好几行,直到找到下一个...