介绍
grcMalaria 是一个易于使用的、开源的 R 软件包,旨在使遗传流行病学分析任务变得易于操作。
该软件包能够将来自“SpotMalaria 遗传报告卡”(GRC)中提取的疟原虫遗传信息转化为直观的流行率、多样性、亲缘关系等地理图谱。该软件库还能够识别流行毒株、分析药物耐药性特征以及绘制传播路径。
grcMalaria is a user-friendly, open-source R package, designed to make genetic epidemiology analysis tasks accessible.
The package facilitates the translation of genetic information derived from malaria parasites from SpotMalaria Genetic Report Cards (GRC) into intuitive geographical maps of prevalence, diversity, relatedness. This software library is also capable of identifying circulating strains, characterising drug resistance profiles, and mapping spread.
代码
https://genremekong.org/tools/grcmalaria-guide
上述代码是一个用于处理和分析疟疾基因组数据的R脚本,主要目的是从GitHub安装必要的R包,加载数据文件,并对数据进行初步处理和可视化。以下是代码的主要内容和功能:
安装和加载必要的R包
- 安装
devtools
和rgeos
包:这两个包是后续安装其他包和处理地理数据所必需的。 - 安装
grcMalariaGeodata
包:这是一个专门用于处理疟疾基因组地理数据的R包,通过devtools::install_github
从GitHub安装。 - 安装
pcaMethods
包:这是一个用于主成分分析(PCA)的R包,通过BiocManager
安装。
加载数据和检查包版本
- 加载
grcMalariaGeodata
和grcMalaria
包:这两个包提供了处理疟疾基因组数据的函数和工具。 - 检查包版本:确保安装的
grcMalaria
和grcMalariaGeodata
包是最新版本。
加载数据文件
- 使用
loadGrc
函数加载数据:这个函数从指定路径加载GRC(Genomic Resource Center)数据文件,文件格式为Excel(.xlsx
)。需要指定文件路径、工作表名称、物种类型(如Pf
表示疟原虫)和版本号。
初始化上下文
- 使用
initializeContext
函数初始化上下文:这个函数设置了一个分析环境,包括数据、输出目录路径、最小SNP可分型率和最小样本可分型率等参数。
选择样本集
- 使用
selectSampleSet
函数选择样本集:这个函数允许用户根据不同的字段(如国家、时间点、研究等)选择特定的样本集。可以选择一个或多个字段来筛选样本。- 示例1:选择来自越南(VN)、柬埔寨(KH)和老挝(LA)的样本。
- 示例2:选择特定时间点和研究的样本。
- 示例3:选择特定省份和年份的样本。
可视化样本分布
- 使用
mapSampleCounts
函数绘制样本分布图:这个函数生成一个地图,显示选定样本集在不同地理区域的分布情况。可以指定聚合级别(如省份、地区)、最小聚合计数、标记大小、颜色分组等参数。
总结
这段代码的主要目的是为疟疾基因组数据的分析提供一个完整的流程,从安装必要的R包、加载数据文件、初始化分析环境、选择样本集到可视化样本分布。通过这些步骤,研究人员可以有效地处理和分析疟疾基因组数据,为进一步的基因组学研究奠定基础。
## Install devtools and rgeos
install.packages("devtools")
install.packages("rgeos")
##Install grcMalariaGeodata from Github
devtools::install_github("malariagen/grcMalariaGeodata")
## Require these dependencies to install 'malariagen/grcMalaria'
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("pcaMethods")
# Load libraries
library(grcMalariaGeodata)
library(grcMalaria)
# Check package versions grcMalaria and grcMalariaGeodata
# Latest version grcMalariaGeodata: 0.4.0
# Latest stable version of grcMalaria: 2.0.0
packageVersion('grcMalaria')
packageVersion('grcMalariaGeodata')
# Load data file
# Change the path to where your file is located before running the code
Data <- loadGrc("D:/.../GRC.xlsx",
sheet = "GenRe-Mekong",
species = "Pf", version = "1.4")
ctx <- initializeContext(Data,
dir="D:/...", #Change the path to where you want output file to be
minSnpTypability=0.8, minSampleTypability=0.75)
## Select sample set to work on.
# To select samples from 1 field (1 column in the GRC)
selectSampleSet(ctx, sampleSetName="EBKK", select=list(
list(field="Country", values=c("VN", "KH", "LA")) ))
# To select samples from 2 fields
selectSampleSet(ctx, sampleSetName="Laos", select=list(
list(field="TimePoint", values=c("D00H00","-")),
list(field="Study", values=c("1208-PF-LA-CMPE-GENRE")) ))
# To select samples from 3 fields
selectSampleSet(ctx, sampleSetName="SouthLA_2017", select=list(
list(field="Country", values="LA"),
list(field="AdmDiv1", values=c("Attapeu", "Champasak")),
list(field="Year", values=c("2017", "2018")) ))
# To select samples from more fields, follow the example above to add more -> list(field=" ", values = " ")
mapSampleCounts (ctx, sampleSet="EBKK", timePeriods=NULL,
aggregate=c("Province","District"),
minAggregateCount=1,
markerSize=c(10,40),
colourBy="Province",
showNames=TRUE,
...)
mapDrugResistancePrevalence (ctx, sampleSet="EBKK", timePeriods=NULL,
drugs="ALL", aggregate=c("Province","District"),
minAggregateCount=10, showNames=TRUE, markerSize=16,
...)
参考
- https://github.com/GenRe-Mekong/grcMalaria
- https://genremekong.org/tools/grcmalaria-guide