群体遗传学gwas学习

群体遗传 || Pophelper-群体结构可视化学习

2020-07-03  本文已影响0人  Dawn_WangTP

Pophelper基本说明

群体遗传下游分析中的一项常规分析即是群体结构的分层展示(STRUCTURE ANALYSIS),不同于系统树和PCA,群体结构分层可以分断出小群体的个数,每个小群体之间的基因交流情况,甚至是小群体或者个体内的血源组成。

群体结构分层常用软件有STRUCTUREADMIXTUREfaststructure。STRUCTURE是群体结构分析的经典软件,但运行速度较慢。ADMIXTURE和faststructure软件等是近些年较新的软件,由于运算速度相对较快,已有了较多的引用次数。

群体结构分层的可视化展示通常是以堆叠柱状图所展示,Pophelper即是面向群体结构分层展示的强大的R包软件。

使用介绍

1. 安装

R version >3.5

# install the dependency packages
install.packages(c("devtools","ggplot2","gridExtra","gtable","label.switching","tidyr"),dependencies=T)

# install pophelper package from GitHub
devtools::install_github('royfrancis/pophelper')

2. 读取文件

Pophelper接受structure,admixture,faststructure,tess等软件的输出文件。个人较熟悉的ADMIXTURE和faststructure,其输出文件结构都是以meanQ和meanP的矩阵文件。

library(pophelper)
options(stringsAsFactors = F)
dir.create("pophelper_learning")
setwd("pophelper_learning/")

### INPUT STRUCTURE RESULT FILES
sfiles <- list.files(path=system.file("files/structure",package="pophelper"), full.names=T)
slist <- readQ(files=sfiles)

### INPUT ADMIXTURE RESULT FILES
alist <- readQ(list.files(path=system.file("files/admixture",package="pophelper"), full.names=T)

3. 绘制最佳K值线

Pophelper中evannoMethodStructure()函数仅支持对STRUCTURE的结果绘制最佳K值线。其基本步骤包括三步

  1. tabularQ(),接收读取的structure list文件
  2. summariseQ(),接收tabularQ返回结果
  3. evannoMethodStructure(),接收summ返回结果,绘制最佳K值线
tbq <- tabulateQ(slist)
smq <- summariseQ(tbq)
evannoMethodStructure(data=sr1,exportplot=T,returnplot=T,returndata=F,basesize=12,linesize=0.7,height = 10,width = 12,outputfilename = "test")

4. 绘制柱状堆叠图plotQ()

image

一个plotQ包含了复杂的柱状堆叠图的参数,一些常用参数:

5. 一些群体结构图的示例

sfiles <- list.files(path=system.file("files/structure",package="pophelper"), full.names=T)
slist <- readQ(files=sfiles,indlabfromfile=T)
threelabset <- read.delim(system.file("files/metadata.txt", package="pophelper"), header=T,stringsAsFactors=F)
twolabset <- threelabset[,2:3] ### group label

##绘图
plotQ(slist[2:3],imgoutput="join",showindlab=T,grplab=twolabset,
      subsetgrp=c("Brazil","Greece"),selgrp="loc",ordergrp=T,showlegend=T,
      showtitle=T,showsubtitle=T,titlelab="The Great Structure",
      subtitlelab="The amazing population structure of your favourite organism.",
      height=1.6,indlabsize=2.3,indlabheight=0.08,indlabspacer=-1,
      barbordercolour="white",barbordersize=0,outputfilename="plotq",imgtype="png")
image image image

Reference
[http://www.royfrancis.com/pophelper/articles/index.html#plotq]

上一篇 下一篇

猜你喜欢

热点阅读