r 用户R从PLINK分析单个SNP。使用有序logit模型分析SNP,SNP作为结果(通常它是完成的

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r 用户R从PLINK分析单个SNP。使用有序logit模型分析SNP,SNP作为结果(通常它是完成的相关的知识,希望对你有一定的参考价值。

#Test the association between a SNP and PTSD, in R, assuming ordered logit of the SNP

#Do the following in PLINK
 plink --bfile --snp rs4680 --recodeA --out rs4680

#Open the corresponding .raw file and note the column name for the SNP. you'll need this for R

#Then load R

R

library(MASS)

setwd('C:/Users/adam/Desktop/PGC-PTSD/phenotype_harmonization/shareefa_check/')

#Merge genotype, phenotype, and covariates
#Assuming that each of the sheets has columns FID and IID which identify subjects

gene <- read.table('rs4680.raw', header=T)
pheno <- read.table('C:/Users/adam/Desktop/PGC-PTSD/phenotype_harmonization/shareefa_check/Copy of C7Y6N1S2_6_2_15_COVs_PCAs_withSA_SD_harm_Jan20162.csv', sep=";", header=T,na.strings=c("NA","#N/A","-9"))

dat <- merge(gene,pheno,all=TRUE,by=c("FID","IID"))


m <- polr(as.factor(rs4680_G) ~ as.numeric(PTSDCurrentContinuous), data = dat, Hess=TRUE)


(ctable <- coef(summary(m)))
p <- pnorm(abs(ctable[, "t value"]), lower.tail = FALSE) * 2

#View beta, se, test stat, P value
(ctable <- cbind(ctable, "p value" = p))



以上是关于r 用户R从PLINK分析单个SNP。使用有序logit模型分析SNP,SNP作为结果(通常它是完成的的主要内容,如果未能解决你的问题,请参考以下文章

2020-01-10 分析SNP位点:连锁不平衡-可视化R包LDheatmap

r 在R中合并PLINK表型和协变量

R数据可视化12:曼哈顿图

群体遗传之ped格式

haploview出现“results file must contain a snp column”的解决方法

Admixture 进行遗传结构分析