Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在R中的基因组VCF文件上运行PCA、距离矩阵和其他数学程序?_R_Bioinformatics_Genetics_Vcf Variant Call Format_Google Genomics - Fatal编程技术网

如何在R中的基因组VCF文件上运行PCA、距离矩阵和其他数学程序?

如何在R中的基因组VCF文件上运行PCA、距离矩阵和其他数学程序?,r,bioinformatics,genetics,vcf-variant-call-format,google-genomics,R,Bioinformatics,Genetics,Vcf Variant Call Format,Google Genomics,我正在学习处理VCF(变量调用文件)以生成绘图和报告。这是R代码,我不知道为什么它会崩溃。请建议如何修复它,并告诉适当的教程 library(VariantAnnotation) library(SNPRelate) vcf<-readVcf("test.vcf","hg19") # load your VCF file from a set dir snpgdsVCF2GDS("test.vcf", "my.g

我正在学习处理VCF(变量调用文件)以生成绘图和报告。这是R代码,我不知道为什么它会崩溃。请建议如何修复它,并告诉适当的教程

library(VariantAnnotation)  
library(SNPRelate)

vcf<-readVcf("test.vcf","hg19") # load your VCF file from a set dir

snpgdsVCF2GDS("test.vcf", "my.gds")

snpgdsSummary("my.gds")

genofile <- openfn.gds("my.gds")

#dendogram

dissMatrix  <-  snpgdsDiss(genofile , sample.id=NULL, snp.id=NULL,
autosome.only=TRUE,remove.monosnp=TRUE, maf=NaN, missing.rate=NaN,
num.thread=10, verbose=TRUE)

snpHCluster <-  snpgdsHCluster(dist, sample.id=NULL, need.mat=TRUE,
hang=0.25)

cutTree <- snpgdsCutTree(snpHCluster, z.threshold=15, outlier.n=5,
n.perm = 5000, samp.group=NULL,col.outlier="red", col.list=NULL,
pch.outlier=4, pch.list=NULL,label.H=FALSE, label.Z=TRUE,
verbose=TRUE)

#pca

sample.id <- read.gdsn(index.gdsn(genofile, "sample.id"))

pop_code <- read.gdsn(index.gdsn(genofile, "sample.id")

pca <- snpgdsPCA(genofile)

tab <- data.framesample.id = pca$sample.id,pop =
factor(pop_code)[match(pca$sample.id, sample.id)],EV1 =
pca$eigenvect[,1],EV2 = pca$eigenvect[,2],stringsAsFactors = FALSE)

plot(tab$EV2, tab$EV1, col=as.integer(tab$pop),xlab="eigenvector 2",
ylab="eigenvector 1") legend("topleft", legend=levels(tab$pop),
pch="o", col=1:nlevels(tab$pop))
库(VariantAnotation)
图书馆(高级)

vcf您的代码有几个问题:

-snpgdsHCluster步骤应在DISSMARX上运行,而不是在dist上运行:

snpHCluster <-  snpgdsHCluster(dissMatrix, sample.id=NULL, need.mat=TRUE,
    hang=0.25)

我认为,否则它应该适合您。

我认为,如果您包含test.vcf的一些示例,或者指向一个可以下载小示例文件的位置,人们可以为您提供更多帮助。还有你看到了什么错误,在脚本的哪一部分。上面有很多代码;到底是什么不起作用。
tab <- data.frame(sample.id = pca$sample.id,pop =
   factor(pop_code)[match(pca$sample.id, sample.id)],EV1 =
   pca$eigenvect[,1],EV2 = pca$eigenvect[,2],stringsAsFactors = FALSE)
plot(tab$EV2, tab$EV1, col=as.integer(tab$pop),xlab="eigenvector 2",
    ylab="eigenvector 1") 

legend("topleft", legend=levels(tab$pop),
    pch="o", col=1:nlevels(tab$pop))