【发布时间】:2023-03-28 08:25:01
【问题描述】:
我正在尝试使用 snpStats 包执行关联。
我有一个名为“plink”的 snp 矩阵,其中包含我的基因型数据(如 $genotypes、$map、$fam) 和 plink$genotype 的列表具有:SNP 名称作为列名(2 个 SNP),主题标识符作为行名:
plink$genotype
SnpMatrix with 6 rows and 2 columns
Row names: 1 ... 6
Col names: 203 204
可以复制以下 ped 和 map 文件并分别保存为“plink.ped”和 plink.map 来复制 plink 数据集:
plink.ped:
1 1 0 0 1 -9 A A G G
2 2 0 0 2 -9 G A G G
3 3 0 0 1 -9 A A G G
4 4 0 0 1 -9 A A G G
5 5 0 0 1 -9 A A G G
6 6 0 0 2 -9 G A G G
plink.map:
1 203 0 792429
2 204 0 819185
然后这样使用plink:
./plink --file plink --make-bed
@----------------------------------------------------------@
| PLINK! | v1.07 | 10/Aug/2009 |
|----------------------------------------------------------|
| (C) 2009 Shaun Purcell, GNU General Public License, v2 |
|----------------------------------------------------------|
| For documentation, citation & bug-report instructions: |
| http://pngu.mgh.harvard.edu/purcell/plink/ |
@----------------------------------------------------------@
Web-based version check ( --noweb to skip )
Recent cached web-check found...Problem connecting to web
Writing this text to log file [ plink.log ]
Analysis started: Tue Nov 29 18:08:18 2011
Options in effect:
--file /ugi/home/claudiagiambartolomei/Desktop/plink
--make-bed
2 (of 2) markers to be included from [ /ugi/home/claudiagiambartolomei/Desktop /plink.map ]
6 individuals read from [ /ugi/home/claudiagiambartolomei/Desktop/plink.ped ]
0 individuals with nonmissing phenotypes
Assuming a disease phenotype (1=unaff, 2=aff, 0=miss)
Missing phenotype value is also -9
0 cases, 0 controls and 6 missing
4 males, 2 females, and 0 of unspecified sex
Before frequency and genotyping pruning, there are 2 SNPs
6 founders and 0 non-founders found
Total genotyping rate in remaining individuals is 1
0 SNPs failed missingness test ( GENO > 1 )
0 SNPs failed frequency test ( MAF < 0 )
After frequency and genotyping pruning, there are 2 SNPs
After filtering, 0 cases, 0 controls and 6 missing
After filtering, 4 males, 2 females, and 0 of unspecified sex
Writing pedigree information to [ plink.fam ]
Writing map (extended format) information to [ plink.bim ]
Writing genotype bitfile to [ plink.bed ]
Using (default) SNP-major mode
Analysis finished: Tue Nov 29 18:08:18 2011
我还有一个表型数据框,其中包含我想与基因型关联的结果(结果 1、结果 2、...),即:
ID<- 1:6
sex<- rep(1,6)
age<- c(59,60,54,48,46,50)
bmi<- c(26,28,22,20,23, NA)
ldl<- c(5, 3, 5, 4, 2, NA)
pheno<- data.frame(ID,sex,age,bmi,ldl)
当我这样做时,该关联适用于单个术语:(使用公式“snp.rhs.test”):
bmi<-snp.rhs.tests(bmi~sex+age,family="gaussian", data=pheno, snp.data=plink$genotype)
我的问题是,如何循环查看结果?这类数据 似乎与其他所有人不同,我遇到了麻烦 操纵它,所以如果您有建议,我也将不胜感激 一些教程可以帮助我理解如何做到这一点和其他 例如,对 snp.matrix 数据进行子集化等操作。
这是我为循环尝试过的:
rhs <- function(x) {
x<- snp.rhs.tests(x, family="gaussian", data=pheno,
snp.data=plink$genotype)
}
res_ <- apply(pheno,2,rhs)
Error in x$terms : $ operator is invalid for atomic vectors
然后我尝试了这个:
for (cov in names(pheno)) {
association<-snp.rhs.tests(cov, family="gaussian",data=pheno, snp.data=plink$genotype)
}
Error in eval(expr, envir, enclos) : object 'bmi' not found
一如既往地感谢您的帮助! -f
【问题讨论】:
-
您有示例数据集供我们使用吗?
-
你不能在矩阵上使用
$,而是使用snp.matrix[,"genotype"] -
很抱歉给您带来了困惑,我很抱歉让我的问题更清楚,如果这仍然令人困惑,我将尝试添加 plink 中生成的 snpmatrix 数据...
-
@user971102:您仍然缺少
plink变量,因此该示例还不能重现。请提供。 -
如果您只是发布 dput(plink) 会容易得多,而不是建议我们安装另一个(非 R)程序。