0
点赞
收藏
分享

微信扫一扫

blupf90根据G矩阵和H矩阵构建PCA分析以及与Plink以及GCTA的结果对比

hoohack 2022-02-16 阅读 19


模拟一套数据, 5个世代, 最后三代有基因型数据, 每个世代400个个体, SNP为50K

1. blupf90构建G矩阵的PCA

blupf90如果想要进行GBLUP分析, 不写系谱信息即可, 示例par文件:

DATAFILE
dat_f90.txt
TRAITS
10 # This is column 10 (phenotype) from QMSim data file
FIELDS_PASSED TO OUTPUT
1 # This will copy the ID number to the renf90.dat data file
WEIGHT(S) # WARNING: ALWAYS PUT AN EMPTY LINE AFTER THIS!!!!!

RESIDUAL_VARIANCE
0.9 # add starting values for residual variance
EFFECT
4 cross alpha # Fit generation as a fixed effect, 'cross alpha' is a class in SAS
EFFECT
1 cross alpha # Fit animal effect
RANDOM
animal # Fit animal effect (A matrix) for the effect directly above it (column 1, animal)
#FILE
#ped_f90.txt # pedigree file (animal, sire, dam), 0's are missing always!!!
#FILE_POS
#1 2 3 0 0 # indicates that column 1 = Animal, column 2 = Sire, column 3 = Dam
SNP_FILE
yM.txt
(CO)VARIANCES
0.1 # add starting values for additive animal effect
OPTION alpha_size 25 # Equal to the max number of characters within a column
OPTION max_string_readline 800 # maximum number of characters in one line of data file
OPTION max_field_readline 100 # maximum number of columns in the dataset
#OPTION saveHinvOrig
#OPTION saveHinv
#OPTION sol se
#OPTION use_yams
#OPTION missing -999
OPTION plotpca

运行​​preGSf90​​​后, 会生成​​pc1vspc2​​文件, 里面包括PC1和PC2两列, 增加世代为pop, 然后使用R画图:

pca = read.table(("pc1vspc2"))
head(pca)
names(pca) = c("PC1","PC2")
pca$pop = rep(c("A","B","C"),each=400)
library(ggplot2)
p <- ggplot(pca, aes(x=PC1, y=PC2, colour=pop))
p <- p + geom_point(size=2)
p <- p + stat_ellipse(level = 0.95, size = 1)
p <- p + geom_hline(yintercept = 0)
p <- p + geom_vline(xintercept = 0)
p <- p + theme_bw()
p

结果:

blupf90根据G矩阵和H矩阵构建PCA分析以及与Plink以及GCTA的结果对比_数据

2. blupf90构建H矩阵的PCA

需要定义系谱和基因型, 示例​​par​​文件:

DATAFILE
dat_f90.txt
TRAITS
10 # This is column 10 (phenotype) from QMSim data file
FIELDS_PASSED TO OUTPUT
1 # This will copy the ID number to the renf90.dat data file
WEIGHT(S) # WARNING: ALWAYS PUT AN EMPTY LINE AFTER THIS!!!!!

RESIDUAL_VARIANCE
0.9 # add starting values for residual variance
EFFECT
4 cross alpha # Fit generation as a fixed effect, 'cross alpha' is a class in SAS
EFFECT
1 cross alpha # Fit animal effect
RANDOM
animal # Fit animal effect (A matrix) for the effect directly above it (column 1, animal)
FILE
ped_f90.txt # pedigree file (animal, sire, dam), 0's are missing always!!!
FILE_POS
1 2 3 0 0 # indicates that column 1 = Animal, column 2 = Sire, column 3 = Dam
SNP_FILE
yM.txt
(CO)VARIANCES
0.1 # add starting values for additive animal effect
OPTION alpha_size 25 # Equal to the max number of characters within a column
OPTION max_string_readline 800 # maximum number of characters in one line of data file
OPTION max_field_readline 100 # maximum number of columns in the dataset
#OPTION saveHinvOrig
#OPTION saveHinv
#OPTION sol se
#OPTION use_yams
#OPTION missing -999
OPTION plotpca

运行​​preGSf90​​​后, 会生成​​pc1vspc2​​文件, 里面包括PC1和PC2两列, 增加世代为pop, 然后使用R画图:

pca = read.table(("pc1vspc2"))
head(pca)
names(pca) = c("PC1","PC2")
pca$pop = rep(c("A","B","C"),each=400)
library(ggplot2)
p <- ggplot(pca, aes(x=PC1, y=PC2, colour=pop))
p <- p + geom_point(size=2)
p <- p + stat_ellipse(level = 0.95, size = 1)
p <- p + geom_hline(yintercept = 0)
p <- p + geom_vline(xintercept = 0)
p <- p + theme_bw()
p

blupf90根据G矩阵和H矩阵构建PCA分析以及与Plink以及GCTA的结果对比_r语言_02

3. plink根据G矩阵做PCA

代码:

plink --file b --pca 3

结果生成:

plink.eigenval  plink.eigenvec  plink.log  plink.nosex

R语言作图:

library(ggplot2)
head(dd)
p <- ggplot(dd, aes(x=PC1, y=PC2, colour=pop))
p <- p + geom_point(size=2)
p <- p + stat_ellipse(level = 0.95, size = 1)
# p <- p + scale_color_manual(values = cols)
p <- p + geom_hline(yintercept = 0)
p <- p + geom_vline(xintercept = 0)
p <- p + theme_bw()
p

blupf90根据G矩阵和H矩阵构建PCA分析以及与Plink以及GCTA的结果对比_数据_03

4. gcta64根据G矩阵做PCA

将ped文件转化为bed文件

plink --file b --make-bed --out c

生成grm文件

gcta64 --bfile c --autosome --make-grm --out grm

生成pca文件

gcta64 --grm grm --pca 3

根据PCA信息作图

blupf90根据G矩阵和H矩阵构建PCA分析以及与Plink以及GCTA的结果对比_sed_04

注意: GCTA做PCA时, 坐标和plink或者blupf90坐标是反着的, 因此有些差异. 不信, 你可以从图的后面看, 它就和plink的结果一致了.(哭脸)

blupf90根据G矩阵和H矩阵构建PCA分析以及与Plink以及GCTA的结果对比_数据_05



举报

相关推荐

0 条评论