script for calcuating various OR & output csv
This commit is contained in:
parent
a1cc7ee33d
commit
003b22ce3f
2 changed files with 117 additions and 305 deletions
|
@ -167,7 +167,7 @@ cat(paste0('Total no. of distinct comp snps to perform OR calcs: ', length(gene_
|
|||
#x = as.numeric(mut)
|
||||
#y = dst
|
||||
|
||||
custom_chisq_or = function(x,y){
|
||||
mychisq_or = function(x,y){
|
||||
tab = as.matrix(table(x,y))
|
||||
a = tab[2,2]
|
||||
if (a==0){ a<-0.5}
|
||||
|
@ -232,7 +232,7 @@ pval_fisher = fisher.test(table(mut, dst))$p.value; print(paste0('pval fisher:',
|
|||
|
||||
|
||||
#3) custom chisq
|
||||
or_mychisq = custom_chisq_or(mut,dst)
|
||||
or_mychisq = mychisq_or(mut,dst)
|
||||
|
||||
#4) logistic
|
||||
summary(model<-glm(dst ~ mut, family = binomial))
|
||||
|
@ -277,7 +277,7 @@ snps
|
|||
# custom chisq
|
||||
ors = sapply(snps,function(m){
|
||||
mut = grepl(m,raw_data$all_muts_gene)
|
||||
custom_chisq_or(mut,dst)
|
||||
mychisq_or(mut,dst)
|
||||
})
|
||||
head(ors)
|
||||
|
||||
|
@ -423,7 +423,7 @@ x = sapply(snps,function(m){
|
|||
ci_upper_logistic = ci_mod[["97.5 %"]]
|
||||
|
||||
# custom_chisq and fisher: OR p-value and CI
|
||||
or_mychisq = custom_chisq_or(dst, mut)
|
||||
or_mychisq = mychisq_or(dst, mut)
|
||||
|
||||
or_fisher = fisher.test(dst, mut)$estimate
|
||||
or_fisher = or_fisher[[1]]
|
||||
|
@ -523,7 +523,7 @@ for (i in snps){
|
|||
#=====================
|
||||
# custom chi square
|
||||
#=====================
|
||||
or_mychisq = custom_chisq_or(mut,dst)
|
||||
or_mychisq = mychisq_or(mut,dst)
|
||||
|
||||
#=====================
|
||||
# chi square
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue