2011-11-29 3 views
0

snpStats 패키지를 사용하여 연결을 수행하려고합니다.S4 개체의 반복 열이 R

내 유전자형 데이터 ( $ genotypes, $ map, $ fam의 목록)를 포함하는 plink라는 plp 매트릭스가 있고 plink $ genotype은 다음과 같습니다. SNP 이름이 열 이름 (2 SNP)이고

plink$genotype 
SnpMatrix with 6 rows and 2 columns 
Row names: 1 ... 6 
Col names: 203 204 

가용 스루풋 데이터 세트는 다음 PED 및지도 파일을 복사하고 'plink.ped'로 저장 각각 plink.map '재현 할 수 있습니다 :

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를 사용하십시오 :

, I은 ​​또한 결과를 포함하는 표현형 데이터 프레임을

은 (outcome1, outcome2, ...) I이 인 유전자형으로 연결하고자

./plink --file plink --make-bed 

@[email protected] 
|  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/  | 
@[email protected] 

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 
:

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) 

내 질문은, 어떻게 결과를 통해 I를 루프를 할 수 있습니까? 이 데이터 유형 은 다른 모든 것과 다르게 보입니다. 문제가 발생하면 을 조작합니다. 제안 사항이 있으면 내게 도움이 될 수있는 자습서 중 일부는 하위 집합과 같이 처리하는 데 도움이됩니다. 예를 들어 snp.matrix 데이터.

Error in eval(expr, envir, enclos) : object 'bmi' not found

for (cov in names(pheno)) { 
association<-snp.rhs.tests(cov, family="gaussian",data=pheno, snp.data=plink$genotype) 
} 
당신의 도움을 평소와 같이 주셔서 감사합니다 : 그럼이 시도

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

:

내가 루프 시도 것입니다 ! -f

+0

함께 놀 수있는 예제 데이터 세트가 있습니까? –

+2

행렬에'$'를 쓰지 말고, 대신에 snp.matrix [, "genotype"]'을 사용하십시오. – James

+0

혼란을 가져 주셔서 진심으로 질문드립니다. 생성 된 snpmatrix 데이터를 추가하겠습니다. 이것이 여전히 혼란 스럽다면 plink ... – user971102

답변

3

snpStats의 저자는 David Clayton입니다. 패키지 설명에 나와있는 웹 사이트는 잘못이지만, 그는 해당 도메인에 여전히이며이 규격과 구글의 고급 검색 기능을 사용하여 문서에 대한 검색을 수행 할 수있다 :

snpStats site:https://www-gene.cimr.cam.ac.uk/staff/clayton/ 

당신의 어려움에 대한 가능성이 이유 이 패키지는 S4 패키지이며 액세스 방법이 다릅니다. 인쇄 방법 대신에 S4 개체는 일반적으로 표시 방법을 가지고 있습니다. 이 여기 패키지에 네트입니다 : https://www-gene.cimr.cam.ac.uk/staff/clayton/courses/florence11/practicals/practical6.pdf, 그리고 그의 전체 짧은 코스 디렉토리 액세스를 위해 열려 있습니다 : https://www-gene.cimr.cam.ac.uk/staff/clayton/courses/florence11/

그것은 개체에 액세스 할 수 있습니다 snp.rhs.tests에서 반환 된 것이 분명해진다 "["사용 순차 번호 또는 이름은 7 페이지에 설명되어 있습니다.당신은 이름을 얻을 수 있습니다 : 당신이 열을 호출 할 수있다

# Using the example on the help(snp.rhs.tests) page: 

> names(slt3) 
[1] "173760" "173761" "173762" "173767" "173769" "173770" "173772" "173774" 
[9] "173775" "173776" 

일들은 "슬롯"

> getSlots(class(slt3)) 
    snp.names var.names  chisq   df   N 
     "ANY" "character" "numeric" "integer" "integer" 
> str(getSlots(class(slt3))) 
Named chr [1:5] "ANY" "character" "numeric" "integer" "integer" 
- attr(*, "names")= chr [1:5] "snp.names" "var.names" "chisq" "df" ... 
> names(getSlots(class(slt3))) 
[1] "snp.names" "var.names" "chisq"  "df"  "N"   

하지만 그 슬롯 이름을 통해 반복에 대한 [i,j] 방법이없는 아마. 대신 해당 S4 클래스에 대해 정의 된 메소드 목록이있는 ?"GlmTests-class" 도움말 페이지로 이동해야합니다.

1

필요한 초기 포스터가 무엇인지 할 수있는 올바른 방법 :

for (i in ncol(pheno)) { 
    association <- snp.rhs.tests(pheno[,i], family="gaussian", snp.data=plink$genotype) 
} 

snp.rhs.tests()의 문서 데이터가 누락 된 경우, 표현형이 상위 프레임에서 가져온 것을 말한다 - 또는 어쩌면 그것이에 나가셨했다 반대 의미 : 데이터가 지정되면 표현형은 지정된 data.frame으로 평가됩니다.

for (i in ncol(pheno)) { 
    cc <- pheno[,i] 
    association <- snp.rhs.tests(cc, family="gaussian", snp.data=plink$genotype) 
} 
1

문서는 data=parent.frame()snp.rhs.tests()의 기본 말한다 :

이것은 명확한 버전입니다.

apply() 코드에 눈부신 오류가 있습니다. 매우 나쁜 것이므로 x <- some.fun(x)을 입력하십시오. 대신 이것을 시도하십시오 - data=을 삭제하고 다른 변수 이름을 사용하십시오.

rhs <- function(x) { 
y<- snp.rhs.tests(x, family="gaussian", snp.data=plink$genotype) 
} 
res_ <- apply(pheno,2,rhs) 

초기 포스터의 질문도 오해의 소지가 있습니다.

plink $ genotype은 S4 개체이며, pheno는 data.frame (S3 개체)입니다. S3 data.frame의 열을 선택하기를 원하지만, snp.rhs.tests()가 열 (data.frame이 주어진 경우) 또는 벡터 표현형 (if 서브 루틴이 "하위"프레임에서 평가되기 때문에 부모 프레임 또는 "현재"프레임의 평범한 벡터로 표시됩니다.

관련 문제