-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmiRsurvival_correlation.r
63 lines (47 loc) · 1.85 KB
/
miRsurvival_correlation.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
rm(list=ls())
options(digits=3,digits.sec=4,device="quartz",max.print=200)
## other options (width=120,error=recover)
## this file has functions that I use most often
## install libraries if needed
install.packages("qvalue")
## install bioconductor package
source("http://bioconductor.org/biocLite.R")
## biocLite("qvalue")
## useful libraries
library(qvalue)
library(MASS)
library(reshape)
library(Hmisc)
## paste operator
"%&%" <- function(a, b) paste(a, b, sep="")
## define subdirectories
pre = 'C:/Users/fan/Desktop/R/'
input.dir = pre %&% 'input/'
output.dir = pre %&% 'output/'
plot.dir = pre %&% 'plots/'
source.dir = pre %&% "sources/"
work.dir = pre
## functions specific to the project
##source(source.dir %&% "functions.r")
## working directory
setwd(work.dir)
## read the data
data.miR.survival = read.table("222.txt",sep='\t', header=T, quote = "\"", stringsAsFactors = F)
##multiple pair-wise LR
phenolist=names(data.miR.survival)[272]
exprlist=names(data.miR.survival)[2:271]
results=data.frame()
pvals <- numeric()
for(cpheno in phenolist) {pheno = data.miR.survival[,cpheno]
for(cexpr in exprlist) {expr = data.miR.survival[,cexpr]
fit = lm(pheno ~ expr)
sumfit=summary(fit)
pvals <- c(pvals, coef(summary(fit))[2,4])
results = rbind( results, data.frame(cexpr, cpheno, coef(sumfit) ) )
print(cpheno)
print(cexpr)
print(summary(fit))}}
write.table(results, file="result.txt", quote=F, col=T, row=F)
##odd or even rows
del <- seq(1, nrow(results), by = 2)
b = results[-del, ]